Skip to content

Commit c29160c

Browse files
committed
Merge remote-tracking branch 'origin/master' into wasmer7
2 parents 61062ad + 7b2327c commit c29160c

File tree

86 files changed

+2371
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2371
-564
lines changed

.github/workflows/_detect-changes.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ jobs:
4040
- 'crates/**'
4141
- 'contracts/**'
4242
- 'Makefile'
43+
- '**.toml'
44+
- '**/Cargo.lock'
4345
- '.github/workflows/_rust-tests.yml'
46+
- '.github/workflows/_detect-changes.yml'
4447
bold_legacy:
4548
- 'bold/legacy/**'
4649
- '.github/workflows/_bold-legacy.yml'

.github/workflows/_validation-tests.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,33 @@ jobs:
6868
fi
6969
7070
# 3. Send 2 validation requests
71-
RESPONSE1=$(curl -s -X POST http://localhost:4141/validation_validate \
72-
-H "Content-Type: application/json" \
73-
-d @${{ env.INPUT_FILE }})
71+
RESPONSE1=$(jq -n --slurpfile input ${{ env.INPUT_FILE }} \
72+
'{jsonrpc: "2.0", id: 1, method: "validation_validate", params: [$input[0]]}' | \
73+
curl -s -X POST http://localhost:4141/validation_validate \
74+
-H "Content-Type: application/json" -d @-)
7475
75-
RESPONSE2=$(curl -s -X POST http://localhost:4141/validation_validate \
76-
-H "Content-Type: application/json" \
77-
-d @${{ env.INPUT_FILE }})
76+
RESPONSE2=$(jq -n --slurpfile input ${{ env.INPUT_FILE }} \
77+
'{jsonrpc: "2.0", id: 2, method: "validation_validate", params: [$input[0]]}' | \
78+
curl -s -X POST http://localhost:4141/validation_validate \
79+
-H "Content-Type: application/json" -d @-)
7880
7981
# 4. Stop the server
8082
kill $SERVER_PID
8183
wait $SERVER_PID 2>/dev/null || true
8284
83-
# 5. Compare hashes
84-
SERVER_HASH1=$(echo "$RESPONSE1" | jq -r '.BlockHash')
85-
SERVER_HASH2=$(echo "$RESPONSE2" | jq -r '.BlockHash')
86-
85+
# 5. Verify JSON-RPC response IDs match request IDs
86+
RESP_ID1=$(echo "$RESPONSE1" | jq -r '.id')
87+
RESP_ID2=$(echo "$RESPONSE2" | jq -r '.id')
88+
89+
if [ "$RESP_ID1" != "1" ] || [ "$RESP_ID2" != "2" ]; then
90+
echo "❌ $MODE_NAME JSON-RPC response ID mismatch: expected 1 and 2, got $RESP_ID1 and $RESP_ID2"
91+
exit 1
92+
fi
93+
94+
# 6. Compare hashes
95+
SERVER_HASH1=$(echo "$RESPONSE1" | jq -r '.result.BlockHash')
96+
SERVER_HASH2=$(echo "$RESPONSE2" | jq -r '.result.BlockHash')
97+
8798
echo "JIT Hash: $JIT_HASH"
8899
echo "Server response 1 Hash: $SERVER_HASH1"
89100
echo "Server response 2 Hash: $SERVER_HASH2"

