From f5b70a28b96729df167da2f33ce4928de67555bb Mon Sep 17 00:00:00 2001 From: Logan <80692353+jyc228@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:34:10 +0900 Subject: [PATCH] feat: add overhead and l1feescalar proofs to trace (#94) --- core/vm/logger.go | 8 ++++++++ eth/tracers/api_blocktrace.go | 1 + 2 files changed, 9 insertions(+) diff --git a/core/vm/logger.go b/core/vm/logger.go index 0b6a5e4af..7ea958c12 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -17,6 +17,7 @@ package vm import ( + "bytes" "encoding/hex" "encoding/json" "fmt" @@ -502,6 +503,13 @@ func (l *StructLogger) MaybeAddFeeRecipientsToStatesAffected(tx *types.Transacti } } +func (l *StructLogger) MaybeAddL1BlockInfo(tx *types.Transaction) { + if contractAddress := *tx.To(); bytes.Equal(contractAddress[:], types.L1BlockAddr[:]) { + l.storage[contractAddress][types.OverheadSlot] = l.env.StateDB.GetState(contractAddress, types.OverheadSlot) + l.storage[contractAddress][types.L1FeeScalarsSlot] = l.env.StateDB.GetState(contractAddress, types.L1FeeScalarsSlot) + } +} + // WriteTrace writes a formatted trace to the given writer // [Scroll: START] func WriteTrace(writer io.Writer, logs []*StructLog) { diff --git a/eth/tracers/api_blocktrace.go b/eth/tracers/api_blocktrace.go index 991a8e054..b8c277b70 100644 --- a/eth/tracers/api_blocktrace.go +++ b/eth/tracers/api_blocktrace.go @@ -262,6 +262,7 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc } tracer.MaybeAddFeeRecipientsToStatesAffected(tx) + tracer.MaybeAddL1BlockInfo(tx) // merge required proof data proofAccounts := tracer.UpdatedAccounts()