-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
eth: request id dispatcher and direct req/reply APIs #23576
Conversation
f10a4fb
to
c6de738
Compare
With this change, I think we should make the request tracker more strict -- so we can rely on it for incoming messages. If we do that, we can do many checks earlier in the pipeline, e.g. checking block body before delivering upstream. |
74cb06b
to
30581fd
Compare
if written > 0 { | ||
rawdb.WriteFastTrieProgress(s.d.stateDB, s.d.syncStatsState.processed) | ||
//rawdb.WriteFastTrieProgress(s.d.stateDB, s.d.syncStatsState.processed) | ||
} |
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.
Either the clause can be removed entirely or this should be uncommented again?
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.
There's no fast sync in les
, so either way it doesn't matter. I think I just needed to remove references to the main downloader.SyncProcess
types, which have no notion of fast sync any more. I could have rewritten les
's downloader too, but figured that it's gonna happen anyway from scratch so better just keep the changes minimal and don't try to make actual "real" changes. I guess I left as a comment to keep te original code intact if we want to see what was there.
} | ||
|
||
// deliver is responsible for taking a generic response packet from the concurrent | ||
// fetcher, unpacking the body data and delivering it to the downloader's queue. |
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.
// fetcher, unpacking the body data and delivering it to the downloader's queue. | |
// fetcher, unpacking the receipt data and delivering it to the downloader's queue. |
I ran the downloader-tests with
|
Please see #23576 (comment) If you enable the race detector, everything gets significantly slower, so yeah, kind of to be expected. The "solution" could be to abstract out the notion of |
eth/handler_eth.go
Outdated
case *eth.BlockBodiesPacket: | ||
txset, uncleset := packet.Unpack() | ||
return h.handleBodies(peer, txset, uncleset) | ||
case *eth.BlockBodiesPacket: // TODO(karalabe): Delete before PR merge |
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.
Here's still a todo
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.
Yes, I'll delete this after a few benchmark syncs. Just want to make sue these don't end up in live code.
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.
Tried my best to review it, I didn't properly check the blockchain_test.go
and I could not super meaningfully review fetchers_concurrent.go
The rest looks good to me. We should create some fuzzers for Snap packages btw
} | ||
// Send back anything accumulated | ||
// Send back anything accumulated (or empty in case of errors) |
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.
It looks like you check the error beforehand, so you wouldn't send back anything in case of error
@@ -297,12 +297,6 @@ const schema string = ` | |||
currentBlock: Long! | |||
# HighestBlock is the latest known block number. | |||
highestBlock: Long! | |||
# PulledStates is the number of state entries fetched so far, or null |
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.
I think you need to add then new methods here so they can be called by graphql
@@ -205,7 +205,7 @@ var ( | |||
defaultSyncMode = ethconfig.Defaults.SyncMode | |||
SyncModeFlag = TextMarshalerFlag{ | |||
Name: "syncmode", | |||
Usage: `Blockchain sync mode ("fast", "full", "snap" or "light")`, | |||
Usage: `Blockchain sync mode ("snap", "full" or "light")`, |
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.
Might be that this change causes a lot of existing setups to refuse to start. Maybe we shoud deprecate fast
and just internally translate it to snap
for a while?
5c5c2f7
to
792779d
Compare
// Deliver the filled out response and wait until it's handled. This | ||
// path is a bit funky as Go's select has no order, so if a response | ||
// arrives to an already cancelled request, there's a 50-50% changes | ||
// of picking on channel or the other. To avoid such cases delivering |
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.
// of picking on channel or the other. To avoid such cases delivering | |
// of picking one channel or the other. To avoid such cases delivering |
1aea7ad
to
ce55507
Compare
84f66fc
to
bcabe1c
Compare
bcabe1c
to
577d826
Compare
delete(pending, req.Peer) | ||
stales[req.Peer] = req |
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.
With this change here, afaict the comment is now misleading. We don't cancel it so it's not considered in-flight anymore, since we no longer call req.Close()
on it. I suppose the caller keeps waiting for the reply, even though this internally has been moved to stale? And after a little while longer, the peer will be rejected, prompting the stale request to be Close
d and rescheduled?
@@ -173,10 +196,24 @@ func (p *Peer) dispatchRequests() { | |||
pending[req.id] = req | |||
} | |||
|
|||
case cancelOp := <-p.reqCancel: | |||
// Retrieve the pendign request to cancel and short circuit if it |
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.
s/pendign/pending
case resOp := <-p.resDispatch: | ||
res := resOp.res | ||
res.Req = pending[res.id] | ||
res.Time = res.recv.Sub(res.Req.sent) | ||
|
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.
What happens if the response to a stale
request comes in -- we just drop it, right? I don't quite follow the logic. So we shuffle it over from pending
to stale
, but we still don't (immediately) reschedule it, but neither do we handle a late response?
I must have missed something, but it seems like moving something to stale
unconditionally means it will time out a bit later, leading to the peer being rejected.
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.
Ah, my bad. The pending
here is dispatcher-local pending, it has no relation to the pending/stales in the downloader.
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.
LGTM
SyncProgress was modified in PR ethereum#23576 to add the fields reported for snap sync. The PR also changed ethclient to use the SyncProgress struct directly instead of wrapping it for hex-decoding. This broke the SyncProgress method. Fix it by putting back the custom wrapper. While here, also put back the fast sync related fields because SyncProgress is stable API and thus removing fields is not allowed.
SyncProgress was modified in PR #23576 to add the fields reported for snap sync. The PR also changed ethclient to use the SyncProgress struct directly instead of wrapping it for hex-decoding. This broke the SyncProgress method. Fix it by putting back the custom wrapper. While here, also put back the fast sync related fields because SyncProgress is stable API and thus removing fields is not allowed. Fixes #24180 Fixes #24176
SyncProgress was modified in PR ethereum#23576 to add the fields reported for snap sync. The PR also changed ethclient to use the SyncProgress struct directly instead of wrapping it for hex-decoding. This broke the SyncProgress method. Fix it by putting back the custom wrapper. While here, also put back the fast sync related fields because SyncProgress is stable API and thus removing fields is not allowed. Fixes ethereum#24180 Fixes ethereum#24176
* eth: request ID based message dispatcher * eth: fix dispatcher cancellation, rework fetchers idleness tracker * eth/downloader: drop peers who refuse to serve advertised chains
SyncProgress was modified in PR ethereum#23576 to add the fields reported for snap sync. The PR also changed ethclient to use the SyncProgress struct directly instead of wrapping it for hex-decoding. This broke the SyncProgress method. Fix it by putting back the custom wrapper. While here, also put back the fast sync related fields because SyncProgress is stable API and thus removing fields is not allowed. Fixes ethereum#24180 Fixes ethereum#24176
… beacon sync. including commits: c10a0a6 pr: ethereum/go-ethereum#23576 c893488 pr: ethereum/go-ethereum#24032 58d1988 pr: ethereum/go-ethereum#24047 6ce4670 pr: ethereum/go-ethereum#24276 8f66ea3 pr: ethereum/go-ethereum#23982 ......
* L2 consensus api auth api * scroll new version adjustment * Introduce L1Message type transaction test fix * add BLS Data add optional rlp tag * add docker-compose and modify entrypoint for dockerfile * Improve oversized block handling (#315) * improve oversized block handling * bump version * Archimedes hard fork: Disable sha2, ripemd, blake2f precompiles (#280) * add placeholder block * add test, more changes * revert aleth changes * typo * typo * precompile switch * change precomiles * rename placeholder to archimedes * fix comment * ScrollAlphaChainConfig * add nil for archimedes block for now * fix test typo * add isShanghai rule based on block number (#319) * add isShanghai rule based on block number * fix lint * nit --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * core: implement EIP-3651, warm coinbase (#317) * core: implement EIP-3651, warm coinbase (#25819) Implements EIP-3651, "Warm Coinbase", for Shanghai hardfork. Specification: https://eips.ethereum.org/EIPS/eip-3651. * improve test * update to shanghai * trigger ci * fix comments --------- Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> * chore(github): Add PR template to ask for rationale and version update (#327) Create pull_request_template.md * cherry-pick commits from ethereum for the further snapshot sync using beacon sync. including commits: c10a0a6 pr: ethereum/go-ethereum#23576 c893488 pr: ethereum/go-ethereum#24032 58d1988 pr: ethereum/go-ethereum#24047 6ce4670 pr: ethereum/go-ethereum#24276 8f66ea3 pr: ethereum/go-ethereum#23982 ...... * writeBlockWithState with head insertion directly * core/vm: implement EIP-3860: Limit and meter initcode (#23847) (#318) * core/vm: implement EIP-3860: Limit and meter initcode (#23847) Implementation of https://eips.ethereum.org/EIPS/eip-3860, limit and meter initcode. This PR enables EIP-3860 as part of the Shanghai fork. Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> * add ishanghai * fix test * fix --------- Co-authored-by: Andrei Maiboroda <andrei@ethereum.org> Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Add Archimedes hard fork block number for Scroll Alpha (#331) * add Archimedes hard fork block number for Scroll Alpha * bump version * feat(trace): add storage proof about l1fee (baseFee, overhead, scalar) and withdraw root into trace (#314) * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add coinbase storage as trace * comment for clarify * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: enable eip and update check (#335) * enable eip and update check * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(trace): deletion proof missed path terminated by empty node (#330) * fix deletion proof issue on empty node * refine for better implement and fix unittest * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(API): use `hexutil.Big` for `l1Fee` in `GetTransactionReceipt` (#336) * It's not a bug, but if just translate to hexutil.Big can be better. * Revert editor's auto change. * Update version. * Update version. * refactor(config): moved fee vault addr to rollup config (#341) * moved fee vault addr to rollup config * fixed linter issue * added back FeeVaultAddress --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * feat(abigen): add `--contract` flag to specify a given contract (#334) * add contract flag * Use GlobalXX * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix txs p2p && testnet scripts * Merge scroll tag v3.2.4 into morphism (#9) * feat(trace): add storage proof about l1fee (baseFee, overhead, scalar) and withdraw root into trace (#314) * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add coinbase storage as trace * comment for clarify * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: enable eip and update check (#335) * enable eip and update check * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(trace): deletion proof missed path terminated by empty node (#330) * fix deletion proof issue on empty node * refine for better implement and fix unittest * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(API): use `hexutil.Big` for `l1Fee` in `GetTransactionReceipt` (#336) * It's not a bug, but if just translate to hexutil.Big can be better. * Revert editor's auto change. * Update version. * Update version. --------- Co-authored-by: Ho <noelwei@gmail.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: maskpp <maskpp266@gmail.com> * build(github): update github action yaml (#347) * build(github): update github action yaml * fix * optimize block validation * ci(github): update pull request template (#349) * chore(github): update pull request template * Update pull_request_template.md * Return error for disabled precompile calls (#337) return error for disabled precompile calls * feat: delay Archimedes on Alpha by a week (#342) * delay Archimedes on Alpha by a week * bump version --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Fix transaction DA cost under-estimation (#332) * fix tx DA cost under-estimation * bump version --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat(block_validator): check payload size during block validation (#322) * added block size check in validate body * added payload method to block * Update core/types/block.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * fixed test * fix * bump version * fix test --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * test(zkTrie): add deletion test in account update unit test (#344) feat(zkTrie): extend account update unit tests with account deletion * Merge commits under tag of scroll-v3.3.0 from scroll-tech (#10) * feat(trace): add storage proof about l1fee (baseFee, overhead, scalar) and withdraw root into trace (#314) * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add coinbase storage as trace * comment for clarify * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: enable eip and update check (#335) * enable eip and update check * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(trace): deletion proof missed path terminated by empty node (#330) * fix deletion proof issue on empty node * refine for better implement and fix unittest * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(API): use `hexutil.Big` for `l1Fee` in `GetTransactionReceipt` (#336) * It's not a bug, but if just translate to hexutil.Big can be better. * Revert editor's auto change. * Update version. * Update version. * refactor(config): moved fee vault addr to rollup config (#341) * moved fee vault addr to rollup config * fixed linter issue * added back FeeVaultAddress --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * feat(abigen): add `--contract` flag to specify a given contract (#334) * add contract flag * Use GlobalXX * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * build(github): update github action yaml (#347) * build(github): update github action yaml * fix * ci(github): update pull request template (#349) * chore(github): update pull request template * Update pull_request_template.md * Return error for disabled precompile calls (#337) return error for disabled precompile calls --------- Co-authored-by: Ho <noelwei@gmail.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: maskpp <maskpp266@gmail.com> Co-authored-by: Richord <rzhang139@gmail.com> * fix: add missing term when merging two deletion proofs (#353) * fix: merge emptyTermPaths * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * update docker image name * fix(ethclient): support WithdrawalsHash in Scroll Go SDK (#354) * added withdrawalsHash to header * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * update docker-compose * fix(tracing): fix ZktrieTracer race condition (#356) * fix race condition of zktrie tracer * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: Sync and relay L1 messages (#350) * add l1 config in genesis config (#249) * add l1 config in genesis config * fix lint * Update params/config.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * extend node configuration (#251) * extend node configuration * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * fix typos --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Fix/improve node config parsing (#260) * raise error on failed parsing * default value * add l1-message-type, transaction methods (#252) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * txpool l1 check, pointer change, marhsal test * draft: start implementing l1message gas behavior * draft: start implementing l1message gas behavior * change to gas usage * error comment typo Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * goimports * update nonce, add hash test (fails), marshal test * goimports * target addr cant be nil * change call msg * comment out test * lint --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Add L1 message database (#255) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * remove comments * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * add range check * fix tests * update comments * nit * support blocks with 0 l1 messages --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * Fix L1Message Deep Copy, Complete Bridge Tx Hash test (#269) * deep copy value field, add tx hash test comment * typo * Rename nonce to queueindex, increment sender nonce on L1 message execution (#271) * change nonce to queueindex, increment nonce on L1 message * fix db acccessors * Update core/types/transaction_marshalling.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Fix db inspect command (#276) fix db inspect command * Add l1 sync service (#256) * extend node configuration * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * add L1 message store to rawdb * remove comments * fix typos * add L1 message sync service * use l1 contract address and chain ID * use L1DeploymentBlock * add confirmation config * move bridge client to separate file * use uint64 block number * fix bigint comparison * rename constants * add more logs * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * check if config is provided * improve sync service DB batched writes * add range check * fix tests * update comments * nit * fix flush range and improve comments * solve circular dependency * update stress tests * initialize l1 client for geth * start sync service * add more comments * check nil correctly * address comments * fix merge * fix genesis l1config deserialization * add sync progress logs * initial sync * handle leveldb not found error * use errors.Is * address comments * update DefaultPollInterval --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * Add L1 message validation (#272) * add L1 message validation * add comments and better error handling * handle leveldb not found error * update incorrect condition for genesis block * typo * change inclusion index logic * disable L1 message check for legacy tests * set NumL1MessagesPerBlock to 0 in tests * update default genesis config * Add L1 msg validation tests (#303) add L1 msg validation tests * Update miner include l1 messages (#265) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * add L1 message sync service * remove comments * use l1 contract address and chain ID * extend node configuration * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * fix typos * use L1DeploymentBlock * add confirmation config * move bridge client to separate file * use uint64 block number * fix bigint comparison * rename constants * add more logs * Fix/improve node config parsing (#260) * raise error on failed parsing * default value * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * check if config is provided * improve sync service DB batched writes * include l1 messages in blocks: part 1 * add l1-message-type, transaction methods (#252) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * txpool l1 check, pointer change, marhsal test * draft: start implementing l1message gas behavior * draft: start implementing l1message gas behavior * change to gas usage * error comment typo Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * goimports * update nonce, add hash test (fails), marshal test * goimports * target addr cant be nil * change call msg * comment out test * lint --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Add L1 message database (#255) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * remove comments * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * add range check * fix tests * update comments * nit * support blocks with 0 l1 messages --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * build(docker): auto docker push when pushing git tags (#258) * build(docker): update docker trigger tag prefix (#259) * Fix L1Message Deep Copy, Complete Bridge Tx Hash test (#269) * deep copy value field, add tx hash test comment * typo * commitl1messages * lint * Revert "add L1 message sync service" This reverts commit 5305e8a5de14766ed249e1a7d64042c7a72cf5c2. * Revert "move bridge client to separate file" This reverts commit 0b220bee37de93c3250545e23430db2c401a2f90. * update branch * use commitMessages for l1Txs * little fix * fix config * fix test * comment fixes * fix * fix config check --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Add ErrUnknownAncestor tests (#305) add ErrUnknownAncestor tests * worker test include l1 msgs (#306) * worker test include l1 msgs * move L1 message index update next to block insertion --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * exclude l1 messages from transaction count limit in block (#307) * exclude l1 messages from transaction count limit in block * fix comments * trigger ci * nit --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Expose queueIndex on Transaction (#316) expose queueIndex on Transaction * test that l1msg doesn't count in maxTxPerBlock limit (#312) * test that l1msg doesn't count in maxTxPerBlock limit * fix, comment * retrigger ci * change order inside test --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * reuse trace nonce field for queueIndex * expose scroll APIs on the geth console * add L1 message query APIs * Trigger new block on new l1 messages (#343) * trigger new block on new l1 messages * typo * initialize l1MsgCh * fix worker l1msg tests (#345) --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> * test(worker): ensure that l1 messages are included in the correct order (#346) test that l1msgs added in correct order * rename enqueueIndex --> queueIndex * move QueueIndex into transaction * improve l1 db interface * formatting * bump version * print l1config * add API to query latest included message queue index * clean up tx limit logic * add clarifying comments and todos to ValidateL1Messages * improve db comments and logs * clean up L1MessageTx type handling * format * format * improve L1 message block check * fix missing L1 event handling * fix TestL1MessageValidationFailure * simplify sync height resume logic * make l1Config.l1MessageQueueAddress non-pointer * improve command line flags * remove todo * use abigen tools for log filtering * cache block L1 message count * nit: fix variable name case * improve logs * flush pending writes to DB before shutdown --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> * enable empty block * add feeVaultAddress into default genesis * update entrypoint and docker-compose conf for devops * update entrypoint and docker-compose conf for devops (#12) * add hash * fix * fix(trace): change l1Fee type from uint64 to *big.Int (#360) * fix: change l1Fee type from uint64 to *big.Int * use hexutil.Big * Integrate with the commits under tag scroll v4.1.0 * feat(trace): add storage proof about l1fee (baseFee, overhead, scalar) and withdraw root into trace (#314) * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add coinbase storage as trace * comment for clarify * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: enable eip and update check (#335) * enable eip and update check * Update version.go --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(trace): deletion proof missed path terminated by empty node (#330) * fix deletion proof issue on empty node * refine for better implement and fix unittest * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix(API): use `hexutil.Big` for `l1Fee` in `GetTransactionReceipt` (#336) * It's not a bug, but if just translate to hexutil.Big can be better. * Revert editor's auto change. * Update version. * Update version. * refactor(config): moved fee vault addr to rollup config (#341) * moved fee vault addr to rollup config * fixed linter issue * added back FeeVaultAddress --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * feat(abigen): add `--contract` flag to specify a given contract (#334) * add contract flag * Use GlobalXX * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Update cmd/abigen/main.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * build(github): update github action yaml (#347) * build(github): update github action yaml * fix * ci(github): update pull request template (#349) * chore(github): update pull request template * Update pull_request_template.md * Return error for disabled precompile calls (#337) return error for disabled precompile calls * feat: delay Archimedes on Alpha by a week (#342) * delay Archimedes on Alpha by a week * bump version --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Fix transaction DA cost under-estimation (#332) * fix tx DA cost under-estimation * bump version --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat(block_validator): check payload size during block validation (#322) * added block size check in validate body * added payload method to block * Update core/types/block.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * fixed test * fix * bump version * fix test --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * test(zkTrie): add deletion test in account update unit test (#344) feat(zkTrie): extend account update unit tests with account deletion * fix: add missing term when merging two deletion proofs (#353) * fix: merge emptyTermPaths * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * fix(ethclient): support WithdrawalsHash in Scroll Go SDK (#354) * added withdrawalsHash to header * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * fix(tracing): fix ZktrieTracer race condition (#356) * fix race condition of zktrie tracer * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * feat: Sync and relay L1 messages (#350) * add l1 config in genesis config (#249) * add l1 config in genesis config * fix lint * Update params/config.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * extend node configuration (#251) * extend node configuration * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * fix typos --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Fix/improve node config parsing (#260) * raise error on failed parsing * default value * add l1-message-type, transaction methods (#252) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * txpool l1 check, pointer change, marhsal test * draft: start implementing l1message gas behavior * draft: start implementing l1message gas behavior * change to gas usage * error comment typo Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * goimports * update nonce, add hash test (fails), marshal test * goimports * target addr cant be nil * change call msg * comment out test * lint --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Add L1 message database (#255) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * remove comments * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * add range check * fix tests * update comments * nit * support blocks with 0 l1 messages --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * Fix L1Message Deep Copy, Complete Bridge Tx Hash test (#269) * deep copy value field, add tx hash test comment * typo * Rename nonce to queueindex, increment sender nonce on L1 message execution (#271) * change nonce to queueindex, increment nonce on L1 message * fix db acccessors * Update core/types/transaction_marshalling.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Fix db inspect command (#276) fix db inspect command * Add l1 sync service (#256) * extend node configuration * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * add L1 message store to rawdb * remove comments * fix typos * add L1 message sync service * use l1 contract address and chain ID * use L1DeploymentBlock * add confirmation config * move bridge client to separate file * use uint64 block number * fix bigint comparison * rename constants * add more logs * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * check if config is provided * improve sync service DB batched writes * add range check * fix tests * update comments * nit * fix flush range and improve comments * solve circular dependency * update stress tests * initialize l1 client for geth * start sync service * add more comments * check nil correctly * address comments * fix merge * fix genesis l1config deserialization * add sync progress logs * initial sync * handle leveldb not found error * use errors.Is * address comments * update DefaultPollInterval --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * Add L1 message validation (#272) * add L1 message validation * add comments and better error handling * handle leveldb not found error * update incorrect condition for genesis block * typo * change inclusion index logic * disable L1 message check for legacy tests * set NumL1MessagesPerBlock to 0 in tests * update default genesis config * Add L1 msg validation tests (#303) add L1 msg validation tests * Update miner include l1 messages (#265) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * add L1 message sync service * remove comments * use l1 contract address and chain ID * extend node configuration * use block number instead of hash * accept safe, finalized and numbers for L1Confirmations * fix typos * use L1DeploymentBlock * add confirmation config * move bridge client to separate file * use uint64 block number * fix bigint comparison * rename constants * add more logs * Fix/improve node config parsing (#260) * raise error on failed parsing * default value * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * check if config is provided * improve sync service DB batched writes * include l1 messages in blocks: part 1 * add l1-message-type, transaction methods (#252) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * txpool l1 check, pointer change, marhsal test * draft: start implementing l1message gas behavior * draft: start implementing l1message gas behavior * change to gas usage * error comment typo Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * goimports * update nonce, add hash test (fails), marshal test * goimports * target addr cant be nil * change call msg * comment out test * lint --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Add L1 message database (#255) * add l1-message-type, transaction methods * goimports * Update core/types/transaction.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * add L1 message store to rawdb * remove comments * rename to l1_message * rename variables and add comments * write l1 msgs in a batch * add more comments * update tests * allow batched and non-batched writes * rename to accessors_l1_message * handle error * add range check * fix tests * update comments * nit * support blocks with 0 l1 messages --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> * build(docker): auto docker push when pushing git tags (#258) * build(docker): update docker trigger tag prefix (#259) * Fix L1Message Deep Copy, Complete Bridge Tx Hash test (#269) * deep copy value field, add tx hash test comment * typo * commitl1messages * lint * Revert "add L1 message sync service" This reverts commit 5305e8a5de14766ed249e1a7d64042c7a72cf5c2. * Revert "move bridge client to separate file" This reverts commit 0b220bee37de93c3250545e23430db2c401a2f90. * update branch * use commitMessages for l1Txs * little fix * fix config * fix test * comment fixes * fix * fix config check --------- Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Add ErrUnknownAncestor tests (#305) add ErrUnknownAncestor tests * worker test include l1 msgs (#306) * worker test include l1 msgs * move L1 message index update next to block insertion --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * exclude l1 messages from transaction count limit in block (#307) * exclude l1 messages from transaction count limit in block * fix comments * trigger ci * nit --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * Expose queueIndex on Transaction (#316) expose queueIndex on Transaction * test that l1msg doesn't count in maxTxPerBlock limit (#312) * test that l1msg doesn't count in maxTxPerBlock limit * fix, comment * retrigger ci * change order inside test --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * reuse trace nonce field for queueIndex * expose scroll APIs on the geth console * add L1 message query APIs * Trigger new block on new l1 messages (#343) * trigger new block on new l1 messages * typo * initialize l1MsgCh * fix worker l1msg tests (#345) --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> * test(worker): ensure that l1 messages are included in the correct order (#346) test that l1msgs added in correct order * rename enqueueIndex --> queueIndex * move QueueIndex into transaction * improve l1 db interface * formatting * bump version * print l1config * add API to query latest included message queue index * clean up tx limit logic * add clarifying comments and todos to ValidateL1Messages * improve db comments and logs * clean up L1MessageTx type handling * format * format * improve L1 message block check * fix missing L1 event handling * fix TestL1MessageValidationFailure * simplify sync height resume logic * make l1Config.l1MessageQueueAddress non-pointer * improve command line flags * remove todo * use abigen tools for log filtering * cache block L1 message count * nit: fix variable name case * improve logs * flush pending writes to DB before shutdown --------- Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> * remove syncing L1 messages related, it is migrated to node service --------- Co-authored-by: Ho <noelwei@gmail.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: maskpp <maskpp266@gmail.com> Co-authored-by: Richord <rzhang139@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> * feat: update l1fee calculation (#351) * update env for docker compose * update docker compose * feat: return keccak(chainId || height) for BLOCKHASH opcode (#359) * changed blockhash behavior * added patch version * Update core/vm/runtime/runtime_test.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * Update core/vm/runtime/runtime_test.go Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> * lint fix * changed wording * used interpreter.hasher and padded chainId to uint64 * used interpreter.hasher and padded chainId to uint64 * undo changes * bump version --------- Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * execute safe block * add newSafeL2Block to api client * feat(abigen): Add flag let be able to add user tmpl file. (#362) * Add user tmpl file. * Update accounts/abi/bind/template.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Update cmd/abigen/main.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Update cmd/abigen/main.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Update cmd/abigen/main.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix bug --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix: improve L1Message RPC encoding (#368) correctly encode L1 messages in RPC response * make baseFee unnecessary * fix block rlp encode issue * add testnet geth config file (#17) Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * Morph testnet deploy v0.0.1 (#18) * add testnet geth config file * add nohub to geth cmd --------- Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * count fix * feat: update contract ABI QueueIndex type to uint64 (#371) * update contract ABI QueueIndex type to uint64 * Update bindings.go * feat(core/vm): revert modexp precompiled contract if input is not u256 (#361) * Revert modexp precompiled contract if input is not u256 * bump version * use specific error * bump version * tests * bump version * fix lint * Update version.go --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * feat(evm): limit ecPairing precompile to use up to 4 inputs (#373) * feat(evm): limit ecPairing precompile to use up to 4 inputs * update test cases * reorder test functions * change the predeploy contract address * fix: include L1MessageTx fields in transaction RPC result (#375) * fix: include L1MessageTx fields in tx RPC result * bump version * Update entrypoint.sh (#19) * fix test compile error * feat(trace): add per_tx_storage_trace (#372) * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add pertx storage trace * dummy tx proof * add txstorage trace * add coinbase storage as trace * Update version.go * address comments --------- Co-authored-by: Ho Vei <noelwei@gmail.com> * add new func * fix(trace): fix `statesAffected` in `traceLastNAddressAccount` (#367) * fix(trace): fix * Update version.go * fix(trace): fix storage proof of l1gas price oracle (#376) * fix storage proof of l1gas price oracle * Update version.go * fix(trace): fix --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * add withdrawTrieRoot * feat(core/vm): modexp precompiled support also less than 32-bytes inputs (#393) * modexp support 32-bytes or less inputs * change revert string * bump version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * feat(rawdb&rpc): add block row consumption rpc (#388) * add db api for rowconsumption * add rpc api for block row consumption * return nil if rc is is not known * add method to sdk * bump version * small fix * update version --------- Co-authored-by: Péter Garamvölgyi <peter@scroll.io> * change withdrawTrieRootSlot to 45 * add logs for debuging * more logs * more logs * separat entrypoint for testnet (#20) * fix estimateGas issue. similar to ethereum PR:24363 * fix the KnownBlock issue * fix(ethapi): change scroll_getBlockByHash ethapi behaviour (#398) * fix api behaviour * update version * not retrun error in ethclient * add comment * modify rowconsumption struct * fix lint * change naming * fix newL2SafeBlock * make baseFeePerGas not Must * remove parentHash from safeL2Data * update run testnet shell (#22) Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * fix compile error testcase * update run testnet shell (#23) Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * improve * Feature/testnet runner (#24) * update run testnet shell * refine run testnet sh --------- Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * Feature/testnet runner (#25) * update run testnet shell * refine run testnet sh * refine testnet runner --------- Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * blockSize gets length of txHash involved * add script to run testnet sentry geth * update l2node geth command with --nodiscover (#26) Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * fix incompatible block hash (#27) fix * Feature/run testnet update (#28) * update l2node geth command with --nodiscover * add run testnet in validator role * add comment for each script --------- Co-authored-by: Yu Marvel <marvel.yu@bitget.com> * Feature/run testnet update (#29) * update l2node geth command with --nodiscover * add run testnet in validator role * add comment for each script * remove set -u for script --------- Co-authored-by: Yu Marvel <marvel.yu@bitget.com> --------- Co-authored-by: marvelfisher <marvelfisher@gmail.com> Co-authored-by: Péter Garamvölgyi <th307q@gmail.com> Co-authored-by: Max Wolff <max@scroll.io> Co-authored-by: Nazarii Denha <dengaaa2002@gmail.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io> Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Orest Tarasiuk <830847+OrestTa@users.noreply.github.com> Co-authored-by: Péter Szilágyi <peterke@gmail.com> Co-authored-by: Andrei Maiboroda <andrei@ethereum.org> Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com> Co-authored-by: Martin Holst Swende <martin@swende.se> Co-authored-by: Ho <noelwei@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: maskpp <maskpp266@gmail.com> Co-authored-by: Richord <rzhang139@gmail.com> Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-14-253.us-west-2.compute.internal> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: Max Wolff <maxcwolff@gmail.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com> Co-authored-by: Yu Marvel <marvel.yu@bitget.com>
With all non-request-id
eth
protocol version dropped (<= eth/65
), we can finally properly match up inbound replies to pending requests (e.g. inboundReceiptsMsg
to pendingGetReceiptsMsg
). This is a very good thing, as is greatly simplifies internal code... after a huge rewrite, this PR.Background
A huge complexity in our network packet handling code is that there can be concurrent requests of the same type sent to the same peer. These happen because there are multiple subsystems that run concurrently, and which may want to fetch something:
downloader
requests headers, bodies, receipts and states.fetcher
requests headers and bodies.eth
package does header challenges.To make matters worse, if a peer disconnects and quickly reconnects (Parity liked to do this), it can happen that there are still some reply handling propagating through the system from the old connection, whilst the new connection is hit with requests and starts delivering replies too.
The net effect is that when a reply packet arrives (header, body, receipt, state delivery), there can be many requests waiting for it all over the place. Since there's no way in <= eth/65 to match the arriving packets up with the requests, our code had a filtering mechanism implemented: a reply packet is first given to the eth challenge handler; it it doesn't consume it, it is handed to the fetcher; if it is still not consumed, it is handed to the downloader.
This quickly becomes a horrible thing when we also allow partial deliveries or altogether empty replies (missing data); as subsystems will start to consume each others' data, leading to inconsistencies (timeouts and weird behavior) in the starved subsystem. Further complexity arises when peers send spam data; or when a reply reaches a subsystem where the peer already disconnected/reconnected and was issues a new request.
Geth does handle all this complexity currently. It's just insanely complicated and with The Merge coming and requiring heavy protocol changes; it's extremely brittle to keep hacking the existing code, hoping it won't blow up. The only sane way out, is to rework the entire reply consumption mechanism; or formally put, the reply dispatching.
Dispatcher
As detailed above, Geth's reply handling is insanely complicated, forced by the
eth
protocol not supporting matching replies to requests.eth/66
, however, introduced a request ID in all request packets that get echoed back in the replies to those packets.Using these ping-ponged IDs, we could ensure that subsystems don't consume each other's messages; that unrequested data gets correctly dropped; or that deliveries across reconnects don't influence each other. Still, keeping the old architecture of each subsystem filtering through all the inbound messages - just because in the legacy protocols they had to - becomes useless complexity that still hinders work on The Merge.
Instead of having an architecture where network replies enter the system through the protocol handlers and then bubble through everything to reach their final destination, this PR introduces a request/reply dispatcher that delivers a reply message directly to the point of request. This simplifies packet handling a lot:
eth
chain challenges; or thedownloader
ancestor lookup); it can simply block - inline in the code, like a function call waiting for the return - until the reply arrives or the request times out. No more waiting on channels that might deliver junk.downloader
receipt chain retrieval), it can multiplex the replies into a single sink channel, but still have the guarantee that only one reply arrives to a request and that every request either gets serviced or times out. This moves the error handling complexity out of the higher level subsystem.This dispatcher is implemented within
eth/protocols/eth
and is part of theeth.Peer
(i.e. each peer gets its own dispatcher to avoid starvation issues). The dispatcher in essence is a goroutine that receiveseth.Request
objects to send over the wire and tracks these until a response-type message arrives bundled up as aneth.Response
. After a successful match, the response payload is delivered on the sink channel of the request.The
eth.Request
objects aren't constructed publicly, they are created byeth.Peer.RequestXYZ
, but they are returned to the caller since they allow cancelling a pending request if the caller deems so (e.g. timeout, disconnect, etc). It is essential to note that the dispatcher does not untrack requests on disconnect and does not untrack requests on timeouts. It doesn't even have a notion of untracking requests itself. This is important, as it creates a deterministic workflow:eth.Request
instanceThis workflow is very easy to reason about as response delivery has it's dedicated flow/direction (dispatcher to caller via sink channel) and cleanup handling has it's own dedicated flow/direction (caller to dispatcher via method calls (internally channels)). There's no dirtying of flows by sending lifecycle events on the data channel.
API
Although the dispatcher is part of an
eth.Peer
, it is not publicly callable. Since theeth.Request
types need to be assembled - which is half protocol dependent, half dispatcher dependent - the requests are created and dispatched by thepeer.RequestXYZ
methods. Similarly, theeth.Responses
are assembled and dispatched internally in the handlers.However, since requests do need to be tracked and potentially cancelled, the
eth.Request
is public and returned via thepeer.RequestXYZ
methods. Similarly, it's simpler to also delivereth.Response
as a public type to the caller (via the request sink) since it allows bundling up a lot of useful metadata. The exact content was derived by what was necessary to support the fetchers and downloaders.One downside of working with public
eth.Request
andeth.Response
types is that the downloader and fetcher got locked in to theeth
protocol, whereas previously the same code was used forles
too. This is a curious issue, because on the surface it might be considered a downside - fixable with introducing interfaces (currently the old code was duplicated into les). But thinking about it mid-term, it's not really a good idea to complicate the codebase back again to support multiple protocols:eth
one becomes dead code.les
becomes completely different after The Merge, since the chain head is available via the consensus node; and there's no reason to download entire past chain segments (currently we need it to sync).As such, this PR assumes that both the duplicated fetcher and downloader in
les
will be altogether deleted after the merge. There's very little point in hacking the entire codebase into something abstract that has a half a year death sentence anyway.Refactors
The above described dispatcher which delivers responses directly to the callsite has the potential to simplify everything, but it does entail a significant refactor since everything was built on the bubble-through approach (
les
even does some accounting on top 😱).The PR does a full and clean refactor of the
downloader
to support the new model. Sincefast sync
is deprecated, that part of the code was deleted altogether (since refactoring it is painful), completely relying onsnap sync
from now on. Snap sync was not previously tested within the context of the downloader, so the PR also completely overhauls the downloader tests to use the realcore.BlockChain
code andeth.Handlers
code as we can't meaningfully mock out the snapshot tree handlig. This is a huge change in the downloader, but it cleans everything up in preparation for the reverse syncer work for The Merge.The PR did a murky-er refactor within the fetcher. Instead of rewriting the whole thing - at significant time cost - I've just did the bare minimum to hack in the new model. The thinking is that the fetcher is going away anyway after the merge, so don't waste time on fixing stuff on the death row.
The PR also cleanly integrated the dispatcher model into the
eth
header challenges.