Commit 86632a52 authored by Joshua Gutow's avatar Joshua Gutow

op-node: Log on L1 Info deposit mismatch

parent 0bf643c4
...@@ -5,13 +5,16 @@ import ( ...@@ -5,13 +5,16 @@ import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
) )
// AttributesMatchBlock checks if the L2 attributes pre-inputs match the output // AttributesMatchBlock checks if the L2 attributes pre-inputs match the output
// nil if it is a match. If err is not nil, the error contains the reason for the mismatch // nil if it is a match. If err is not nil, the error contains the reason for the mismatch
func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash, block *eth.ExecutionPayload) error { func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash, block *eth.ExecutionPayload, l log.Logger) error {
if parentHash != block.ParentHash { if parentHash != block.ParentHash {
return fmt.Errorf("parent hash field does not match. expected: %v. got: %v", parentHash, block.ParentHash) return fmt.Errorf("parent hash field does not match. expected: %v. got: %v", parentHash, block.ParentHash)
} }
...@@ -26,6 +29,9 @@ func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash, ...@@ -26,6 +29,9 @@ func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash,
} }
for i, otx := range attrs.Transactions { for i, otx := range attrs.Transactions {
if expect := block.Transactions[i]; !bytes.Equal(otx, expect) { if expect := block.Transactions[i]; !bytes.Equal(otx, expect) {
if i == 0 {
logL1InfoTxns(l, uint64(block.BlockNumber), uint64(block.Timestamp), otx, block.Transactions[i])
}
return fmt.Errorf("transaction %d does not match. expected: %v. got: %v", i, expect, otx) return fmt.Errorf("transaction %d does not match. expected: %v. got: %v", i, expect, otx)
} }
} }
...@@ -37,3 +43,33 @@ func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash, ...@@ -37,3 +43,33 @@ func AttributesMatchBlock(attrs *eth.PayloadAttributes, parentHash common.Hash,
} }
return nil return nil
} }
// logL1InfoTxns reports the values from the L1 info tx when they differ to aid
// debugging. This check is the one that has been most frequently triggered.
func logL1InfoTxns(l log.Logger, l2Number, l2Timestamp uint64, safeTx, unsafeTx hexutil.Bytes) {
// First decode into *types.Transaction to get the tx data.
var safeTxValue, unsafeTxValue types.Transaction
errSafe := (&safeTxValue).UnmarshalBinary(safeTx)
errUnsafe := (&unsafeTxValue).UnmarshalBinary(unsafeTx)
if errSafe != nil || errUnsafe != nil {
l.Error("failed to umarshal tx", "errSafe", errSafe, "errUnsafe", errUnsafe)
}
// Then decode the ABI encoded parameters
var safeInfo, unsafeInfo L1BlockInfo
errSafe = (&safeInfo).UnmarshalBinary(safeTxValue.Data())
errUnsafe = (&unsafeInfo).UnmarshalBinary(unsafeTxValue.Data())
if errSafe != nil || errUnsafe != nil {
l.Error("failed to umarshal l1 info", "errSafe", errSafe, "errUnsafe", errUnsafe)
}
l.Error("L1 Info transaction differs", "number", l2Number, "time", l2Timestamp,
"safe_l1_number", safeInfo.Number, "safe_l1_hash", safeInfo.BlockHash,
"safe_l1_time", safeInfo.Time, "safe_seq_num", safeInfo.SequenceNumber,
"safe_l1_basefee", safeInfo.BaseFee, "safe_batcher_add", safeInfo.BlockHash,
"safe_gpo_scalar", safeInfo.L1FeeScalar, "safe_gpo_overhead", safeInfo.L1FeeOverhead,
"unsafe_l1_number", unsafeInfo.Number, "unsafe_l1_hash", unsafeInfo.BlockHash,
"unsafe_l1_time", unsafeInfo.Time, "unsafe_seq_num", unsafeInfo.SequenceNumber,
"unsafe_l1_basefee", unsafeInfo.BaseFee, "unsafe_batcher_add", unsafeInfo.BlockHash,
"unsafe_gpo_scalar", unsafeInfo.L1FeeScalar, "unsafe_gpo_overhead", unsafeInfo.L1FeeOverhead)
}
...@@ -422,7 +422,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error ...@@ -422,7 +422,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error
} }
return NewTemporaryError(fmt.Errorf("failed to get existing unsafe payload to compare against derived attributes from L1: %w", err)) return NewTemporaryError(fmt.Errorf("failed to get existing unsafe payload to compare against derived attributes from L1: %w", err))
} }
if err := AttributesMatchBlock(eq.safeAttributes[0], eq.safeHead.Hash, payload); err != nil { if err := AttributesMatchBlock(eq.safeAttributes[0], eq.safeHead.Hash, payload, eq.log); err != nil {
eq.log.Warn("L2 reorg: existing unsafe block does not match derived attributes from L1", "err", err) eq.log.Warn("L2 reorg: existing unsafe block does not match derived attributes from L1", "err", err)
// geth cannot wind back a chain without reorging to a new, previously non-canonical, block // geth cannot wind back a chain without reorging to a new, previously non-canonical, block
return eq.forceNextSafeAttributes(ctx) return eq.forceNextSafeAttributes(ctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment