From f65307ba96d5fa4dfe58b98297a005d486d670c0 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Fri, 26 Jan 2024 22:57:08 +0000 Subject: [PATCH 1/4] simulators/ethereum/engine: Fix expected error on fcu tests --- .../ethereum/engine/suites/cancun/tests.go | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/simulators/ethereum/engine/suites/cancun/tests.go b/simulators/ethereum/engine/suites/cancun/tests.go index da272edc46..672c9433fb 100644 --- a/simulators/ethereum/engine/suites/cancun/tests.go +++ b/simulators/ethereum/engine/suites/cancun/tests.go @@ -531,7 +531,7 @@ var Tests = []test.Spec{ - Payload Attributes uses Shanghai timestamp - Payload Attributes Beacon Root is null - Verify that client returns INVALID_PARAMS_ERROR. + Verify that client returns INVALID_PAYLOAD_ATTRIBUTES. `, MainFork: config.Cancun, ForkHeight: 2, @@ -541,12 +541,12 @@ var Tests = []test.Spec{ NewPayloads{ FcUOnPayloadRequest: &helper.UpgradeForkchoiceUpdatedVersion{ ForkchoiceUpdatedCustomizer: &helper.BaseForkchoiceUpdatedCustomizer{ - ExpectedError: globals.INVALID_PARAMS_ERROR, + ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES, }, }, ExpectationDescription: fmt.Sprintf(` - ForkchoiceUpdatedV3 before Cancun with any null field must return INVALID_PARAMS_ERROR (code %d) - `, *globals.INVALID_PARAMS_ERROR), + ForkchoiceUpdatedV3 before Cancun with any null field must return INVALID_PAYLOAD_ATTRIBUTES (code %d) + `, *globals.INVALID_PAYLOAD_ATTRIBUTES), }, }, }, @@ -585,13 +585,13 @@ var Tests = []test.Spec{ // ForkchoiceUpdatedV2 before cancun with beacon root &CancunBaseSpec{ BaseSpec: test.BaseSpec{ - Name: "ForkchoiceUpdatedV2 To Request Shanghai Payload, Non-Null Beacon Root ", + Name: "ForkchoiceUpdatedV2 To Request Shanghai Payload, Non-Null Beacon Root", About: ` Test sending ForkchoiceUpdatedV2 to request a Shanghai payload: - Payload Attributes uses Shanghai timestamp - Payload Attributes Beacon Root is non-null - Verify that client returns INVALID_PARAMS_ERROR. + Verify that client returns INVALID_PAYLOAD_ATTRIBUTES. `, MainFork: config.Cancun, ForkHeight: 2, @@ -603,11 +603,11 @@ var Tests = []test.Spec{ PayloadAttributesCustomizer: &helper.BasePayloadAttributesCustomizer{ BeaconRoot: &(common.Hash{}), }, - ExpectedError: globals.INVALID_PARAMS_ERROR, + ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES, }, ExpectationDescription: fmt.Sprintf(` - ForkchoiceUpdatedV2 before Cancun with beacon root field must return INVALID_PARAMS_ERROR (code %d) - `, *globals.INVALID_PARAMS_ERROR), + ForkchoiceUpdatedV2 before Cancun with beacon root field must return INVALID_PAYLOAD_ATTRIBUTES (code %d) + `, *globals.INVALID_PAYLOAD_ATTRIBUTES), }, }, }, @@ -621,7 +621,7 @@ var Tests = []test.Spec{ - Payload Attributes uses Cancun timestamp - Payload Attributes Beacon Root is non-null - Verify that client returns INVALID_PARAMS_ERROR. + Verify that client returns INVALID_PAYLOAD_ATTRIBUTES. `, MainFork: config.Cancun, ForkHeight: 1, @@ -634,12 +634,12 @@ var Tests = []test.Spec{ PayloadAttributesCustomizer: &helper.BasePayloadAttributesCustomizer{ BeaconRoot: &(common.Hash{}), }, - ExpectedError: globals.INVALID_PARAMS_ERROR, + ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES, }, }, ExpectationDescription: fmt.Sprintf(` - ForkchoiceUpdatedV2 after Cancun with beacon root field must return INVALID_PARAMS_ERROR (code %d) - `, *globals.INVALID_PARAMS_ERROR), + ForkchoiceUpdatedV2 after Cancun with beacon root field must return INVALID_PAYLOAD_ATTRIBUTES (code %d) + `, *globals.INVALID_PAYLOAD_ATTRIBUTES), }, }, }, From 320520785088a45749a6f3378f56eb18ce07c682 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Mon, 29 Jan 2024 22:30:42 +0000 Subject: [PATCH 2/4] simulators/ethereum/engine: Get Payload delay at spec level --- simulators/ethereum/engine/test/spec.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simulators/ethereum/engine/test/spec.go b/simulators/ethereum/engine/test/spec.go index bda2dfd4e6..52d6df775d 100644 --- a/simulators/ethereum/engine/test/spec.go +++ b/simulators/ethereum/engine/test/spec.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "math/big" + "time" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/hive/simulators/ethereum/engine/clmock" @@ -60,6 +61,9 @@ type BaseSpec struct { // CL Mocker configuration for time increments BlockTimestampIncrement uint64 + // CL Mocker configuration for payload delay in seconds + GetPayloadDelay uint64 + // CL Mocker configuration for slots to `safe` and `finalized` respectively SlotsToSafe *big.Int SlotsToFinalized *big.Int @@ -109,6 +113,9 @@ func (s BaseSpec) ConfigureCLMock(cl *clmock.CLMocker) { cl.SafeSlotsToImportOptimistically = s.SafeSlotsToImportOptimistically } cl.BlockTimestampIncrement = new(big.Int).SetUint64(s.GetBlockTimeIncrements()) + if s.GetPayloadDelay != 0 { + cl.PayloadProductionClientDelay = time.Duration(s.GetPayloadDelay) * time.Second + } } func (s BaseSpec) GetAbout() string { From 84e09ce46af6c16528dc2b2a7c51087e5bef7e39 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 30 Jan 2024 00:50:26 +0000 Subject: [PATCH 3/4] simulators/ethereum/engine: Correct error code on inconsistent FcU --- simulators/ethereum/engine/suites/engine/forkchoice.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simulators/ethereum/engine/suites/engine/forkchoice.go b/simulators/ethereum/engine/suites/engine/forkchoice.go index 81ef794143..bc90020733 100644 --- a/simulators/ethereum/engine/suites/engine/forkchoice.go +++ b/simulators/ethereum/engine/suites/engine/forkchoice.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/hive/simulators/ethereum/engine/clmock" "github.com/ethereum/hive/simulators/ethereum/engine/config" + "github.com/ethereum/hive/simulators/ethereum/engine/globals" "github.com/ethereum/hive/simulators/ethereum/engine/helper" "github.com/ethereum/hive/simulators/ethereum/engine/test" typ "github.com/ethereum/hive/simulators/ethereum/engine/types" @@ -79,7 +80,7 @@ func (tc InconsistentForkchoiceTest) Execute(t *test.Env) { inconsistentFcU.FinalizedBlockHash = alternativePayloads[len(canonicalPayloads)-3].BlockHash } r := t.TestEngine.TestEngineForkchoiceUpdated(&inconsistentFcU, nil, t.CLMock.LatestPayloadBuilt.Timestamp) - r.ExpectError() + r.ExpectErrorCode(*globals.INVALID_FORKCHOICE_STATE) // Return to the canonical chain r = t.TestEngine.TestEngineForkchoiceUpdated(&t.CLMock.LatestForkchoice, nil, t.CLMock.LatestPayloadBuilt.Timestamp) From 4e8c3fe181475f3b63c71c4192706fbb64b29081 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 30 Jan 2024 01:00:47 +0000 Subject: [PATCH 4/4] simulators/ethereum/engine: Invaild Payload Attributes Expectation Modification --- simulators/ethereum/engine/suites/cancun/tests.go | 2 -- .../ethereum/engine/suites/engine/payload_attributes.go | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/simulators/ethereum/engine/suites/cancun/tests.go b/simulators/ethereum/engine/suites/cancun/tests.go index 672c9433fb..689843d894 100644 --- a/simulators/ethereum/engine/suites/cancun/tests.go +++ b/simulators/ethereum/engine/suites/cancun/tests.go @@ -1813,8 +1813,6 @@ func init() { Customizer: &helper.BasePayloadAttributesCustomizer{ RemoveBeaconRoot: true, }, - // Error is expected on syncing because V3 checks all fields to be present - ErrorOnSync: true, }, } { Tests = append(Tests, t) diff --git a/simulators/ethereum/engine/suites/engine/payload_attributes.go b/simulators/ethereum/engine/suites/engine/payload_attributes.go index 0f246a50ce..91b9cadae4 100644 --- a/simulators/ethereum/engine/suites/engine/payload_attributes.go +++ b/simulators/ethereum/engine/suites/engine/payload_attributes.go @@ -14,7 +14,6 @@ type InvalidPayloadAttributesTest struct { Description string Customizer helper.PayloadAttributesCustomizer Syncing bool - ErrorOnSync bool } func (s InvalidPayloadAttributesTest) WithMainFork(fork config.Fork) test.Spec { @@ -69,12 +68,8 @@ func (tc InvalidPayloadAttributesTest) Execute(t *test.Env) { if tc.Syncing { // If we are SYNCING, the outcome should be SYNCING regardless of the validity of the payload atttributes r := t.TestEngine.TestEngineForkchoiceUpdated(&fcu, attr, t.CLMock.LatestPayloadBuilt.Timestamp) - if tc.ErrorOnSync { - r.ExpectError() - } else { - r.ExpectPayloadStatus(test.Syncing) - r.ExpectPayloadID(nil) - } + r.ExpectPayloadStatus(test.Syncing) + r.ExpectPayloadID(nil) } else { r := t.TestEngine.TestEngineForkchoiceUpdated(&fcu, attr, t.CLMock.LatestPayloadBuilt.Timestamp) r.ExpectError()