mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 07:53:47 +00:00
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>
This commit is contained in:
parent
b8d22a104d
commit
910d4f1a70
2 changed files with 38 additions and 1 deletions
|
|
@ -290,6 +290,8 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc
|
||||||
|
|
||||||
// merge required proof data
|
// merge required proof data
|
||||||
proofAccounts := tracer.UpdatedAccounts()
|
proofAccounts := tracer.UpdatedAccounts()
|
||||||
|
proofAccounts[vmenv.FeeRecipient()] = struct{}{}
|
||||||
|
proofAccounts[rcfg.L1GasPriceOracleAddress] = struct{}{}
|
||||||
for addr := range proofAccounts {
|
for addr := range proofAccounts {
|
||||||
addrStr := addr.String()
|
addrStr := addr.String()
|
||||||
|
|
||||||
|
|
@ -314,6 +316,12 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc
|
||||||
}
|
}
|
||||||
|
|
||||||
proofStorages := tracer.UpdatedStorages()
|
proofStorages := tracer.UpdatedStorages()
|
||||||
|
proofStorages[rcfg.L1GasPriceOracleAddress] = vm.Storage(
|
||||||
|
map[common.Hash]common.Hash{
|
||||||
|
rcfg.L1BaseFeeSlot: {}, // notice we do not need the right value here
|
||||||
|
rcfg.OverheadSlot: {},
|
||||||
|
rcfg.ScalarSlot: {},
|
||||||
|
})
|
||||||
for addr, keys := range proofStorages {
|
for addr, keys := range proofStorages {
|
||||||
env.sMu.Lock()
|
env.sMu.Lock()
|
||||||
trie, err := state.GetStorageTrieForProof(addr)
|
trie, err := state.GetStorageTrieForProof(addr)
|
||||||
|
|
@ -404,6 +412,35 @@ func (api *API) fillBlockTrace(env *traceEnv, block *types.Block) (*types.BlockT
|
||||||
txs[i] = types.NewTransactionData(tx, block.NumberU64(), api.backend.ChainConfig())
|
txs[i] = types.NewTransactionData(tx, block.NumberU64(), api.backend.ChainConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, existed := env.Proofs[rcfg.L2MessageQueueAddress.String()]; !existed {
|
||||||
|
if proof, err := statedb.GetProof(rcfg.L2MessageQueueAddress); err != nil {
|
||||||
|
log.Error("Proof for L2MessageQueueAddress not available", "error", err)
|
||||||
|
} else {
|
||||||
|
wrappedProof := make([]hexutil.Bytes, len(proof))
|
||||||
|
for i, bt := range proof {
|
||||||
|
wrappedProof[i] = bt
|
||||||
|
}
|
||||||
|
env.Proofs[rcfg.L2MessageQueueAddress.String()] = wrappedProof
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, existed := env.StorageProofs[rcfg.L2MessageQueueAddress.String()]; !existed {
|
||||||
|
env.StorageProofs[rcfg.L2MessageQueueAddress.String()] = make(map[string][]hexutil.Bytes)
|
||||||
|
}
|
||||||
|
if _, existed := env.StorageProofs[rcfg.L2MessageQueueAddress.String()][rcfg.WithdrawTrieRootSlot.String()]; !existed {
|
||||||
|
if trie, err := statedb.GetStorageTrieForProof(rcfg.L2MessageQueueAddress); err != nil {
|
||||||
|
log.Error("Storage proof for WithdrawTrieRootSlot not available", "error", err)
|
||||||
|
} else if proof, _ := statedb.GetSecureTrieProof(trie, rcfg.WithdrawTrieRootSlot); err != nil {
|
||||||
|
log.Error("Get storage proof for WithdrawTrieRootSlot failed", "error", err)
|
||||||
|
} else {
|
||||||
|
wrappedProof := make([]hexutil.Bytes, len(proof))
|
||||||
|
for i, bt := range proof {
|
||||||
|
wrappedProof[i] = bt
|
||||||
|
}
|
||||||
|
env.StorageProofs[rcfg.L2MessageQueueAddress.String()][rcfg.WithdrawTrieRootSlot.String()] = wrappedProof
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blockTrace := &types.BlockTrace{
|
blockTrace := &types.BlockTrace{
|
||||||
ChainID: api.backend.ChainConfig().ChainID.Uint64(),
|
ChainID: api.backend.ChainConfig().ChainID.Uint64(),
|
||||||
Version: params.ArchiveVersion(params.CommitHash),
|
Version: params.ArchiveVersion(params.CommitHash),
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 3 // Major version component of the current release
|
VersionMajor = 3 // Major version component of the current release
|
||||||
VersionMinor = 2 // Minor version component of the current release
|
VersionMinor = 2 // Minor version component of the current release
|
||||||
VersionPatch = 0 // Patch version component of the current release
|
VersionPatch = 1 // Patch version component of the current release
|
||||||
VersionMeta = "alpha" // Version metadata to append to the version string
|
VersionMeta = "alpha" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue