Skip to content
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

[FEATURE]Morphism geth implementation #3

Merged
merged 103 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
de64cb2
L2 consensus api
FletcherMan Apr 12, 2023
2881444
scroll new version adjustment
FletcherMan Apr 20, 2023
f32afd5
Introduce L1Message type transaction
FletcherMan Apr 26, 2023
6cb5dfe
add BLS Data
FletcherMan May 4, 2023
bfb092d
add docker-compose and modify entrypoint for dockerfile
MarvelFisher May 6, 2023
7da27f6
Merge remote-tracking branch 'upstream/develop' into fletcher/l2-geth
FletcherMan May 8, 2023
27a3830
Improve oversized block handling (#315)
Thegaram May 8, 2023
b0b0bf1
Archimedes hard fork: Disable sha2, ripemd, blake2f precompiles (#280)
maxwolff May 9, 2023
b1e5eea
add isShanghai rule based on block number (#319)
NazariiDenha May 10, 2023
29b23f4
core: implement EIP-3651, warm coinbase (#317)
NazariiDenha May 12, 2023
e1fb195
chore(github): Add PR template to ask for rationale and version updat…
OrestTa May 15, 2023
d3affee
cherry-pick commits from ethereum for the further snapshot sync using…
karalabe Nov 26, 2021
d49ea7d
writeBlockWithState with head insertion directly
FletcherMan May 18, 2023
c5da652
core/vm: implement EIP-3860: Limit and meter initcode (#23847) (#318)
NazariiDenha May 18, 2023
b8d22a1
Add Archimedes hard fork block number for Scroll Alpha (#331)
Thegaram May 18, 2023
910d4f1
feat(trace): add storage proof about l1fee (baseFee, overhead, scalar…
noel2004 May 18, 2023
e5a6851
Merge branch 'scroll/v3.2.0' into morph_v1
FletcherMan May 19, 2023
8edec7f
Merge pull request #1 from morphism-labs/morph-scroll-v3.2.0
FletcherMan May 19, 2023
1094569
feat: enable eip and update check (#335)
NazariiDenha May 19, 2023
149419c
fix(trace): deletion proof missed path terminated by empty node (#330)
noel2004 May 22, 2023
a89ab83
fix(API): use `hexutil.Big` for `l1Fee` in `GetTransactionReceipt` (#…
mask-pp May 22, 2023
2f70857
refactor(config): moved fee vault addr to rollup config (#341)
rrzhang139 May 22, 2023
0c182f1
feat(abigen): add `--contract` flag to specify a given contract (#334)
mask-pp May 22, 2023
69cf63f
fix txs p2p && testnet scripts
FletcherMan May 23, 2023
fedb314
Merge scroll tag v3.2.4 into morphism (#9)
FletcherMan May 23, 2023
9f981c5
build(github): update github action yaml (#347)
0xmountaintop May 24, 2023
374b784
optimize block validation
FletcherMan May 24, 2023
fb570dc
ci(github): update pull request template (#349)
0xmountaintop May 24, 2023
334892a
Return error for disabled precompile calls (#337)
Thegaram May 24, 2023
060815e
feat: delay Archimedes on Alpha by a week (#342)
Thegaram May 24, 2023
31b754e
Fix transaction DA cost under-estimation (#332)
Thegaram May 24, 2023
ad43d0e
feat(block_validator): check payload size during block validation (#322)
rrzhang139 May 24, 2023
74725fb
test(zkTrie): add deletion test in account update unit test (#344)
colinlyguo May 25, 2023
302c315
Merge commits under tag of scroll-v3.3.0 from scroll-tech (#10)
FletcherMan May 25, 2023
9b943f3
fix: add missing term when merging two deletion proofs (#353)
noel2004 Jun 1, 2023
667cd5e
update docker image name
Jun 5, 2023
1f167bd
fix(ethclient): support WithdrawalsHash in Scroll Go SDK (#354)
rrzhang139 Jun 5, 2023
35e4bdc
update docker-compose
MarvelFisher Jun 6, 2023
4867699
fix(tracing): fix ZktrieTracer race condition (#356)
noel2004 Jun 7, 2023
983d630
feat: Sync and relay L1 messages (#350)
Thegaram Jun 7, 2023
b120a55
enable empty block
FletcherMan Jun 8, 2023
5721f01
add feeVaultAddress into default genesis
FletcherMan Jun 8, 2023
7aaaf83
update entrypoint and docker-compose conf for devops
MarvelFisher Jun 8, 2023
8ccf1ea
update entrypoint and docker-compose conf for devops (#12)
MarvelFisher Jun 8, 2023
37de1f4
add hash
FletcherMan Jun 9, 2023
1c4a88f
fix
FletcherMan Jun 9, 2023
4e0daeb
fix(trace): change l1Fee type from uint64 to *big.Int (#360)
Thegaram Jun 9, 2023
5067662
Integrate with the commits under tag scroll v4.1.0
FletcherMan Jun 12, 2023
f055f50
feat: update l1fee calculation (#351)
0xmountaintop Jun 13, 2023
9e9747e
Merge branch 'morph/v0.0.1' of github.com:morphism-labs/go-ethereum i…
MarvelFisher Jun 13, 2023
a3f03d7
update env for docker compose
MarvelFisher Jun 13, 2023
76dfeb9
update docker compose
MarvelFisher Jun 13, 2023
b5e8d12
feat: return keccak(chainId || height) for BLOCKHASH opcode (#359)
rrzhang139 Jun 14, 2023
db4946c
execute safe block
FletcherMan Jun 16, 2023
a4a63e7
add newSafeL2Block to api client
FletcherMan Jun 16, 2023
43be9a6
feat(abigen): Add flag let be able to add user tmpl file. (#362)
mask-pp Jun 19, 2023
b14a402
fix: improve L1Message RPC encoding (#368)
Thegaram Jun 19, 2023
02b4ad4
make baseFee unnecessary
FletcherMan Jun 25, 2023
1d91b84
merge commits under scroll tag v4.2.2
FletcherMan Jun 26, 2023
1201e3f
Merge pull request #16 from morphism-labs/morph-scroll-v4.2.2
FletcherMan Jun 26, 2023
9a7bdc2
fix block rlp encode issue
FletcherMan Jun 27, 2023
749014f
add testnet geth config file (#17)
MarvelFisher Jun 27, 2023
8590393
Morph testnet deploy v0.0.1 (#18)
MarvelFisher Jun 27, 2023
0e68e48
count fix
FletcherMan Jun 28, 2023
5abc15d
feat: update contract ABI QueueIndex type to uint64 (#371)
Thegaram Jun 28, 2023
e09346e
feat(core/vm): revert modexp precompiled contract if input is not u25…
NazariiDenha Jun 28, 2023
8c141eb
feat(evm): limit ecPairing precompile to use up to 4 inputs (#373)
Thegaram Jun 29, 2023
ee7b78d
change the predeploy contract address
FletcherMan Jun 30, 2023
38a6a1e
fix: include L1MessageTx fields in transaction RPC result (#375)
Thegaram Jun 30, 2023
d99c46c
Update entrypoint.sh (#19)
MarvelFisher Jul 3, 2023
e554e93
fix test compile error
FletcherMan Jul 3, 2023
3cf5ba8
feat(trace): add per_tx_storage_trace (#372)
0xmountaintop Jul 4, 2023
b9d37e7
add new func
FletcherMan Jul 5, 2023
8c5bf30
fix(trace): fix `statesAffected` in `traceLastNAddressAccount` (#367)
0xmountaintop Jul 7, 2023
2dcc60a
fix(trace): fix storage proof of l1gas price oracle (#376)
noel2004 Jul 7, 2023
7555d08
add withdrawTrieRoot
FletcherMan Jul 10, 2023
5eac3a7
feat(core/vm): modexp precompiled support also less than 32-bytes inp…
NazariiDenha Jul 10, 2023
3943547
feat(rawdb&rpc): add block row consumption rpc (#388)
NazariiDenha Jul 11, 2023
c8ae2f9
change withdrawTrieRootSlot to 45
FletcherMan Jul 13, 2023
2e8990d
add logs for debuging
FletcherMan Jul 11, 2023
0567d64
more logs
FletcherMan Jul 14, 2023
e481942
more logs
FletcherMan Jul 14, 2023
fe3f869
separat entrypoint for testnet (#20)
MarvelFisher Jul 17, 2023
09344b9
fix estimateGas issue. similar to ethereum PR:24363
FletcherMan Jul 18, 2023
a59522f
fix the KnownBlock issue
FletcherMan Jul 19, 2023
a677ee3
fix(ethapi): change scroll_getBlockByHash ethapi behaviour (#398)
NazariiDenha Jul 19, 2023
d31c9ae
fix newL2SafeBlock
FletcherMan Jul 21, 2023
935037f
make baseFeePerGas not Must
FletcherMan Jul 21, 2023
84cdc3d
merge commits under tag of scroll-v4.2.11
FletcherMan Jul 24, 2023
88e3871
Merge pull request #21 from morphism-labs/morph-scroll-v4.2.11
FletcherMan Jul 24, 2023
52c72a4
remove parentHash from safeL2Data
FletcherMan Jul 26, 2023
f361cd6
update run testnet shell (#22)
MarvelFisher Jul 27, 2023
9ea6be2
fix compile error testcase
FletcherMan Aug 1, 2023
6751a55
update run testnet shell (#23)
MarvelFisher Aug 2, 2023
5bf9755
improve
FletcherMan Aug 2, 2023
f1c0e46
Feature/testnet runner (#24)
MarvelFisher Aug 2, 2023
663db69
Feature/testnet runner (#25)
MarvelFisher Aug 2, 2023
1cd6610
blockSize gets length of txHash involved
FletcherMan Aug 4, 2023
08f2948
add script to run testnet sentry geth
Aug 11, 2023
f136a83
update l2node geth command with --nodiscover (#26)
MarvelFisher Aug 11, 2023
8017b7e
fix incompatible block hash (#27)
FletcherMan Aug 15, 2023
bd4a942
Feature/run testnet update (#28)
MarvelFisher Aug 22, 2023
f0d9f0f
Feature/run testnet update (#29)
MarvelFisher Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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>
  • Loading branch information
13 people authored Jun 12, 2023
commit 5067662fb2291b2c5ecb41d1700eff37da299cdc
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func setupGeth(stack *node.Node) error {
TrieDirtyCache: 16,
TrieTimeout: 60 * time.Minute,
SnapshotCache: 10,
})
}, nil)
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ var (
utils.GpoIgnoreGasPriceFlag,
utils.MinerNotifyFullFlag,
configFileFlag,
//>>>>>>> scroll/v4.1.0
utils.CatalystFlag,
}

rpcFlags = []cli.Flag{
Expand Down
6 changes: 6 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ var (
Usage: "InfluxDB organization name (v2 only)",
Value: metrics.DefaultConfig.InfluxDBOrganization,
}

CatalystFlag = cli.BoolFlag{
Name: "catalyst",
Usage: "Catalyst mode (eth2 integration testing)",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1767,6 +1772,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend))
return backend.ApiBackend, nil
}

backend, err := eth.New(stack, cfg)
if err != nil {
Fatalf("Failed to register the Ethereum service: %v", err)
Expand Down
6 changes: 5 additions & 1 deletion core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) {
return ErrKnownBlock
}
if !v.config.Scroll.IsValidTxCount(len(block.Transactions())) {
if !v.config.Scroll.IsValidL2TxCount(block.CountL2Tx()) {
return consensus.ErrInvalidTxCount
}
// Check if block payload size is smaller than the max size
if !v.config.Scroll.IsValidBlockSize(block.PayloadSize()) {
return ErrInvalidBlockPayloadSize
}
// Header validity is known at this point, check the uncles and transactions
header := block.Header()
if err := v.engine.VerifyUncles(v.bc, block); err != nil {
Expand Down
5 changes: 4 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@ func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (e
batch := bc.db.NewBatch()
rawdb.WriteTd(batch, block.Hash(), block.NumberU64(), td)
rawdb.WriteBlock(batch, block)

if err := batch.Write(); err != nil {
log.Crit("Failed to write block into disk", "err", err)
}
Expand Down Expand Up @@ -1221,6 +1222,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
rawdb.WriteBlock(blockBatch, block)
rawdb.WriteReceipts(blockBatch, block.Hash(), block.NumberU64(), receipts)
rawdb.WritePreimages(blockBatch, state.Preimages())

if err := blockBatch.Write(); err != nil {
log.Crit("Failed to write block into disk", "err", err)
}
Expand Down Expand Up @@ -2131,11 +2133,12 @@ Chain config: %v

Number: %v
Hash: 0x%x
ParentHash: 0x%x
%v

Error: %v
##############################
`, bc.chainConfig, block.Number(), block.Hash(), receiptString, err))
`, bc.chainConfig, block.Number(), block.Hash(), block.ParentHash(), receiptString, err))
}

// InsertHeaderChain attempts to insert the given header chain in to the local
Expand Down
105 changes: 83 additions & 22 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1747,8 +1747,8 @@ func TestInsertReceiptChainRollback(t *testing.T) {
// overtake the 'canon' chain until after it's passed canon by about 200 blocks.
//
// Details at:
// - https://github.com/scroll-tech/go-ethereum/issues/18977
// - https://github.com/scroll-tech/go-ethereum/pull/18988
// - https://github.com/scroll-tech/go-ethereum/issues/18977
// - https://github.com/scroll-tech/go-ethereum/pull/18988
func TestLowDiffLongChain(t *testing.T) {
// Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker()
Expand Down Expand Up @@ -1867,7 +1867,8 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
// That is: the sidechain for import contains some blocks already present in canon chain.
// So the blocks are
// [ Cn, Cn+1, Cc, Sn+3 ... Sm]
// ^ ^ ^ pruned
//
// ^ ^ ^ pruned
func TestPrunedImportSide(t *testing.T) {
//glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false)))
//glogger.Verbosity(3)
Expand Down Expand Up @@ -2472,9 +2473,9 @@ func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
// This internally leads to a sidechain import, since the blocks trigger an
// ErrPrunedAncestor error.
// This may e.g. happen if
// 1. Downloader rollbacks a batch of inserted blocks and exits
// 2. Downloader starts to sync again
// 3. The blocks fetched are all known and canonical blocks
// 1. Downloader rollbacks a batch of inserted blocks and exits
// 2. Downloader starts to sync again
// 3. The blocks fetched are all known and canonical blocks
func TestSideImportPrunedBlocks(t *testing.T) {
// Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker()
Expand Down Expand Up @@ -2636,20 +2637,19 @@ func TestDeleteCreateRevert(t *testing.T) {

// TestInitThenFailCreateContract tests a pretty notorious case that happened
// on mainnet over blocks 7338108, 7338110 and 7338115.
// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated
// with 0.001 ether (thus created but no code)
// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on
// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the
// deployment fails due to OOG during initcode execution
// - Block 7338115: another tx checks the balance of
// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as
// zero.
// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated
// with 0.001 ether (thus created but no code)
// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on
// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the
// deployment fails due to OOG during initcode execution
// - Block 7338115: another tx checks the balance of
// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as
// zero.
//
// The problem being that the snapshotter maintains a destructset, and adds items
// to the destructset in case something is created "onto" an existing item.
// We need to either roll back the snapDestructs, or not place it into snapDestructs
// in the first place.
//
func TestInitThenFailCreateContract(t *testing.T) {
var (
// Generate a canonical chain to act as the main dataset
Expand Down Expand Up @@ -2838,13 +2838,13 @@ func TestEIP2718Transition(t *testing.T) {

// TestEIP1559Transition tests the following:
//
// 1. A transaction whose gasFeeCap is greater than the baseFee is valid.
// 2. Gas accounting for access lists on EIP-1559 transactions is correct.
// 3. Only the transaction's tip will be received by the coinbase.
// 4. The transaction sender pays for both the tip and baseFee.
// 5. The coinbase receives only the partially realized tip when
// gasFeeCap - gasTipCap < baseFee.
// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap).
// 1. A transaction whose gasFeeCap is greater than the baseFee is valid.
// 2. Gas accounting for access lists on EIP-1559 transactions is correct.
// 3. Only the transaction's tip will be received by the coinbase.
// 4. The transaction sender pays for both the tip and baseFee.
// 5. The coinbase receives only the partially realized tip when
// gasFeeCap - gasTipCap < baseFee.
// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap).
func TestEIP1559Transition(t *testing.T) {
var (
aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")
Expand Down Expand Up @@ -3239,6 +3239,67 @@ func TestTransactionCountLimit(t *testing.T) {
}
}

func TestBlockPayloadSizeLimit(t *testing.T) {
// Create config that allows at most 150 bytes per block payload
config := params.TestChainConfig
config.Scroll.MaxTxPayloadBytesPerBlock = new(int)
*config.Scroll.MaxTxPayloadBytesPerBlock = 150
config.Scroll.MaxTxPerBlock = nil

var (
engine = ethash.NewFaker()
db = rawdb.NewMemoryDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(1000000000000000)
gspec = &Genesis{Config: config, Alloc: GenesisAlloc{address: {Balance: funds}}}
genesis = gspec.MustCommit(db)
)

addTx := func(b *BlockGen) {
tx := types.NewTransaction(b.TxNonce(address), address, big.NewInt(0), 50000, b.header.BaseFee, nil)
signed, _ := types.SignTx(tx, types.HomesteadSigner{}, key)
b.AddTx(signed)
}

// Initialize blockchain
blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil)
if err != nil {
t.Fatalf("failed to create new chain manager: %v", err)
}
defer blockchain.Stop()

// Insert empty block
block1, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
// empty
})

if _, err := blockchain.InsertChain(block1); err != nil {
t.Fatalf("failed to insert chain: %v", err)
}

// Insert block with 1 transaction
block2, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
addTx(b)
})

if _, err := blockchain.InsertChain(block2); err != nil {
t.Fatalf("failed to insert chain: %v", err)
}

// Insert block with 2 transactions
block3, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) {
addTx(b)
addTx(b)
})

_, err = blockchain.InsertChain(block3)

if !errors.Is(err, ErrInvalidBlockPayloadSize) {
t.Fatalf("error mismatch: have: %v, want: %v", err, ErrInvalidBlockPayloadSize)
}
}

func TestEIP3651(t *testing.T) {
var (
addraa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")
Expand Down
3 changes: 3 additions & 0 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var (
// ErrKnownBlock is returned when a block to import is already known locally.
ErrKnownBlock = errors.New("block already known")

// ErrInvalidBlockPayloadSize is returned when a block to import has an oversized payload.
ErrInvalidBlockPayloadSize = errors.New("invalid block payload size")

// ErrBannedHash is returned if a block to import is on the banned list.
ErrBannedHash = errors.New("banned hash")

Expand Down
8 changes: 4 additions & 4 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func (e *GenesisMismatchError) Error() string {
// SetupGenesisBlock writes or updates the genesis block in db.
// The block that will be used is:
//
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
//
// The stored chain configuration will be updated if it is compatible (i.e. does not
// specify a fork block below the local head block). In case of a conflict, the
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
databaseVersionKey, headHeaderKey, headBlockKey, headFastBlockKey, lastPivotKey,
fastTrieProgressKey, snapshotDisabledKey, SnapshotRootKey, snapshotJournalKey,
snapshotGeneratorKey, snapshotRecoveryKey, txIndexTailKey, fastTxLookupLimitKey,
uncleanShutdownKey, badBlockKey, skeletonSyncStatusKey,
uncleanShutdownKey, badBlockKey,
} {
if bytes.Equal(key, meta) {
metadata.Add(size)
Expand Down
2 changes: 2 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// no refunds for l1 messages
if st.msg.IsL1MessageTx() {
return &ExecutionResult{
// >>>>>>> scroll/v4.1.0
L1Fee: big.NewInt(0),
UsedGas: st.gasUsed(),
Err: vmerr,
ReturnData: ret,
Expand Down
3 changes: 2 additions & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ func (pool *TxPool) local() map[common.Address]types.Transactions {
// rules and adheres to some heuristic limits of the local node (price and size).
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// No unauthenticated deposits allowed in the transaction pool.
if tx.Type() == types.L1MessageTxType {
// >>>>>>> scroll/v4.1.0
if tx.IsL1MessageTx() {
return ErrTxTypeNotSupported
}

Expand Down
39 changes: 37 additions & 2 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ type Header struct {

// BLSData was the field specified for morphism
BLSData BLSData `json:"blsData" rlp:"optional"`
// >>>>>>> scroll/v4.1.0
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
// Included for Ethereum compatibility in Scroll SDK
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
}

// field type overrides for gencodec
Expand Down Expand Up @@ -216,8 +220,9 @@ type Block struct {
transactions Transactions

// caches
hash atomic.Value
size atomic.Value
hash atomic.Value
size atomic.Value
l1MsgCount atomic.Value

// Td is used by package core to store the total difficulty
// of the chain up to and including the block.
Expand Down Expand Up @@ -379,6 +384,16 @@ func (b *Block) Size() common.StorageSize {
return common.StorageSize(c)
}

// PayloadSize returns the sum of all transactions in a block.
func (b *Block) PayloadSize() common.StorageSize {
// add up all txs sizes
var totalSize common.StorageSize
for _, tx := range b.transactions {
totalSize += tx.Size()
}
return totalSize
}

// SanityCheck can be used to prevent that unbounded fields are
// stuffed with junk data to add processing overhead
func (b *Block) SanityCheck() error {
Expand Down Expand Up @@ -436,4 +451,24 @@ func (b *Block) Hash() common.Hash {
return v
}

// L1MessageCount returns the number of L1 messages in this block.
func (b *Block) L1MessageCount() int {
if l1MsgCount := b.l1MsgCount.Load(); l1MsgCount != nil {
return l1MsgCount.(int)
}
count := 0
for _, tx := range b.transactions {
if tx.IsL1MessageTx() {
count += 1
}
}
b.l1MsgCount.Store(count)
return count
}

// CountL2Tx returns the number of L2 transactions in this block.
func (b *Block) CountL2Tx() int {
return len(b.transactions) - b.L1MessageCount()
}

type Blocks []*Block
Loading