-
Notifications
You must be signed in to change notification settings - Fork 72
feat: multi blob #935
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
Merged
Merged
feat: multi blob #935
Changes from 30 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
1dcb46e
contract for blob
Kukoomomo 9b4d976
submitter multi batch
Kukoomomo a6958e1
fix: align V2 header generation and remove MAX_BLOB_PER_BLOCK constant
chengwenxi 2711f07
feat(prover): add multi-blob V2 support for prover, shadow-prove, and…
chengwenxi 9894b04
fix(prover): wire batch_version and fix V2 blob validation across all…
chengwenxi 8c419a7
refactor(challenge): simplify BatchInfo to use blob_hashes vec, drop …
chengwenxi f8a7f2e
style(prover): cargo fmt
chengwenxi edf823f
fix(prover): correct multi-blob decode — unpack all blobs first, deco…
chengwenxi d78251c
refactor: simplify V2 batch header — store aggregated blob hash at of…
chengwenxi 56bd83f
fix(rollup): store aggregatedBlobHash in batchBlobVersionedHashes for V2
chengwenxi 2ee96ae
refactor(rollup): extract _computeBlobVersionedHash, unify header con…
chengwenxi 9ae6e51
refactor(rollup): allow V2 batches to use commitState
chengwenxi 50f96d1
gas-price-oracle support multi blob
anylots c355467
fix(rollup): require blob count check before keccak in _computeBlobVe…
chengwenxi 10a7d3b
feat(node): multi-blob derivation support (V2 batch) (#937)
curryxbo 482f31c
update submitter config for multi blob
Kukoomomo 44e37a4
update devnet gov config
Kukoomomo 31b7bb7
update docker config
Kukoomomo 2bc40ff
update common
Kukoomomo 86b1764
gas-oracle batch data check
anylots 1bc53e3
fix(derivation): harden blob verification for PeerDAS sidecars (#944)
curryxbo 47f4b67
Merge branch 'main' into feat/multi_batch
curryxbo 7b7be9a
Merge branch 'main' into feat/multi_batch
8fe8bde
refactor: dedupe batch header / blob helpers, single-source on common…
curryxbo 82190b3
add common for batch
Kukoomomo 53aee9b
Merge branch 'feat/multi_batch' of github.com:morph-l2/morph into fea…
Kukoomomo a3568e0
add common for batch
Kukoomomo da9c301
fix node test
Kukoomomo cb17a22
fix node test
Kukoomomo 7535858
add logs
Kukoomomo 245656f
num_blobs check
anylots d61284e
update prover elf and programVkey
chengwenxi 2843031
fix(derivation): guard BlockContexts length before reading block-coun…
aae2213
fix(derivation): guard against blockCount underflow on malformed batches
f5f5656
add prover qa&testnet deploy cmd
anylots 82e7062
Revert "fix(derivation): guard against blockCount underflow on malfor…
e0756a4
use block header's state-root
anylots 5df8bf3
add default_batch_version
anylots 44ab6aa
update vkey
chengwenxi fbd1bee
chore: align go-ethereum submodule with origin/main
Kukoomomo 1fe0d74
add rustc version desc
anylots fa9f4e8
fix submitter replay batch with config max blob count
Kukoomomo 7ec11cf
Merge branch 'feat/multi_batch' of github.com:morph-l2/morph into fea…
Kukoomomo c6f7cc2
add v0/v1 blob check
Kukoomomo 4be9cda
update challenge handler dep
anylots 84ae08d
fix(derivation): guard against blockCount underflow on malformed batc…
curryxbo daf6937
fix(prover): replace .unwrap() with map_err in blob KZG verification …
chengwenxi af9e631
docs(prover): explain why header.state_root replaces morph_diskRoot (…
chengwenxi ab5c916
docs(shadow-prove): clarify version is read for logging only in calc_…
chengwenxi 6718710
Multi batch commit state (#954)
Kukoomomo c3243f2
Merge remote-tracking branch 'origin/main' into feat/multi_batch
chengwenxi dacd340
fix: address CodeRabbit issues from PR #935
chengwenxi 6ae662f
chore(prover): rebuild verifier-client ELF for SP1 v6 + multi_batch
chengwenxi 2e6b3db
upgrade prover's morph-reth dep to v0.2.0
anylots f63a5e7
prover throttle requests
anylots 7972e77
nonce check
Kukoomomo 4437c42
update bindings
Kukoomomo 680ef90
Merge branch 'main' into feat/multi_batch
chengwenxi 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
253 changes: 210 additions & 43 deletions
253
tx-submitter/batch/batch_cache.go → common/batch/batch_cache.go
Large diffs are not rendered by default.
Oops, something went wrong.
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,142 @@ | ||
| package batch | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "os/signal" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/morph-l2/go-ethereum/common/hexutil" | ||
| "github.com/morph-l2/go-ethereum/log" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| var ( | ||
| // Fill this with hex-encoded batch header bytes, e.g. "0x00....". | ||
| // This test will use it as the genesis parent header to initialize cache. | ||
| globalGenesisBatchHeaderHex = "0x00000000000000000000000000000000000000000000000000d81a073a4abd227068a2a334f4a41b3abba26144dc866a78ed28e2ae90f86f5a010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c4440140000000000000000000000000000000000000000000000000000000000000000290233e7a85533655c301d3e1043f03acd5427c73d1bbcbf8784db3f3974327f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" | ||
| globalGenesisBatchHeader *BatchHeaderBytes | ||
| globalGenesisBatchHeaderErr error | ||
| globalGenesisBatchHeaderOnce sync.Once | ||
|
|
||
| // Global overrides for cache batch config in tests (instead of updateBatchConfigFromGov). | ||
| globalBatchTimeoutForTest uint64 = 10000000 | ||
| globalBlockIntervalForTest uint64 = 10000 | ||
| ) | ||
|
|
||
| func ensureGlobalGenesisBatchHeader() error { | ||
| globalGenesisBatchHeaderOnce.Do(func() { | ||
| if globalGenesisBatchHeaderHex == "" { | ||
| globalGenesisBatchHeaderErr = fmt.Errorf("globalGenesisBatchHeaderHex is empty") | ||
| return | ||
| } | ||
| raw, err := hexutil.Decode(globalGenesisBatchHeaderHex) | ||
| if err != nil { | ||
| globalGenesisBatchHeaderErr = fmt.Errorf("decode globalGenesisBatchHeaderHex failed: %w", err) | ||
| return | ||
| } | ||
| header := BatchHeaderBytes(raw) | ||
| if err := header.validate(); err != nil { | ||
| globalGenesisBatchHeaderErr = fmt.Errorf("invalid global genesis batch header: %w", err) | ||
| return | ||
| } | ||
| globalGenesisBatchHeader = &header | ||
| }) | ||
| return globalGenesisBatchHeaderErr | ||
| } | ||
|
|
||
| // initCacheWithGlobalGenesisHeader initializes cache base fields from the | ||
| // globally cached genesis batch header, instead of loading through Init(). | ||
| func initCacheWithGlobalGenesisHeader(cache *BatchCache) error { | ||
| if err := ensureGlobalGenesisBatchHeader(); err != nil { | ||
| return err | ||
| } | ||
| if globalGenesisBatchHeader == nil { | ||
| return ErrKeyNotFound | ||
| } | ||
| // Use global test knobs instead of querying gov config from chain. | ||
| cache.batchTimeOut = globalBatchTimeoutForTest | ||
| cache.blockInterval = globalBlockIntervalForTest | ||
| headerCopy := make(BatchHeaderBytes, len(*globalGenesisBatchHeader)) | ||
| copy(headerCopy, *globalGenesisBatchHeader) | ||
| cache.parentBatchHeader = &headerCopy | ||
|
|
||
| prevStateRoot, err := cache.parentBatchHeader.PostStateRoot() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| cache.prevStateRoot = prevStateRoot | ||
|
|
||
| totalL1MessagePopped, err := cache.parentBatchHeader.TotalL1MessagePopped() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| cache.totalL1MessagePopped = totalL1MessagePopped | ||
|
|
||
| lastPackedBlockHeight, err := cache.parentBatchHeader.LastBlockNumber() | ||
| if err != nil { | ||
| lastPackedBlockHeight = 0 | ||
| } | ||
| cache.lastPackedBlockHeight = lastPackedBlockHeight | ||
| cache.currentBlockNumber = lastPackedBlockHeight | ||
| cache.initDone = true | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func TestBatchCacheInitWithGlobalGenesisHeader(t *testing.T) { | ||
| testDB := openTestKV(t) | ||
| a := func(uint64) bool { return true } | ||
| cache := NewBatchCache(nil, a, 3, l1Client, &SingleL2Client{C: l2Client}, rollupContract, l2Gov, testDB) | ||
|
|
||
| var batchCacheSyncMu sync.Mutex | ||
| done := make(chan error, 1) | ||
| go func() { | ||
| batchCacheSyncMu.Lock() | ||
| defer batchCacheSyncMu.Unlock() | ||
| for { | ||
| if err := initCacheWithGlobalGenesisHeader(cache); err != nil { | ||
| log.Error("init with global genesis header failed, wait for next try", "error", err) | ||
| time.Sleep(3 * time.Second) | ||
| continue | ||
| } | ||
| done <- nil | ||
| return | ||
| } | ||
| }() | ||
|
|
||
| select { | ||
| case err := <-done: | ||
| require.NoError(t, err) | ||
| case <-time.After(20 * time.Second): | ||
| t.Fatal("timeout waiting for cache init with global genesis header") | ||
| } | ||
|
|
||
| require.True(t, cache.initDone) | ||
| require.NotNil(t, cache.parentBatchHeader) | ||
| version, err := cache.parentBatchHeader.Version() | ||
| require.NoError(t, err) | ||
| require.Equal(t, uint8(BatchHeaderVersion0), version) | ||
| require.Equal(t, cache.lastPackedBlockHeight, cache.currentBlockNumber) | ||
| _, err = cache.l2Clients.BlockNumber(context.Background()) | ||
| require.NoError(t, err) | ||
|
|
||
| go testLoop(cache.ctx, 5*time.Second, func() { | ||
| batchCacheSyncMu.Lock() | ||
| defer batchCacheSyncMu.Unlock() | ||
| err := cache.AssembleCurrentBatchHeader() | ||
| if err != nil { | ||
| log.Error("Assemble current batch failed, wait for the next try", "error", err) | ||
| } | ||
| }) | ||
|
|
||
| // Catch CTRL-C to ensure a graceful shutdown. | ||
| interrupt := make(chan os.Signal, 1) | ||
| signal.Notify(interrupt, os.Interrupt) | ||
|
|
||
| // Wait until the interrupt signal is received from an OS signal. | ||
| <-interrupt | ||
| } | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.