From bacbcd932f88f7175ccab1bcca7deef618883d6c Mon Sep 17 00:00:00 2001 From: Yaroslav Kukharuk Date: Wed, 28 Aug 2024 12:35:31 +0200 Subject: [PATCH 1/2] Fix some of the engine api issues --- .../gnosis-engine-jq/client/hive_rpc/hive_rpc.go | 15 ++++++--------- simulators/ethereum/gnosis-engine-jq/main.go | 12 ++++++------ .../ethereum/gnosis-engine-jq/test/expect.go | 6 +++++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/simulators/ethereum/gnosis-engine-jq/client/hive_rpc/hive_rpc.go b/simulators/ethereum/gnosis-engine-jq/client/hive_rpc/hive_rpc.go index 825fec2a41..3c09bda4b7 100644 --- a/simulators/ethereum/gnosis-engine-jq/client/hive_rpc/hive_rpc.go +++ b/simulators/ethereum/gnosis-engine-jq/client/hive_rpc/hive_rpc.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/ethereum/go-ethereum/core" "math/big" "net" "net/http" @@ -12,6 +11,8 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/core" + api "github.com/ethereum/go-ethereum/beacon/engine" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -343,19 +344,15 @@ func (ec *HiveRPCEngineClient) HeaderByNumber(ctx context.Context, number *big.I url, _ := ec.Url() var requestBody string - if number == nil { + var blockNum = toBlockNumArg(number) - requestBody = fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["%v",true],"id":1}`, "latest") - } else { + requestBody = fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["%v",true],"id":1}`, blockNum) - requestBody = fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["%v",true],"id":1}`, number.Int64()) - } - - blockHash, err := getBlockHash(url, requestBody) + byNumber, err := ec.Client.BlockByNumber(ctx, number) if err != nil { return nil, err } - byNumber, err := ec.Client.BlockByNumber(ctx, number) + blockHash, err := getBlockHash(url, requestBody) if err != nil { return nil, err } diff --git a/simulators/ethereum/gnosis-engine-jq/main.go b/simulators/ethereum/gnosis-engine-jq/main.go index 293d47585d..f538c55c56 100644 --- a/simulators/ethereum/gnosis-engine-jq/main.go +++ b/simulators/ethereum/gnosis-engine-jq/main.go @@ -99,7 +99,7 @@ func main() { simulator := hivesim.New() // Mark suites for execution - //hivesim.MustRunSuite(simulator, engine) + hivesim.MustRunSuite(simulator, engine) hivesim.MustRunSuite(simulator, auth) hivesim.MustRunSuite(simulator, excap) // hivesim.MustRunSuite(simulator, syncSuite) @@ -173,6 +173,11 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) { // Load the genesis file specified and dynamically bundle it. genesis := currentTest.GetGenesis() forkConfig := currentTest.GetForkConfig() + if forkConfig == nil { + // Test cannot be configured as is for current fork, skip + fmt.Printf("skipping test \"%s\" because fork configuration is not possible\n", currentTestName) + continue + } cancunTimestamp := new(big.Int).Add(timestamp, big.NewInt(0)) shanghaiTimestamp := new(big.Int).Add(timestamp, big.NewInt(-1000000)) @@ -184,11 +189,6 @@ func makeRunner(tests []test.Spec, nodeType string) func(t *hivesim.T) { forkConfig.ShanghaiTimestamp = shanghaiTimestamp - if forkConfig == nil { - // Test cannot be configured as is for current fork, skip - fmt.Printf("skipping test \"%s\" because fork configuration is not possible\n", currentTestName) - continue - } forkConfig.ConfigGenesis(genesis) genesisStartOption, err := helper.GenesisStartOption(genesis) if err != nil { diff --git a/simulators/ethereum/gnosis-engine-jq/test/expect.go b/simulators/ethereum/gnosis-engine-jq/test/expect.go index e466e3173e..8686d46111 100644 --- a/simulators/ethereum/gnosis-engine-jq/test/expect.go +++ b/simulators/ethereum/gnosis-engine-jq/test/expect.go @@ -804,10 +804,14 @@ func (tec *TestEngineClient) TestHeaderByNumber(number *big.Int) *HeaderResponse ctx, cancel := context.WithTimeout(tec.TestContext, globals.RPCTimeout) defer cancel() header, err := tec.Engine.HeaderByNumber(ctx, number) + var blockHeader *types.Header = nil + if header != nil { + blockHeader = &header.Header + } ret := &HeaderResponseExpectObject{ ExpectEnv: &ExpectEnv{Env: tec.Env}, Call: "HeaderByNumber", - Header: &header.Header, + Header: blockHeader, Error: err, } if err, ok := err.(rpc.Error); ok { From 30ea42c2be1554eaf82231747519b21eaba10152 Mon Sep 17 00:00:00 2001 From: Yaroslav Kukharuk Date: Wed, 28 Aug 2024 12:38:48 +0200 Subject: [PATCH 2/2] disable Invalid Ancestor Re-Org tests --- .../gnosis-engine-jq/suites/engine/tests.go | 82 ++++++++++--------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/simulators/ethereum/gnosis-engine-jq/suites/engine/tests.go b/simulators/ethereum/gnosis-engine-jq/suites/engine/tests.go index ab9c08dc22..ee3ba8dbd7 100644 --- a/simulators/ethereum/gnosis-engine-jq/suites/engine/tests.go +++ b/simulators/ethereum/gnosis-engine-jq/suites/engine/tests.go @@ -252,53 +252,57 @@ func init() { } // Invalid Ancestor Re-Org Tests (Reveal Via Sync) - spec := test.BaseSpec{ - TimeoutSeconds: 60, - SlotsToSafe: big.NewInt(32), - SlotsToFinalized: big.NewInt(64), - } - for _, invalidField := range []helper.InvalidPayloadBlockField{ - helper.InvalidStateRoot, - helper.InvalidReceiptsRoot, - // TODO: helper.InvalidNumber, Test is causing a panic on the secondary node, disabling for now. - helper.InvalidGasLimit, - helper.InvalidGasUsed, - helper.InvalidTimestamp, - // TODO: helper.InvalidPrevRandao, Test consistently fails with Failed to set invalid block: missing trie node. - helper.RemoveTransaction, - helper.InvalidTransactionSignature, - helper.InvalidTransactionNonce, - helper.InvalidTransactionGas, - helper.InvalidTransactionGasPrice, - helper.InvalidTransactionValue, - // helper.InvalidOmmers, Unsupported now - } { - for _, reOrgFromCanonical := range []bool{false, true} { - invalidIndex := 9 - if invalidField == helper.InvalidReceiptsRoot || - invalidField == helper.InvalidGasLimit || - invalidField == helper.InvalidGasUsed || - invalidField == helper.InvalidTimestamp || - invalidField == helper.InvalidPrevRandao { - invalidIndex = 8 - } - if invalidField == helper.InvalidStateRoot { + /* + TODO: Tests are disabled since they rely on a Geth node (running within test process) for P2P communcation and block production. Possible fixes: 1: Somehow re-write the tests to use dockerized node; 2: Wait for Gnosis support for Geth. + + spec := test.BaseSpec{ + TimeoutSeconds: 60, + SlotsToSafe: big.NewInt(32), + SlotsToFinalized: big.NewInt(64), + } + for _, invalidField := range []helper.InvalidPayloadBlockField{ + helper.InvalidStateRoot, + helper.InvalidReceiptsRoot, + // TODO: helper.InvalidNumber, Test is causing a panic on the secondary node, disabling for now. + helper.InvalidGasLimit, + helper.InvalidGasUsed, + helper.InvalidTimestamp, + // TODO: helper.InvalidPrevRandao, Test consistently fails with Failed to set invalid block: missing trie node. + helper.RemoveTransaction, + helper.InvalidTransactionSignature, + helper.InvalidTransactionNonce, + helper.InvalidTransactionGas, + helper.InvalidTransactionGasPrice, + helper.InvalidTransactionValue, + // helper.InvalidOmmers, Unsupported now + } { + for _, reOrgFromCanonical := range []bool{false, true} { + invalidIndex := 9 + if invalidField == helper.InvalidReceiptsRoot || + invalidField == helper.InvalidGasLimit || + invalidField == helper.InvalidGasUsed || + invalidField == helper.InvalidTimestamp || + invalidField == helper.InvalidPrevRandao { + invalidIndex = 8 + } + if invalidField == helper.InvalidStateRoot { + Tests = append(Tests, InvalidMissingAncestorReOrgSyncTest{ + BaseSpec: spec, + InvalidField: invalidField, + ReOrgFromCanonical: reOrgFromCanonical, + EmptyTransactions: true, + InvalidIndex: invalidIndex, + }) + } Tests = append(Tests, InvalidMissingAncestorReOrgSyncTest{ BaseSpec: spec, InvalidField: invalidField, ReOrgFromCanonical: reOrgFromCanonical, - EmptyTransactions: true, InvalidIndex: invalidIndex, }) } - Tests = append(Tests, InvalidMissingAncestorReOrgSyncTest{ - BaseSpec: spec, - InvalidField: invalidField, - ReOrgFromCanonical: reOrgFromCanonical, - InvalidIndex: invalidIndex, - }) } - } + */ // Re-org using the Engine API tests