From a6ac896a2e8f4c7b81241b8c7ffb1215221f9154 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:06:16 +0800 Subject: [PATCH] rollup: add `rollup/withdrawtrie` package (#543) --- rollup/withdrawtrie/withdraw_trie.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rollup/withdrawtrie/withdraw_trie.go diff --git a/rollup/withdrawtrie/withdraw_trie.go b/rollup/withdrawtrie/withdraw_trie.go new file mode 100644 index 0000000000..22e51139a4 --- /dev/null +++ b/rollup/withdrawtrie/withdraw_trie.go @@ -0,0 +1,18 @@ +package withdrawtrie + +import ( + "github.com/scroll-tech/go-ethereum/common" + "github.com/scroll-tech/go-ethereum/rollup/rcfg" +) + +// StateDB represents the StateDB interface +// required to get withdraw trie root +type StateDB interface { + GetState(common.Address, common.Hash) common.Hash +} + +// ReadWTRSlot reads WithdrawTrieRoot slot in L2MessageQueue predeploy, i.e., `messageRoot` +// in contracts/src/libraries/common/AppendOnlyMerkleTree.sol +func ReadWTRSlot(addr common.Address, state StateDB) common.Hash { + return state.GetState(addr, rcfg.WithdrawTrieRootSlot) +}