Skip to content

Commit 768db34

Browse files
committed
test with pr-266
1 parent 81c347e commit 768db34

3 files changed

Lines changed: 65 additions & 13 deletions

File tree

execution/evm/engine_payload.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,36 @@ func (e *EnginePayloadEnvelope) UnmarshalJSON(input []byte) error {
4545
return errors.New("missing required field 'executionPayload' for EnginePayloadEnvelope")
4646
}
4747

48-
var payload engine.ExecutableData
49-
if err := json.Unmarshal(dec.ExecutionPayload, &payload); err != nil {
50-
return err
51-
}
5248
var amsterdamProbe struct {
5349
SlotNumber json.RawMessage `json:"slotNumber"`
5450
BlockAccessList json.RawMessage `json:"blockAccessList"`
5551
}
5652
if err := json.Unmarshal(dec.ExecutionPayload, &amsterdamProbe); err != nil {
5753
return err
5854
}
55+
56+
// Execution clients disagree on the blockAccessList JSON schema (reth
57+
// encodes the raw access-list bytes as a hex string, go-ethereum uses
58+
// structured objects). Strip the field before the typed decode so either
59+
// shape is accepted; RawExecutionPayload keeps it for passthrough.
60+
typedPayload := dec.ExecutionPayload
61+
if amsterdamProbe.BlockAccessList != nil {
62+
var fields map[string]json.RawMessage
63+
if err := json.Unmarshal(dec.ExecutionPayload, &fields); err != nil {
64+
return err
65+
}
66+
delete(fields, "blockAccessList")
67+
sanitized, err := json.Marshal(fields)
68+
if err != nil {
69+
return err
70+
}
71+
typedPayload = sanitized
72+
}
73+
74+
var payload engine.ExecutableData
75+
if err := json.Unmarshal(typedPayload, &payload); err != nil {
76+
return err
77+
}
5978
e.ExecutionPayload = &payload
6079
e.RawExecutionPayload = append(e.RawExecutionPayload[:0], dec.ExecutionPayload...)
6180
e.rawHasAmsterdamFields = amsterdamProbe.SlotNumber != nil || amsterdamProbe.BlockAccessList != nil

execution/evm/engine_rpc_client_test.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ const (
104104
zeroHashHex = "0x0000000000000000000000000000000000000000000000000000000000000000"
105105
)
106106

107-
// minimalBlockAccessListJSON is a spec-shaped (EIP-7928) block access list with
108-
// a single account entry, as returned by engine_getPayloadV6.
109-
const minimalBlockAccessListJSON = `[{"address": "0x00000000000000000000000000000000000000aa"}]`
107+
// minimalBlockAccessListJSON matches ev-reth's wire encoding of
108+
// executionPayload.blockAccessList in engine_getPayloadV6 responses: the
109+
// encoded access list as a hex string. go-ethereum instead models the field as
110+
// structured JSON objects; ev-node must accept either shape and pass it
111+
// through unchanged (see TestEnginePayloadEnvelope_StructuredBlockAccessList).
112+
const minimalBlockAccessListJSON = `"0x1234"`
110113

111114
func minimalAmsterdamPayloadEnvelopeJSON(t *testing.T) string {
112115
t.Helper()
@@ -528,6 +531,28 @@ func TestNewPayload_NilExecutionRequests_EncodedAsEmptyArray(t *testing.T) {
528531
require.NoError(t, err)
529532
}
530533

534+
func TestEnginePayloadEnvelope_StructuredBlockAccessList(t *testing.T) {
535+
structured := strings.Replace(
536+
minimalAmsterdamPayloadEnvelopeJSON(t),
537+
`"blockAccessList": `+minimalBlockAccessListJSON,
538+
`"blockAccessList": [{"address": "0x00000000000000000000000000000000000000aa"}]`,
539+
1,
540+
)
541+
542+
var envelope EnginePayloadEnvelope
543+
require.NoError(t, json.Unmarshal([]byte(structured), &envelope))
544+
require.True(t, envelope.hasAmsterdamFields())
545+
546+
payload, err := envelope.executionPayloadParam()
547+
require.NoError(t, err)
548+
raw, ok := payload.(json.RawMessage)
549+
require.True(t, ok)
550+
551+
var fields map[string]json.RawMessage
552+
require.NoError(t, json.Unmarshal(raw, &fields))
553+
require.JSONEq(t, `[{"address": "0x00000000000000000000000000000000000000aa"}]`, string(fields["blockAccessList"]))
554+
}
555+
531556
func TestEnginePayloadEnvelope_MarshalJSON_UsesWireFieldNames(t *testing.T) {
532557
var envelope EnginePayloadEnvelope
533558
require.NoError(t, json.Unmarshal([]byte(minimalAmsterdamPayloadEnvelopeJSON(t)), &envelope))

execution/evm/test/engine_fork_upgrade_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ const (
3333
forkCyclePragueTimestamp = uint64(12)
3434
forkCycleOsakaTimestamp = uint64(24)
3535
forkCycleAmsterdamTimestamp = uint64(36)
36+
37+
// defaultEvRethForkTag pins the ev-reth image built from
38+
// https://github.com/evstack/ev-reth/pull/266 (reth 2.3), the first build
39+
// with Amsterdam Engine API support. Replace with a release tag once that
40+
// PR ships. EV_RETH_IMAGE_REPO/EV_RETH_TAG override this.
41+
defaultEvRethForkTag = "pr-266"
3642
)
3743

3844
// TestEngineAPIForkUpgradeCycleE2E drives ev-node's EngineClient against a real
@@ -41,8 +47,9 @@ const (
4147
// ev-node, so this verifies the V4 -> V5 -> V6 upgrade path instead of only
4248
// asserting that blocks are produced.
4349
//
44-
// The existing Tastora ev-reth image is used by default. Set EV_RETH_TAG, or set
45-
// EV_RETH_IMAGE_REPO with optional EV_RETH_TAG, to point at a local or registry image.
50+
// The ghcr.io/evstack/ev-reth image tagged defaultEvRethForkTag is used by
51+
// default. Set EV_RETH_TAG, or set EV_RETH_IMAGE_REPO with optional EV_RETH_TAG,
52+
// to point at a local or registry image.
4653
func TestEngineAPIForkUpgradeCycleE2E(t *testing.T) {
4754
if testing.Short() {
4855
t.Skip("skipping due to short mode")
@@ -136,11 +143,12 @@ func withEngineForkTimes(t testing.TB, osakaTime, amsterdamTime uint64) reth.Gen
136143
func rethImageOptFromEnv() RethNodeOpt {
137144
repo := strings.TrimSpace(os.Getenv("EV_RETH_IMAGE_REPO"))
138145
tag := strings.TrimSpace(os.Getenv("EV_RETH_TAG"))
139-
if repo == "" && tag == "" {
140-
return nil
141-
}
142146
if tag == "" {
143-
tag = "latest"
147+
if repo == "" {
148+
tag = defaultEvRethForkTag
149+
} else {
150+
tag = "latest"
151+
}
144152
}
145153
return func(b *reth.NodeBuilder) {
146154
if repo != "" {

0 commit comments

Comments
 (0)