Cargo.lock

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ sha2 = { version = "0.10.9" }
8282
sha3 = { version = "0.10.8" }
8383
siphasher = { version = "0.3.10" }
8484
smallvec = { version = "1.10.0" }
85+
spin = { version = "0.10.0" }
8586
static_assertions = { version = "1.1.0" }
8687
structopt = { version = "0.3.26" }
88+
tempdir = { version = "0.3.7" }
8789
thiserror = { version = "1.0.33" }
8890
tiny-keccak = { version = "2.0.2" }
8991
tokio = { version = "1.48.0" }

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ COPY ./scripts/download-machine.sh .
205205
#RUN ./download-machine.sh consensus-v50-rc.5 0xb90895a56a59c0267c2004a0e103ad725bd98d5a05c3262806ab4ccb3f997558
206206
#RUN ./download-machine.sh consensus-v50-rc.6 0x2c54f6e9e378ba320ed9c713a1d9f067a572b1437e4f1c40b1a915d3066c04f2
207207
#RUN ./download-machine.sh consensus-v40 0xdb698a2576298f25448bc092e52cf13b1e24141c997135d70f217d674bbeb69a
208+
RUN ./download-machine.sh consensus-v60-alpha.1 0xe237db4636ba7878fb1d6998f40fa155260a26484f81db732f9aa7dc1b684bf7
208209
RUN ./download-machine.sh consensus-v50 0x2c54f6e9e378ba320ed9c713a1d9f067a572b1437e4f1c40b1a915d3066c04f2
209210
RUN ./download-machine.sh consensus-v51 0x8a7513bf7bb3e3db04b0d982d0e973bcf57bf8b88aef7c6d03dba3a81a56a499
211+
RUN ./download-machine.sh consensus-v51.1 0xc2c02df561d4afaf9a1d6785f70098ec3874765c638e3cb6dbe8d3c83333e14c
210212

211213
FROM golang:1.25-bookworm AS node-builder
212214
WORKDIR /workspace

