Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go dependencies #206

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Conversation

aefhm
Copy link
Contributor

@aefhm aefhm commented Oct 17, 2023

Description

Upgrade go-ethereum and correct Web3 gateway reference.

Supersede #201

Testing

I normally use a base script adapted from the deprecated go-etherum book with our Vigil.sol contract.

package main

import (
	"context"
	"crypto/ecdsa"
	"fmt"
	"log"
	"math/big"

	"github.com/aefhm/vigil"
	"github.com/ethereum/go-ethereum/accounts/abi/bind"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/crypto"
	"github.com/ethereum/go-ethereum/ethclient"
	sapphire "github.com/oasisprotocol/sapphire-paratime/clients/go"
)

var SapphireChainID = big.NewInt(0x5aff)

func main() {
	c, err := ethclient.Dial("https://testnet.sapphire.oasis.dev")
	if err != nil {
		log.Fatal(err)
	}

	privateKey, err := crypto.HexToECDSA("")
	if err != nil {
		log.Fatal(err)
	}

	publicKey := privateKey.Public()
	publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
	if !ok {
		log.Fatal("error casting public key to ECDSA")
	}

	var client *sapphire.WrappedBackend
	client, err = sapphire.WrapClient(*c, func(digest [32]byte) ([]byte, error) { return crypto.Sign(digest[:], privateKey) })

	if err != nil {
		log.Fatal(err)
	}

	fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
	nonce, _ := client.PendingNonceAt(context.Background(), fromAddress)

	gasPrice, err := client.SuggestGasPrice(context.Background())
	if err != nil {
		log.Fatal(err)
	}

	auth, _ := bind.NewKeyedTransactorWithChainID(privateKey, SapphireChainID)
	auth.Nonce = big.NewInt(int64(nonce))
	auth.Value = big.NewInt(1) // in wei
	auth.GasLimit = uint64(0)  // in units
	auth.GasPrice = gasPrice

	if err != nil {
		log.Fatal(err)
	}

	address, tx, _, err := vigil.DeployVigil(auth, client)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(address.Hex())
	fmt.Println(tx.Hash().Hex())

	vigil, err := vigil.NewVigil(address, client)

	if err != nil {
		log.Fatalf("Failed to instantiate Vigil contract: %v", err)
	}

	val := []byte("123")
	transactOpts := client.Transactor(fromAddress)
	transaction, err := vigil.CreateSecret(transactOpts, "age", big.NewInt(5), val)

	if err != nil {
		log.Fatalf("Failed to create secret: %v", err)
	}

	fmt.Println(transaction.Data())

	transaction, err = vigil.RevealSecret(transactOpts, big.NewInt(5))

	if err != nil {
		log.Fatalf("Failed to read secret: %v", err)
	}

	fmt.Println(transaction.Data())
}

TODO

  • Test with go-ethereum tutorial locally
  • Tag post-merge release with probably clients/go/v0.10.0 per steps

@aefhm aefhm self-assigned this Oct 17, 2023
@kostko
Copy link
Member

kostko commented Oct 17, 2023

Task linked: CU-8692vytr5 Bump go-ethereum dependency

2 similar comments
@kostko
Copy link
Member

kostko commented Oct 17, 2023

Task linked: CU-8692vytr5 Bump go-ethereum dependency

@kostko
Copy link
Member

kostko commented Oct 17, 2023

Task linked: CU-8692vytr5 Bump go-ethereum dependency

@aefhm aefhm added p:1 Priority: high dependencies Pull requests that update a dependency file go Pull requests that update Go code labels Oct 17, 2023
@aefhm aefhm force-pushed the CU-8692vytr5_Bump-go-ethereum-dependency_Xi-Zhang branch from 713d3d1 to 40a0a5b Compare October 17, 2023 22:06
@aefhm aefhm marked this pull request as ready for review October 17, 2023 22:06
clients/go/go.mod Outdated Show resolved Hide resolved
clients/go/go.mod Outdated Show resolved Hide resolved
@aefhm aefhm requested a review from CedarMist October 17, 2023 22:10
@CedarMist
Copy link
Member

Seems like you got hit by a mystery bug in one of the CI contracts tests (unrelated to this PR):


  1) Signing
       Secp256k1 (Oasis):

      AssertionError: expected true to equal false
      + expected - actual

      -true
      +false
      
      at testSignThenVerify (test/signing.ts:48:7)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Context.<anonymous> (test/signing.ts:165:9)

@aefhm aefhm force-pushed the CU-8692vytr5_Bump-go-ethereum-dependency_Xi-Zhang branch from 1ff02d5 to 58c34b5 Compare October 18, 2023 22:06
@aefhm aefhm force-pushed the CU-8692vytr5_Bump-go-ethereum-dependency_Xi-Zhang branch from 58c34b5 to 8103e9f Compare October 18, 2023 22:09
@aefhm aefhm force-pushed the CU-8692vytr5_Bump-go-ethereum-dependency_Xi-Zhang branch from 8103e9f to d5697b8 Compare October 18, 2023 22:18
@aefhm aefhm merged commit e2a9f3d into main Oct 18, 2023
16 checks passed
@aefhm aefhm deleted the CU-8692vytr5_Bump-go-ethereum-dependency_Xi-Zhang branch October 18, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file go Pull requests that update Go code p:1 Priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants