From 42d159fb9a8d5d6db77642de960f69b9678c4879 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Sun, 24 Nov 2024 22:32:11 +0700 Subject: [PATCH] fix contract --- accounts/abi/bind/base.go | 7 ++++++- .../abi/bind/testdata/v2_testcase_library/contract.sol | 4 ---- accounts/abi/bind/v2/lib.go | 1 + accounts/abi/bind/v2/v2_test.go | 9 ++++----- core/vm/interpreter.go | 1 + 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index bb7301e965..4d16d675ff 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -401,7 +401,12 @@ func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Ad Value: value, Data: input, } - return c.transactor.EstimateGas(ensureContext(opts.Context), msg) + res, err := c.transactor.EstimateGas(ensureContext(opts.Context), msg) + if err != nil { + fmt.Printf("msg data is %x\n", msg.Data) + panic(err) + } + return res, nil } func (c *BoundContract) getNonce(opts *TransactOpts) (uint64, error) { diff --git a/accounts/abi/bind/testdata/v2_testcase_library/contract.sol b/accounts/abi/bind/testdata/v2_testcase_library/contract.sol index 399f5c41cd..6eca029fdd 100644 --- a/accounts/abi/bind/testdata/v2_testcase_library/contract.sol +++ b/accounts/abi/bind/testdata/v2_testcase_library/contract.sol @@ -37,8 +37,4 @@ contract TestArray { assert(arr[0] == 0); assert(arr[1] == 2); } - - constructor(uint256 foobar) { - - } } diff --git a/accounts/abi/bind/v2/lib.go b/accounts/abi/bind/v2/lib.go index 47555da378..288f0bcce5 100644 --- a/accounts/abi/bind/v2/lib.go +++ b/accounts/abi/bind/v2/lib.go @@ -23,6 +23,7 @@ func deployContract(backend bind.ContractBackend, auth *bind.TransactOpts, const if err != nil { return nil, common.Address{}, fmt.Errorf("contract bytecode is not a hex string: %s", contractBinBytes[2:]) } + fmt.Println("before DeployContractRaw") addr, tx, _, err := bind.DeployContractRaw(auth, contractBinBytes, backend, constructor) if err != nil { return nil, common.Address{}, fmt.Errorf("failed to deploy contract: %v", err) diff --git a/accounts/abi/bind/v2/v2_test.go b/accounts/abi/bind/v2/v2_test.go index f756f38411..245800a9ef 100644 --- a/accounts/abi/bind/v2/v2_test.go +++ b/accounts/abi/bind/v2/v2_test.go @@ -3,7 +3,6 @@ package v2 import ( "context" "encoding/json" - "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_generated_testcase" "github.com/ethereum/go-ethereum/accounts/abi/bind/testdata/v2_testcase_library" @@ -163,20 +162,20 @@ func TestDeployment(t *testing.T) { log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelDebug, true))) - // TODO: add public interface for deploy library, deploy contract (or make them same method?) - // want to allow more flexibility. - + // TODO: allow for the flexibility of deploying only libraries. // also, i kind of hate this conversion. But the API of LinkAndDeployContractWithOverrides feels cleaner this way... idk. libMetas := make(map[string]*bind.MetaData) for pattern, metadata := range v2_testcase_library.TestArrayLibraryDeps { libMetas[pattern] = metadata } + + // TODO: test case with arguments-containing constructor txs, _, err := LinkAndDeployContractWithOverrides(&opts, bindBackend, []byte{}, v2_testcase_library.TestArrayMetaData, v2_testcase_library.TestArrayLibraryDeps, nil) if err != nil { t.Fatalf("err: %+v\n", err) } + bindBackend.Commit() for _, tx := range txs { - fmt.Println("waiting for deployment") _, err = bind.WaitDeployed(context.Background(), &bindBackend, tx) if err != nil { t.Fatalf("error deploying bound contract: %+v", err) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 996ed6e56a..350b3f30fb 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -243,6 +243,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // Get the operation from the jump table and validate the stack to ensure there are // enough stack items available to perform the operation. op = contract.GetOp(pc) + fmt.Printf("op name is: %s\n", op.String()) operation := in.table[op] cost = operation.constantGas // For tracing // Validate stack