-
Notifications
You must be signed in to change notification settings - Fork 644
[MEL] - Create a Functional Replay Binary #3382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a fully functional MEL replay binary, integrating new WAVM I/O bindings, a specialized CLI, and corresponding prover support to track and replay MEL state across a range of blocks.
- Introduces stub (non-WASM) and WASM import bindings for MEL I/O, including a new
GetEndParentChainBlockHash
opcode - Implements
cmd/mel-replay
to walk backward through blocks and extract messages into a final MEL state - Extends the arbitrator prover with a third global-state slot for MEL state root, host I/O support, and updated binary-generation targets
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
wavmio/mel/stub.go | Added non-WASM stub I/O (flags, preimage map) |
wavmio/mel/raw.go | Added WASM imports for MEL stub functions |
wavmio/mel/higher.go | Implemented higher-level wrappers for WASM MEL I/O |
cmd/mel-replay/main.go | New MEL replay CLI and message-extraction loop |
arbitrator/wasm-libraries/host-io/src/lib.rs | Added wavmio__getEndParentChainBlockHash host function |
arbitrator/prover/src/wavm.rs | Introduced GetEndParentChainBlockHash opcode |
arbitrator/prover/src/prepare.rs | Extended global-state byte array length from 2 to 3 |
arbitrator/prover/src/parse_input.rs | Added mel_root and end_parent_chain_block_hash to JSON parsing |
arbitrator/prover/src/main.rs | Added --mel-state-root flag and binary-generation filename flags |
arbitrator/prover/src/machine.rs | Expanded GLOBAL_STATE_BYTES32_NUM to 3; added opcode handler and field |
arbitrator/prover/src/host.rs | Mapped new opcode in the prover host I/O enum |
Makefile | Added targets and variables for MEL replay WASM and machine artifacts |
Comments suppressed due to low confidence (5)
arbitrator/prover/src/parse_input.rs:80
- [nitpick] The JSON field
mel_root
does not match the CLI flag namemel_state_root
. Consider renaming for consistency or documenting the difference clearly.
pub mel_root: Vec<u8>,
cmd/mel-replay/main.go:60
- [nitpick] The error message lacks context about which hash failed. Consider including the
startMelRoot
or the hash value in the formatted error to aid debugging.
panic(fmt.Errorf("error resolving preimage: %w", err))
wavmio/mel/stub.go:64
- [nitpick] The error does not include the missing hash, which makes troubleshooting harder. You could wrap the hash in the error, e.g.,
fmt.Errorf("preimage not found for %s", hash.Hex())
.
return []byte{}, errors.New("preimage not found")
wavmio/mel/higher.go:22
- The
readBuffer
helper contains nontrivial logic for dynamically resizing and reading chunks; consider adding unit tests to validate its behavior across boundary conditions.
func readBuffer(f func(uint32, unsafe.Pointer) uint32) []byte {
arbitrator/prover/src/main.rs:72
- [nitpick] The new CLI flag
--mel-state-root
lacks a help description. Add a doc comment (e.g.,/// Hex-encoded initial MEL state root
) to clarify its purpose.
#[structopt(long)]
Investigating why CI fails |
…into raul/mel-replay-wasm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial
setGlobalStateBytes32(IDX_MEL_ROOT, hashUnsafe) | ||
} | ||
|
||
func ResolveTypedPreimage(ty arbutil.PreimageType, hash common.Hash) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you not use the existing wavmio functions for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because of the stub functions, which will read some flags and load into an in-memory map when run natively
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3382 +/- ##
==========================================
+ Coverage 22.67% 22.71% +0.03%
==========================================
Files 383 383
Lines 58109 58111 +2
==========================================
+ Hits 13177 13198 +21
+ Misses 42903 42885 -18
+ Partials 2029 2028 -1 🚀 New features to boost your workflow:
|
This PR creates a functional replay binary for MEL (the message extraction layer) of Arbitrum nodes. Here's how it works:
ExtractMessages
function which will produce a new MEL stateMELStateRoot
in wavmio of the machine executing the MEL replay binary at the endOther changes
MELStateRoot
to its global state. We do not modify thehash()
orserialize()
methods in order to not break existing code. This will require an arbos upgrade once we touch those two methodsGetEndParentChainBlockHash
which gets us the ending block hash of a MEL machine execution--until-hostio-bin-filename="mel-until-host-io-state.bin" --brotli-wavm-machine-filename="mel_machine.wavm.br" --module-root-filename="mel_module_root.txt"
which have defaults for the existing replay binary but can be changed when generating a MEL replay binaryTesting
In a following PR, we will introduce a testing utility that can run this MEL replay binary for verification and include automated tests. Adding that to this PR would increase the code diff significantly and also requires more changes from #3174 before it works perfectly
Submodule Updates
This PR also updates to Bold's
main
branch, which includes a change to a global state struct within it to include the MELRootResolves NIT-3320