From 159e53d503165a0ccdb4c7e64b280446b1faaf54 Mon Sep 17 00:00:00 2001 From: Max Revitt Date: Wed, 31 Aug 2022 01:51:08 +0100 Subject: [PATCH] EVM fix - issue #5077 (#5233) * fix(evm): output and add makefile command * fix(evm): correct number type conversion --- Makefile | 1 + cmd/evm/staterunner.go | 15 +++++++-------- tests/state_test_util.go | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 776346959..8ec17340f 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,7 @@ COMMANDS += rpctest COMMANDS += sentry COMMANDS += state COMMANDS += txpool +COMMANDS += evm # build each command using %.cmd rule $(COMMANDS): %: %.cmd diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go index 6abaa8882..d10553504 100644 --- a/cmd/evm/staterunner.go +++ b/cmd/evm/staterunner.go @@ -30,7 +30,7 @@ import ( "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/tests" "github.com/ledgerwatch/erigon/turbo/trie" - "github.com/ledgerwatch/log/v3" + log "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) @@ -93,8 +93,8 @@ func stateTestCmd(ctx *cli.Context) error { } // Iterate over all the stateTests, run them and aggregate the results - results := make([]StatetestResult, 0, len(stateTests)) - if err := aggregateResultsFromStateTests(ctx, stateTests, results, tracer, debugger); err != nil { + results, err := aggregateResultsFromStateTests(ctx, stateTests, tracer, debugger) + if err != nil { return err } @@ -106,24 +106,23 @@ func stateTestCmd(ctx *cli.Context) error { func aggregateResultsFromStateTests( ctx *cli.Context, stateTests map[string]tests.StateTest, - results []StatetestResult, tracer vm.Tracer, debugger *vm.StructLogger, -) error { +) ([]StatetestResult, error) { // Iterate over all the stateTests, run them and aggregate the results cfg := vm.Config{ Tracer: tracer, Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name), } - db := memdb.New() defer db.Close() tx, txErr := db.BeginRw(context.Background()) if txErr != nil { - return txErr + return nil, txErr } defer tx.Rollback() + results := make([]StatetestResult, 0, len(stateTests)) for key, test := range stateTests { for _, st := range test.Subtests() { @@ -180,5 +179,5 @@ func aggregateResultsFromStateTests( } } } - return nil + return results, nil } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 0fcbcd9f2..4092a5115 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -449,6 +449,7 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co gpi := big.Int(*gasPrice) gasPriceInt := uint256.NewInt(gpi.Uint64()) + // TODO the conversion to int64 then uint64 then new int isn't working! msg := types.NewMessage( from, to, @@ -456,8 +457,8 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co value, uint64(gasLimit), gasPriceInt, - uint256.NewInt(uint64(feeCap.Int64())), - uint256.NewInt(uint64(tipCap.Int64())), + uint256.NewInt(feeCap.Uint64()), + uint256.NewInt(tipCap.Uint64()), data, accessList, false)