Skip to content

Commit

Permalink
[FEATURE]Morphism geth implementation (#3)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
22 people committed Aug 28, 2023
1 parent 419c354 commit 2e7b3ed
Show file tree
Hide file tree
Showing 231 changed files with 28,365 additions and 4,813 deletions.
3 changes: 3 additions & 0 deletions .env
@@ -0,0 +1,3 @@
GETH_DATA_DIR=/db
GENESIS_FILE_PATH=/genesis.json
JWT_SECRET_PATH=/jwt-secret.txt
34 changes: 34 additions & 0 deletions .github/pull_request_template.md
@@ -0,0 +1,34 @@
## 1. Purpose or design rationale of this PR

...


## 2. PR title

Your PR title must follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) (as we are doing squash merge for each PR), so it must start with one of the following [types](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#type):

- [ ] build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
- [ ] ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
- [ ] docs: Documentation-only changes
- [ ] feat: A new feature
- [ ] fix: A bug fix
- [ ] perf: A code change that improves performance
- [ ] refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
- [ ] style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- [ ] test: Adding missing tests or correcting existing tests


## 3. Deployment tag versioning

Has the version in `params/version.go` been updated?

- [ ] This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
- [ ] Yes


## 4. Breaking change label

Does this PR have the `breaking-change` label?

- [ ] This PR is not a breaking change
- [ ] Yes
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Expand Up @@ -3,7 +3,7 @@ name: Docker
on:
push:
tags:
- scroll-v**
- '*'

jobs:
build-and-push:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/l2geth_ci.yml
Expand Up @@ -6,9 +6,15 @@ on:
- develop
- alpha
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
name: CI
jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand All @@ -21,6 +27,7 @@ jobs:
run: |
make geth
check:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand All @@ -34,6 +41,7 @@ jobs:
rm -rf $HOME/.cache/golangci-lint
make lint
goimports-lint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand All @@ -53,6 +61,7 @@ jobs:
exit 1
fi
test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -47,3 +47,4 @@ profile.cov
/dashboard/assets/package-lock.json

**/yarn-error.log
/build/db*/
17 changes: 5 additions & 12 deletions Dockerfile
@@ -1,8 +1,3 @@
# Support setting various labels on the final image
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""

# Build Geth in a stock Go builder container
FROM golang:1.18-alpine as builder

Expand All @@ -16,13 +11,11 @@ FROM alpine:latest

RUN apk add --no-cache ca-certificates
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
COPY entrypoint.sh /entrypoint.sh

VOLUME ["/db"]

EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]

# Add some metadata labels to help programatic image consumption
ARG COMMIT=""
ARG VERSION=""
ARG BUILDNUM=""
EXPOSE 8545 8546 8551 30303 30303/udp

LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM"
18 changes: 18 additions & 0 deletions Makefile
Expand Up @@ -52,3 +52,21 @@ devtools:
env GOBIN= go install ./cmd/abigen
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'


testnet-up:
docker-compose -f testnet/docker-compose.yml up -d
.PHONY: testnet-up

testnet-down:
docker-compose -f testnet/docker-compose.yml down
.PHONY: testnet-down

testnet-clean:
docker-compose -f testnet/docker-compose.yml down
docker images -q morphism_geth:latest | xargs -r docker rmi
docker volume ls --filter "name=morph_data*" -q | xargs -r docker volume rm
.PHONY: testnet-clean

image:
docker build -f Dockerfile -t morphism-geth:latest .
93 changes: 92 additions & 1 deletion accounts/abi/bind/backends/simulated.go
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/common/hexutil"
"github.com/scroll-tech/go-ethereum/common/math"
"github.com/scroll-tech/go-ethereum/consensus"
"github.com/scroll-tech/go-ethereum/consensus/ethash"
"github.com/scroll-tech/go-ethereum/core"
"github.com/scroll-tech/go-ethereum/core/bloombits"
Expand All @@ -42,6 +43,7 @@ import (
"github.com/scroll-tech/go-ethereum/event"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/fees"
"github.com/scroll-tech/go-ethereum/rpc"
)