arbnode/inbox_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func NewTransactionStreamerForTest(t *testing.T, ctx context.Context, ownerAddre
135135
initReader := statetransfer.NewMemoryInitDataReader(&initData)
136136

137137
options := core.DefaultConfig().WithStateScheme(env.GetTestStateScheme())
138-
bc, err := gethexec.WriteOrTestBlockChain(executionDB, options, initReader, chainConfig, nil, nil, arbostypes.TestInitMessage, &gethexec.ConfigDefault.TxIndexer, 0)
138+
bc, err := gethexec.WriteOrTestBlockChain(executionDB, options, initReader, chainConfig, nil, nil, arbostypes.TestInitMessage, &gethexec.ConfigDefault.TxIndexer, 0, false)
139139

140140
if err != nil {
141141
Fail(t, err)

arbnode/mel/extraction/message_extraction_function.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func extractMessagesImpl(
142142
if err != nil {
143143
return nil, nil, nil, nil, err
144144
}
145-
// Update the delayed message accumulator in the MEL state.
145+
// Extract batch posting reports from delayed messages
146146
batchPostingReports := make([]*mel.DelayedInboxMessage, 0)
147147
for _, delayed := range delayedMessages {
148148
// If this message is a batch posting report, we save it for later
@@ -151,16 +151,6 @@ func extractMessagesImpl(
151151
if delayed.Message.Header.Kind == arbostypes.L1MessageType_BatchPostingReport || delayed.Message.Header.Kind == arbostypes.L1MessageType_Initialize { // Let's consider the init message as a batch posting report, since it is seen as a batch as well, we can later ignore filling its batchGasCost anyway
152152
batchPostingReports = append(batchPostingReports, delayed)
153153
}
154-
if err = state.AccumulateDelayedMessage(delayed); err != nil {
155-
return nil, nil, nil, nil, err
156-
}
157-
state.DelayedMessagesSeen += 1
158-
}
159-
if len(delayedMessages) > 0 {
160-
// Only need to calculate partials once, after all the delayed messages are `seen`
161-
if err := state.GenerateDelayedMessagesSeenMerklePartialsAndRoot(); err != nil {
162-
return nil, nil, nil, nil, err
163-
}
164154
}
165155

166156
// Batch posting reports are included in the same transaction as a batch, so there should
@@ -175,6 +165,7 @@ func extractMessagesImpl(
175165

176166
var batchMetas []*mel.BatchMetadata
177167
var messages []*arbostypes.MessageWithMetadata
168+
var serializedBatches [][]byte
178169
for i, batch := range batches {
179170
batchTx := batchTxs[i]
180171
serialized, err := serialize(
@@ -209,7 +200,26 @@ func extractMessagesImpl(
209200
} else if !(inputState.DelayedMessagesSeen == 0 && i == 0 && delayedMessages[i] == batchPostReport) {
210201
return nil, nil, nil, nil, errors.New("encountered initialize message that is not the first delayed message and the first batch ")
211202
}
203+
serializedBatches = append(serializedBatches, serialized)
204+
}
212205

206+
// Update the delayed message accumulator in the MEL state.
207+
for _, delayed := range delayedMessages {
208+
if err = state.AccumulateDelayedMessage(delayed); err != nil {
209+
return nil, nil, nil, nil, err
210+
}
211+
state.DelayedMessagesSeen += 1
212+
}
213+
if len(delayedMessages) > 0 {
214+
// Only need to calculate partials once, after all the delayed messages are `seen`
215+
if err := state.GenerateDelayedMessagesSeenMerklePartialsAndRoot(); err != nil {
216+
return nil, nil, nil, nil, err
217+
}
218+
}
219+
220+
// Extract L2 messages from batches
221+
for i, batch := range batches {
222+
serialized := serializedBatches[i]
213223
rawSequencerMsg, err := parseSequencerMessage(
214224
ctx,
215225
batch.SequenceNumber,

arbnode/mel/messages.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,13 @@ func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash {
5959
}
6060

6161
func (m *DelayedInboxMessage) Hash() common.Hash {
62-
encoded, err := rlp.EncodeToBytes(m.WithOnlyMELConsensusFields())
62+
encoded, err := rlp.EncodeToBytes(m)
6363
if err != nil {
6464
panic(err)
6565
}
6666
return crypto.Keccak256Hash(encoded)
6767
}
6868

69-
// WithOnlyMELConsensusFields returns a shallow copy of the DelayedInboxMessage with
70-
// only the fields relevant to MEL consensus being present
71-
func (m *DelayedInboxMessage) WithOnlyMELConsensusFields() *DelayedInboxMessage {
72-
return &DelayedInboxMessage{
73-
BlockHash: m.BlockHash,
74-
Message: &arbostypes.L1IncomingMessage{
75-
Header: m.Message.Header,
76-
L2msg: m.Message.L2msg,
77-
},
78-
ParentChainBlockNumber: m.ParentChainBlockNumber,
79-
}
80-
}
81-
8269
type BatchMetadata struct {
8370
Accumulator common.Hash
8471
MessageCount arbutil.MessageIndex

arbnode/mel/recording/delayed_msg_database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (r *DelayedMsgDatabase) ReadDelayedMessage(ctx context.Context, state *mel.
6666
if err != nil {
6767
return nil, err
6868
}
69-
delayedMsgBytes, err := rlp.EncodeToBytes(delayed.WithOnlyMELConsensusFields())
69+
delayedMsgBytes, err := rlp.EncodeToBytes(delayed)
7070
if err != nil {
7171
return nil, err
7272
}

arbnode/mel/runner/fsm.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ type backToStart struct{}
4747

4848
// An action that transitions the FSM to the processing next block state.
4949
type processNextBlock struct {
50-
melState *mel.State
50+
melState *mel.State
51+
prevStepWasReorg bool // Helps prevent unnecessary continuous rewinding of MEL validator when we detect L1 reorg
5152
}
5253

5354
// An action that transitions the FSM to the saving messages state.
@@ -56,10 +57,13 @@ type saveMessages struct {
5657
postState *mel.State
5758
messages []*arbostypes.MessageWithMetadata
5859
delayedMessages []*mel.DelayedInboxMessage
60+
batchMetas []*mel.BatchMetadata
5961
}
6062

6163
// An action that transitions the FSM to the reorging state.
62-
type reorgToOldBlock struct{}
64+
type reorgToOldBlock struct {
65+
melState *mel.State
66+
}
6367

6468
func (backToStart) String() string {
6569
return "back_to_start"

0 commit comments

Comments
 (0)