Skip to content

Commit 1249d4e

Browse files
committed
fix block trace
1 parent d63fcec commit 1249d4e

File tree

4 files changed

+126
-257
lines changed

4 files changed

+126
-257
lines changed

consensus/ethash/consensus.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.H
590590
return nil
591591
}
592592

593-
func (ethash *Ethash) StartHook(chain consensus.ChainHeaderReader, header, preHeader *types.Header, state *state.StateDB) error {
593+
func (ethash *Ethash) StartHook(chain consensus.ChainHeaderReader, header, parentHeader *types.Header, state *state.StateDB) error {
594594
return nil
595595
}
596596

consensus/l2/consensus.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (l2 *Consensus) Prepare(chain consensus.ChainHeaderReader, header *types.He
219219
}
220220

221221
// StartHook implements calling before start apply transactions of block
222-
func (l2 *Consensus) StartHook(chain consensus.ChainHeaderReader, header, preHeader *types.Header, state *state.StateDB) error {
222+
func (l2 *Consensus) StartHook(chain consensus.ChainHeaderReader, header, parentHeader *types.Header, state *state.StateDB) error {
223223
cx := chainContext{Chain: chain, engine: l2.ethone}
224224
blockContext := core.NewEVMBlockContext(header, cx, l2.config, nil)
225225
// TODO tracer
@@ -228,7 +228,7 @@ func (l2 *Consensus) StartHook(chain consensus.ChainHeaderReader, header, preHea
228228
if err != nil {
229229
return err
230230
}
231-
data, err := stakingAbi.Pack("recordBlocks", preHeader.Coinbase)
231+
data, err := stakingAbi.Pack("recordBlocks", parentHeader.Coinbase)
232232
if err != nil {
233233
return err
234234
}

core/types/l2trace.go

+2-72
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type BlockTrace struct {
2020
Bytecodes []*BytecodeTrace `json:"codes"`
2121
TxStorageTraces []*StorageTrace `json:"txStorageTraces,omitempty"`
2222
ExecutionResults []*ExecutionResult `json:"executionResults"`
23+
StartHookResult *ExecutionResult `json:"startHookResult,omitempty"`
2324
WithdrawTrieRoot common.Hash `json:"withdraw_trie_root,omitempty"`
2425
SequencerSetVerifyHash common.Hash `json:"sequencer_set_verify_hash,omitempty"`
2526
StartL1QueueIndex uint64 `json:"startL1QueueIndex"`
@@ -115,75 +116,4 @@ type AccountWrapper struct {
115116
Balance *hexutil.Big `json:"balance"`
116117
KeccakCodeHash common.Hash `json:"keccakCodeHash,omitempty"`
117118
PoseidonCodeHash common.Hash `json:"poseidonCodeHash,omitempty"`
118-
CodeSize uint64 `json:"codeSize"`
119-
}
120-
121-
// StorageWrapper while key & value can also be retrieved from StructLogRes.Storage,
122-
// we still stored in here for roller's processing convenience.
123-
type StorageWrapper struct {
124-
Key string `json:"key,omitempty"`
125-
Value string `json:"value,omitempty"`
126-
}
127-
128-
type TransactionData struct {
129-
Type uint8 `json:"type"`
130-
Nonce uint64 `json:"nonce"`
131-
TxHash string `json:"txHash"`
132-
Gas uint64 `json:"gas"`
133-
GasPrice *hexutil.Big `json:"gasPrice"`
134-
GasTipCap *hexutil.Big `json:"gasTipCap"`
135-
GasFeeCap *hexutil.Big `json:"gasFeeCap"`
136-
From common.Address `json:"from"`
137-
To *common.Address `json:"to"`
138-
ChainId *hexutil.Big `json:"chainId"`
139-
Value *hexutil.Big `json:"value"`
140-
Data string `json:"data"`
141-
IsCreate bool `json:"isCreate"`
142-
AccessList AccessList `json:"accessList"`
143-
V *hexutil.Big `json:"v"`
144-
R *hexutil.Big `json:"r"`
145-
S *hexutil.Big `json:"s"`
146-
}
147-
148-
// NewTransactionData returns a transaction that will serialize to the trace
149-
// representation, with the given location metadata set (if available).
150-
func NewTransactionData(tx *Transaction, blockNumber uint64, config *params.ChainConfig) *TransactionData {
151-
signer := MakeSigner(config, big.NewInt(0).SetUint64(blockNumber))
152-
from, _ := Sender(signer, tx)
153-
v, r, s := tx.RawSignatureValues()
154-
155-
nonce := tx.Nonce()
156-
if tx.IsL1MessageTx() {
157-
nonce = tx.L1MessageQueueIndex()
158-
}
159-
160-
result := &TransactionData{
161-
Type: tx.Type(),
162-
TxHash: tx.Hash().String(),
163-
Nonce: nonce,
164-
ChainId: (*hexutil.Big)(tx.ChainId()),
165-
From: from,
166-
Gas: tx.Gas(),
167-
GasPrice: (*hexutil.Big)(tx.GasPrice()),
168-
GasTipCap: (*hexutil.Big)(tx.GasTipCap()),
169-
GasFeeCap: (*hexutil.Big)(tx.GasFeeCap()),
170-
To: tx.To(),
171-
Value: (*hexutil.Big)(tx.Value()),
172-
Data: hexutil.Encode(tx.Data()),
173-
IsCreate: tx.To() == nil,
174-
AccessList: tx.AccessList(),
175-
V: (*hexutil.Big)(v),
176-
R: (*hexutil.Big)(r),
177-
S: (*hexutil.Big)(s),
178-
}
179-
return result
180-
}
181-
182-
// WrapProof turn the bytes array into proof type (array of hexutil.Bytes)
183-
func WrapProof(proofBytes [][]byte) (wrappedProof []hexutil.Bytes) {
184-
wrappedProof = make([]hexutil.Bytes, len(proofBytes))
185-
for i, bt := range proofBytes {
186-
wrappedProof[i] = bt
187-
}
188-
return
189-
}
119+
CodeSize uint64 `

0 commit comments

Comments
 (0)