Expand All @@ -63,6 +65,8 @@ type SimulatedBackend struct {
database ethdb.Database // In memory database to store our testing data
blockchain *core.BlockChain // Ethereum blockchain to handle the consensus

consensus consensus.Engine

mu sync.Mutex
pendingBlock *types.Block // Currently pending block that will be imported on request
pendingState *state.StateDB // Currently pending state that will be the active on request
Expand Down Expand Up @@ -97,6 +101,87 @@ func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBac
return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit)
}

type simulatedBackendConfig struct {
genesis core.Genesis
cacheConfig *core.CacheConfig
database ethdb.Database
vmConfig vm.Config
consensus consensus.Engine
}

type SimulatedBackendOpt func(s *simulatedBackendConfig)

func WithDatabase(database ethdb.Database) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.database = database
}
}

func WithGasLimit(gasLimit uint64) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.genesis.GasLimit = gasLimit
}
}

func WithAlloc(alloc core.GenesisAlloc) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.genesis.Alloc = alloc
}
}

func WithCacheConfig(cacheConfig *core.CacheConfig) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.cacheConfig = cacheConfig
}
}

func WithGenesis(genesis core.Genesis) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.genesis = genesis
}
}

func WithVMConfig(vmConfig vm.Config) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.vmConfig = vmConfig
}
}

func WithConsensus(consensus consensus.Engine) SimulatedBackendOpt {
return func(s *simulatedBackendConfig) {
s.consensus = consensus
}
}

// NewSimulatedBackendWithOpts creates a new binding backend based on the given database
// and uses a simulated blockchain for testing purposes. It exposes additional configuration
// options that are useful to
func NewSimulatedBackendWithOpts(opts ...SimulatedBackendOpt) *SimulatedBackend {
config := &simulatedBackendConfig{
genesis: core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: 100000000, Alloc: make(core.GenesisAlloc)},
database: rawdb.NewMemoryDatabase(),
consensus: ethash.NewFaker(),
}

for _, opt := range opts {
opt(config)
}

config.genesis.MustCommit(config.database)
blockchain, _ := core.NewBlockChain(config.database, config.cacheConfig, config.genesis.Config, config.consensus, config.vmConfig, nil, nil)

backend := &SimulatedBackend{
database: config.database,
blockchain: blockchain,
config: config.genesis.Config,
consensus: config.consensus,
events: filters.NewEventSystem(&filterBackend{config.database, blockchain}, false),
}

backend.rollback(blockchain.CurrentBlock())
return backend
}

// Close terminates the underlying blockchain's update loop.
func (b *SimulatedBackend) Close() error {
b.blockchain.Stop()
Expand Down Expand Up @@ -638,8 +723,13 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// about the transaction and calling mechanisms.
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true})
gasPool := new(core.GasPool).AddGas(math.MaxUint64)
signer := types.MakeSigner(b.blockchain.Config(), head.Number)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, head.BaseFee, b.blockchain.Config().ChainID, signer, stateDB)
if err != nil {
return nil, err
}

return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb()
return core.NewStateTransition(vmEnv, msg, gasPool, l1DataFee).TransitionDb()
}

// SendTransaction updates the pending block to include the given transaction.
Expand Down Expand Up @@ -814,6 +904,7 @@ func (m callMsg) Gas() uint64 { return m.CallMsg.Gas }
func (m callMsg) Value() *big.Int { return m.CallMsg.Value }
func (m callMsg) Data() []byte { return m.CallMsg.Data }
func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
func (m callMsg) IsL1MessageTx() bool { return false }

// filterBackend implements filters.Backend to support filtering for logs without
// taking bloom-bits acceleration structures into account.
Expand Down
7 changes: 7 additions & 0 deletions accounts/abi/bind/template.go
Expand Up @@ -79,6 +79,13 @@ var tmplSource = map[Lang]string{
LangJava: tmplSourceJava,
}

// SetTmplSource supports this func in order to set special template file.
func SetTmplSource(lang Lang, source string) {
if _, ok := tmplSource[lang]; ok {
tmplSource[lang] = source
}
}

