-
Notifications
You must be signed in to change notification settings - Fork 718
[MEL] - Implement a Unified Replay Binary for MEL #4553
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
Open
rauljordan
wants to merge
18
commits into
master
Choose a base branch
from
raul/mel-unified-binary
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+981
−45
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4f004d6
add unified replay logic
rauljordan 9efa99c
read chain config
rauljordan 46b6444
add in changes to prover
rauljordan bd2a202
Merge branch 'master' into raul/mel-unified-binary
rauljordan 781d531
add cl
rauljordan 932bfd6
Merge branch 'raul/mel-unified-binary' of github.com:OffchainLabs/nit…
rauljordan dad4c47
Merge branch 'master' into raul/mel-unified-binary
rauljordan 8c9bed4
Merge branch 'master' into raul/mel-unified-binary
rauljordan 80e9ca4
Merge branch 'master' into raul/mel-unified-binary
rauljordan c226952
comment
rauljordan d82ca66
Merge branch 'raul/mel-unified-binary' of github.com:OffchainLabs/nit…
rauljordan 350a6d6
fix flakey test
rauljordan 3283fc6
fix conflicts
rauljordan 9d697da
comment
rauljordan 5ce753a
Merge branch 'master' into raul/mel-unified-binary
rauljordan 7ba19b9
edit
rauljordan 07abafc
Merge branch 'raul/mel-unified-binary' of github.com:OffchainLabs/nit…
rauljordan 371044f
edits
rauljordan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ### Added | ||
| - Unified replay binary (`cmd/unified-replay/`) combining MEL message extraction and block production into a single WASM-compilable program | ||
| - `GetEndParentChainBlockHash` host I/O opcode for MEL proving | ||
| - `melwavmio` package providing WASM imports and native stubs for MEL | ||
| - Extended `GlobalState` to 4 bytes32 slots with backward-compatible hashing | ||
| - Makefile targets `build-unified-replay-env` and `build-unified-wasm-bin` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Copyright 2021-2026, Offchain Labs, Inc. | ||
| // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "encoding/hex" | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "github.com/ethereum/go-ethereum/core/rawdb" | ||
| "github.com/ethereum/go-ethereum/ethdb" | ||
|
|
||
| "github.com/offchainlabs/nitro/arbutil" | ||
| "github.com/offchainlabs/nitro/melwavmio" | ||
| ) | ||
|
|
||
| type PreimageDb struct{} | ||
|
|
||
| func (db PreimageDb) Has(key []byte) (bool, error) { | ||
| if len(key) != 32 { | ||
| return false, nil | ||
| } | ||
| return false, errors.New("preimage DB doesn't support Has") | ||
| } | ||
|
|
||
| func (db PreimageDb) DeleteRange(start, end []byte) error { | ||
| return errors.New("preimage DB doesn't support DeleteRange") | ||
| } | ||
|
|
||
| func (db PreimageDb) Get(key []byte) ([]byte, error) { | ||
| var hash [32]byte | ||
| copy(hash[:], key) | ||
| if len(key) == 32 { | ||
| copy(hash[:], key) | ||
| } else if len(key) == len(rawdb.CodePrefix)+32 && bytes.HasPrefix(key, rawdb.CodePrefix) { | ||
| // Retrieving code | ||
| copy(hash[:], key[len(rawdb.CodePrefix):]) | ||
| } else { | ||
| return nil, fmt.Errorf("preimage DB attempted to access non-hash key %v", hex.EncodeToString(key)) | ||
| } | ||
| return melwavmio.ResolveTypedPreimage(arbutil.Keccak256PreimageType, hash) | ||
| } | ||
|
|
||
| func (db PreimageDb) Put(key []byte, value []byte) error { | ||
| return errors.New("preimage DB doesn't support Put") | ||
| } | ||
|
|
||
| func (db PreimageDb) Delete(key []byte) error { | ||
| return errors.New("preimage DB doesn't support Delete") | ||
| } | ||
|
|
||
| func (db PreimageDb) NewBatch() ethdb.Batch { | ||
| return NopBatcher{db} | ||
| } | ||
|
|
||
| func (db PreimageDb) NewBatchWithSize(size int) ethdb.Batch { | ||
| return NopBatcher{db} | ||
| } | ||
|
|
||
| func (db PreimageDb) NewIterator(prefix []byte, start []byte) ethdb.Iterator { | ||
| return ErrorIterator{} | ||
| } | ||
|
|
||
| func (db PreimageDb) Stat() (string, error) { | ||
| return "", errors.New("preimage DB doesn't support Stat") | ||
| } | ||
|
|
||
| func (db PreimageDb) Compact(start []byte, limit []byte) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (db PreimageDb) Close() error { | ||
| return nil | ||
| } | ||
|
|
||
| func (db PreimageDb) Release() { | ||
| } | ||
|
|
||
| func (db PreimageDb) SyncAncient() error { | ||
| return nil // no-op | ||
| } | ||
|
|
||
| func (db PreimageDb) SyncKeyValue() error { | ||
| return nil // no-op | ||
| } | ||
|
|
||
| type NopBatcher struct { | ||
| ethdb.KeyValueStore | ||
| } | ||
|
|
||
| func (b NopBatcher) ValueSize() int { | ||
| return 0 | ||
| } | ||
|
|
||
| func (b NopBatcher) Write() error { | ||
| return nil | ||
| } | ||
|
|
||
| func (b NopBatcher) Reset() {} | ||
|
|
||
| func (b NopBatcher) Replay(w ethdb.KeyValueWriter) error { | ||
| return nil | ||
| } | ||
|
|
||
| type ErrorIterator struct{} | ||
|
|
||
| func (i ErrorIterator) Next() bool { | ||
| return false | ||
| } | ||
|
|
||
| func (i ErrorIterator) Error() error { | ||
| return errors.New("preimage DB doesn't support iterators") | ||
| } | ||
|
|
||
| func (i ErrorIterator) Key() []byte { | ||
| return []byte{} | ||
| } | ||
|
|
||
| func (i ErrorIterator) Value() []byte { | ||
| return []byte{} | ||
| } | ||
|
|
||
| func (i ErrorIterator) Release() {} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[Suggestion] The unconditional
copy(hash[:], key)on line 34 is dead code: iflen(key) == 32, line 36 repeats the same copy; if it's the code prefix, line 39 overwrites; in theelsebranch at line 40 we return beforehashis ever used. This mirrors the same pattern incmd/replay/db.go:33-42, so it's pre-existing rather than introduced here — but since the file is brand new, good moment to drop the redundant line.