Skip to content

Commit 39f6752

Browse files
marioevzEikix
authored andcommitted
simulators/ethereum/engine: Fixes for execution-apis#498 (ethereum#974)
* simulators/ethereum/engine: Fix expected error on fcu tests * simulators/ethereum/engine: Get Payload delay at spec level * simulators/ethereum/engine: Correct error code on inconsistent FcU * simulators/ethereum/engine: Invaild Payload Attributes Expectation Modification
1 parent ef43681 commit 39f6752

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

simulators/ethereum/engine/suites/cancun/tests.go

+13-15
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ var Tests = []test.Spec{
531531
- Payload Attributes uses Shanghai timestamp
532532
- Payload Attributes Beacon Root is null
533533
534-
Verify that client returns INVALID_PARAMS_ERROR.
534+
Verify that client returns INVALID_PAYLOAD_ATTRIBUTES.
535535
`,
536536
MainFork: config.Cancun,
537537
ForkHeight: 2,
@@ -541,12 +541,12 @@ var Tests = []test.Spec{
541541
NewPayloads{
542542
FcUOnPayloadRequest: &helper.UpgradeForkchoiceUpdatedVersion{
543543
ForkchoiceUpdatedCustomizer: &helper.BaseForkchoiceUpdatedCustomizer{
544-
ExpectedError: globals.INVALID_PARAMS_ERROR,
544+
ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES,
545545
},
546546
},
547547
ExpectationDescription: fmt.Sprintf(`
548-
ForkchoiceUpdatedV3 before Cancun with any null field must return INVALID_PARAMS_ERROR (code %d)
549-
`, *globals.INVALID_PARAMS_ERROR),
548+
ForkchoiceUpdatedV3 before Cancun with any null field must return INVALID_PAYLOAD_ATTRIBUTES (code %d)
549+
`, *globals.INVALID_PAYLOAD_ATTRIBUTES),
550550
},
551551
},
552552
},
@@ -585,13 +585,13 @@ var Tests = []test.Spec{
585585
// ForkchoiceUpdatedV2 before cancun with beacon root
586586
&CancunBaseSpec{
587587
BaseSpec: test.BaseSpec{
588-
Name: "ForkchoiceUpdatedV2 To Request Shanghai Payload, Non-Null Beacon Root ",
588+
Name: "ForkchoiceUpdatedV2 To Request Shanghai Payload, Non-Null Beacon Root",
589589
About: `
590590
Test sending ForkchoiceUpdatedV2 to request a Shanghai payload:
591591
- Payload Attributes uses Shanghai timestamp
592592
- Payload Attributes Beacon Root is non-null
593593
594-
Verify that client returns INVALID_PARAMS_ERROR.
594+
Verify that client returns INVALID_PAYLOAD_ATTRIBUTES.
595595
`,
596596
MainFork: config.Cancun,
597597
ForkHeight: 2,
@@ -603,11 +603,11 @@ var Tests = []test.Spec{
603603
PayloadAttributesCustomizer: &helper.BasePayloadAttributesCustomizer{
604604
BeaconRoot: &(common.Hash{}),
605605
},
606-
ExpectedError: globals.INVALID_PARAMS_ERROR,
606+
ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES,
607607
},
608608
ExpectationDescription: fmt.Sprintf(`
609-
ForkchoiceUpdatedV2 before Cancun with beacon root field must return INVALID_PARAMS_ERROR (code %d)
610-
`, *globals.INVALID_PARAMS_ERROR),
609+
ForkchoiceUpdatedV2 before Cancun with beacon root field must return INVALID_PAYLOAD_ATTRIBUTES (code %d)
610+
`, *globals.INVALID_PAYLOAD_ATTRIBUTES),
611611
},
612612
},
613613
},
@@ -621,7 +621,7 @@ var Tests = []test.Spec{
621621
- Payload Attributes uses Cancun timestamp
622622
- Payload Attributes Beacon Root is non-null
623623
624-
Verify that client returns INVALID_PARAMS_ERROR.
624+
Verify that client returns INVALID_PAYLOAD_ATTRIBUTES.
625625
`,
626626
MainFork: config.Cancun,
627627
ForkHeight: 1,
@@ -634,12 +634,12 @@ var Tests = []test.Spec{
634634
PayloadAttributesCustomizer: &helper.BasePayloadAttributesCustomizer{
635635
BeaconRoot: &(common.Hash{}),
636636
},
637-
ExpectedError: globals.INVALID_PARAMS_ERROR,
637+
ExpectedError: globals.INVALID_PAYLOAD_ATTRIBUTES,
638638
},
639639
},
640640
ExpectationDescription: fmt.Sprintf(`
641-
ForkchoiceUpdatedV2 after Cancun with beacon root field must return INVALID_PARAMS_ERROR (code %d)
642-
`, *globals.INVALID_PARAMS_ERROR),
641+
ForkchoiceUpdatedV2 after Cancun with beacon root field must return INVALID_PAYLOAD_ATTRIBUTES (code %d)
642+
`, *globals.INVALID_PAYLOAD_ATTRIBUTES),
643643
},
644644
},
645645
},
@@ -1813,8 +1813,6 @@ func init() {
18131813
Customizer: &helper.BasePayloadAttributesCustomizer{
18141814
RemoveBeaconRoot: true,
18151815
},
1816-
// Error is expected on syncing because V3 checks all fields to be present
1817-
ErrorOnSync: true,
18181816
},
18191817
} {
18201818
Tests = append(Tests, t)

simulators/ethereum/engine/suites/engine/forkchoice.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ethereum/go-ethereum/common"
88
"github.com/ethereum/hive/simulators/ethereum/engine/clmock"
99
"github.com/ethereum/hive/simulators/ethereum/engine/config"
10+
"github.com/ethereum/hive/simulators/ethereum/engine/globals"
1011
"github.com/ethereum/hive/simulators/ethereum/engine/helper"
1112
"github.com/ethereum/hive/simulators/ethereum/engine/test"
1213
typ "github.com/ethereum/hive/simulators/ethereum/engine/types"
@@ -79,7 +80,7 @@ func (tc InconsistentForkchoiceTest) Execute(t *test.Env) {
7980
inconsistentFcU.FinalizedBlockHash = alternativePayloads[len(canonicalPayloads)-3].BlockHash
8081
}
8182
r := t.TestEngine.TestEngineForkchoiceUpdated(&inconsistentFcU, nil, t.CLMock.LatestPayloadBuilt.Timestamp)
82-
r.ExpectError()
83+
r.ExpectErrorCode(*globals.INVALID_FORKCHOICE_STATE)
8384

8485
// Return to the canonical chain
8586
r = t.TestEngine.TestEngineForkchoiceUpdated(&t.CLMock.LatestForkchoice, nil, t.CLMock.LatestPayloadBuilt.Timestamp)

simulators/ethereum/engine/suites/engine/payload_attributes.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type InvalidPayloadAttributesTest struct {
1414
Description string
1515
Customizer helper.PayloadAttributesCustomizer
1616
Syncing bool
17-
ErrorOnSync bool
1817
}
1918

2019
func (s InvalidPayloadAttributesTest) WithMainFork(fork config.Fork) test.Spec {
@@ -69,12 +68,8 @@ func (tc InvalidPayloadAttributesTest) Execute(t *test.Env) {
6968
if tc.Syncing {
7069
// If we are SYNCING, the outcome should be SYNCING regardless of the validity of the payload atttributes
7170
r := t.TestEngine.TestEngineForkchoiceUpdated(&fcu, attr, t.CLMock.LatestPayloadBuilt.Timestamp)
72-
if tc.ErrorOnSync {
73-
r.ExpectError()
74-
} else {
75-
r.ExpectPayloadStatus(test.Syncing)
76-
r.ExpectPayloadID(nil)
77-
}
71+
r.ExpectPayloadStatus(test.Syncing)
72+
r.ExpectPayloadID(nil)
7873
} else {
7974
r := t.TestEngine.TestEngineForkchoiceUpdated(&fcu, attr, t.CLMock.LatestPayloadBuilt.Timestamp)
8075
r.ExpectError()

simulators/ethereum/engine/test/spec.go

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"math/big"
7+
"time"
78

89
"github.com/ethereum/go-ethereum/core"
910
"github.com/ethereum/hive/simulators/ethereum/engine/clmock"
@@ -60,6 +61,9 @@ type BaseSpec struct {
6061
// CL Mocker configuration for time increments
6162
BlockTimestampIncrement uint64
6263

64+
// CL Mocker configuration for payload delay in seconds
65+
GetPayloadDelay uint64
66+
6367
// CL Mocker configuration for slots to `safe` and `finalized` respectively
6468
SlotsToSafe *big.Int
6569
SlotsToFinalized *big.Int
@@ -109,6 +113,9 @@ func (s BaseSpec) ConfigureCLMock(cl *clmock.CLMocker) {
109113
cl.SafeSlotsToImportOptimistically = s.SafeSlotsToImportOptimistically
110114
}
111115
cl.BlockTimestampIncrement = new(big.Int).SetUint64(s.GetBlockTimeIncrements())
116+
if s.GetPayloadDelay != 0 {
117+
cl.PayloadProductionClientDelay = time.Duration(s.GetPayloadDelay) * time.Second
118+
}
112119
}
113120

114121
func (s BaseSpec) GetAbout() string {

0 commit comments

Comments
 (0)