// tmplSourceGo is the Go source template that the generated Go contract binding
// is based on.
const tmplSourceGo = `
Expand Down
1 change: 1 addition & 0 deletions build/jwt-secret.txt
@@ -0,0 +1 @@
688f5d737bad920bdfb2fc2f488d6b6209eebda1dae949a8de91398d932c517a
31 changes: 28 additions & 3 deletions cmd/abigen/main.go
Expand Up @@ -99,6 +99,14 @@ var (
Name: "alias",
Usage: "Comma separated aliases for function and event renaming, e.g. original1=alias1, original2=alias2",
}
contractFlag = cli.StringFlag{
Name: "contract",
Usage: "Name of the contract to generate the bindings for",
}
tmplFlag = cli.StringFlag{
Name: "tmpl",
Usage: "Template file if a user wants to customize",
}
)

func init() {
Expand All @@ -117,6 +125,8 @@ func init() {
outFlag,
langFlag,
aliasFlag,
contractFlag,
tmplFlag,
}
app.Action = utils.MigrateFlags(abigen)
cli.CommandHelpTemplate = flags.OriginCommandHelpTemplate
Expand Down Expand Up @@ -225,6 +235,13 @@ func abigen(c *cli.Context) error {
}
// Gather all non-excluded contract for binding
for name, contract := range contracts {
// The fully qualified name is of the form <solFilePath>:<type>
nameParts := strings.Split(name, ":")
typeName := nameParts[len(nameParts)-1]
// If a contract name is provided then ignore all other contracts
if c.GlobalIsSet(contractFlag.Name) && c.GlobalString(contractFlag.Name) != typeName {
continue
}
if exclude[strings.ToLower(name)] {
continue
}
Expand All @@ -235,11 +252,10 @@ func abigen(c *cli.Context) error {
abis = append(abis, string(abi))
bins = append(bins, contract.Code)
sigs = append(sigs, contract.Hashes)
nameParts := strings.Split(name, ":")
types = append(types, nameParts[len(nameParts)-1])
types = append(types, typeName)

libPattern := crypto.Keccak256Hash([]byte(name)).String()[2:36]
libs[libPattern] = nameParts[len(nameParts)-1]
libs[libPattern] = typeName
}
}
// Extract all aliases from the flags
Expand All @@ -254,6 +270,15 @@ func abigen(c *cli.Context) error {
aliases[match[1]] = match[2]
}
}
// Set customize template file.
if c.GlobalIsSet(tmplFlag.Name) {
tmplFile := c.GlobalString(tmplFlag.Name)
data, err := os.ReadFile(tmplFile)
if err != nil {
utils.Fatalf("Failed to read template file: %v", err)
}
bind.SetTmplSource(lang, string(data))
}
// Generate the contract binding
code, err := bind.Bind(types, abis, bins, sigs, c.GlobalString(pkgFlag.Name), lang, libs, aliases)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Expand Up @@ -662,7 +662,7 @@ func signer(c *cli.Context) error {
if err != nil {
utils.Fatalf("Could not register API: %w", err)
}
handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)

// set port
port := c.Int(rpcPortFlag.Name)
Expand Down
8 changes: 8 additions & 0 deletions cmd/devp2p/internal/ethtest/chain.go
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"strings"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core"
"github.com/scroll-tech/go-ethereum/core/forkid"
"github.com/scroll-tech/go-ethereum/core/types"
Expand Down Expand Up @@ -67,6 +68,13 @@ func (c *Chain) TotalDifficultyAt(height int) *big.Int {
return sum
}

func (c *Chain) RootAt(height int) common.Hash {
if height < c.Len() {
return c.blocks[height].Root()
}
return common.Hash{}
}

// ForkID gets the fork id of the chain.
func (c *Chain) ForkID() forkid.ID {
return forkid.NewID(c.chainConfig, c.blocks[0].Hash(), uint64(c.Len()))
Expand Down

0 comments on commit 2e7b3ed

Please sign in to comment.