EVM fix - issue #5077 (#5233)

* fix(evm): output and add makefile command

* fix(evm): correct number type conversion
This commit is contained in:
Max Revitt 2022-08-31 01:51:08 +01:00 committed by GitHub
parent 002aba4686
commit 159e53d503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -111,6 +111,7 @@ COMMANDS += rpctest
COMMANDS += sentry COMMANDS += sentry
COMMANDS += state COMMANDS += state
COMMANDS += txpool COMMANDS += txpool
COMMANDS += evm
# build each command using %.cmd rule # build each command using %.cmd rule
$(COMMANDS): %: %.cmd $(COMMANDS): %: %.cmd

View File

@ -30,7 +30,7 @@ import (
"github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/tests" "github.com/ledgerwatch/erigon/tests"
"github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/erigon/turbo/trie"
"github.com/ledgerwatch/log/v3" log "github.com/ledgerwatch/log/v3"
"github.com/urfave/cli" "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 // Iterate over all the stateTests, run them and aggregate the results
results := make([]StatetestResult, 0, len(stateTests)) results, err := aggregateResultsFromStateTests(ctx, stateTests, tracer, debugger)
if err := aggregateResultsFromStateTests(ctx, stateTests, results, tracer, debugger); err != nil { if err != nil {
return err return err
} }
@ -106,24 +106,23 @@ func stateTestCmd(ctx *cli.Context) error {
func aggregateResultsFromStateTests( func aggregateResultsFromStateTests(
ctx *cli.Context, ctx *cli.Context,
stateTests map[string]tests.StateTest, stateTests map[string]tests.StateTest,
results []StatetestResult,
tracer vm.Tracer, tracer vm.Tracer,
debugger *vm.StructLogger, debugger *vm.StructLogger,
) error { ) ([]StatetestResult, error) {
// Iterate over all the stateTests, run them and aggregate the results // Iterate over all the stateTests, run them and aggregate the results
cfg := vm.Config{ cfg := vm.Config{
Tracer: tracer, Tracer: tracer,
Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name), Debug: ctx.GlobalBool(DebugFlag.Name) || ctx.GlobalBool(MachineFlag.Name),
} }
db := memdb.New() db := memdb.New()
defer db.Close() defer db.Close()
tx, txErr := db.BeginRw(context.Background()) tx, txErr := db.BeginRw(context.Background())
if txErr != nil { if txErr != nil {
return txErr return nil, txErr
} }
defer tx.Rollback() defer tx.Rollback()
results := make([]StatetestResult, 0, len(stateTests))
for key, test := range stateTests { for key, test := range stateTests {
for _, st := range test.Subtests() { for _, st := range test.Subtests() {
@ -180,5 +179,5 @@ func aggregateResultsFromStateTests(
} }
} }
} }
return nil return results, nil
} }

View File

@ -449,6 +449,7 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co
gpi := big.Int(*gasPrice) gpi := big.Int(*gasPrice)
gasPriceInt := uint256.NewInt(gpi.Uint64()) gasPriceInt := uint256.NewInt(gpi.Uint64())
// TODO the conversion to int64 then uint64 then new int isn't working!
msg := types.NewMessage( msg := types.NewMessage(
from, from,
to, to,
@ -456,8 +457,8 @@ func toMessage(tx stTransactionMarshaling, ps stPostState, baseFee *big.Int) (co
value, value,
uint64(gasLimit), uint64(gasLimit),
gasPriceInt, gasPriceInt,
uint256.NewInt(uint64(feeCap.Int64())), uint256.NewInt(feeCap.Uint64()),
uint256.NewInt(uint64(tipCap.Int64())), uint256.NewInt(tipCap.Uint64()),
data, data,
accessList, accessList,
false) false)