diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 9e194df62d..d6a8852d56 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -1081,8 +1081,8 @@ func (b *Blockchain) verifyAgainstReference(block *core.Block, return nil } -func (b *Blockchain) validateStateDiff(shadowStateUpdate, pendingStateUpdate *core.StateUpdate) error { - _, diffFound := pendingStateUpdate.StateDiff.Diff(shadowStateUpdate.StateDiff, "sequencer", "sepolia") +func (b *Blockchain) validateStateDiff(refStateUpdate, pendingStateUpdate *core.StateUpdate) error { + _, diffFound := pendingStateUpdate.StateDiff.Diff(refStateUpdate.StateDiff, "sequencer", "sepolia") if diffFound { // Todo: make format nicely return fmt.Errorf("state diff validation failed") @@ -1090,96 +1090,96 @@ func (b *Blockchain) validateStateDiff(shadowStateUpdate, pendingStateUpdate *co return nil } -func (b *Blockchain) validateCommitments(shadowBlock *core.Block, shadowStateUpdate *core.StateUpdate, - sequenceCommitments *core.BlockCommitments, +func (b *Blockchain) validateCommitments(refBlock *core.Block, refStateUpdate *core.StateUpdate, + sequencedCommitments *core.BlockCommitments, ) error { - _, shadowCommitments, err := core.BlockHash(shadowBlock, shadowStateUpdate.StateDiff, b.network, nil) + _, refCommitments, err := core.BlockHash(refBlock, refStateUpdate.StateDiff, b.network, nil) if err != nil { - return fmt.Errorf("failed to compute the shadow commitments %s", err) + return fmt.Errorf("failed to compute the reference commitments %s", err) } - blockVer, err := core.ParseBlockVersion(shadowBlock.ProtocolVersion) + blockVer, err := core.ParseBlockVersion(refBlock.ProtocolVersion) if err != nil { return err } if blockVer.LessThan(semver.MustParse("0.13.2")) { // receipt commitment isn't needed for pre 0.13.2 blocks. see post07Hash(). - shadowCommitments.ReceiptCommitment = nil + refCommitments.ReceiptCommitment = nil } - if !shadowCommitments.TransactionCommitment.Equal(sequenceCommitments.TransactionCommitment) { - return fmt.Errorf("transaction commitment mismatch: shadow commitment %v, sequence commitment %v", - shadowCommitments.TransactionCommitment, sequenceCommitments.TransactionCommitment) + if !refCommitments.TransactionCommitment.Equal(sequencedCommitments.TransactionCommitment) { + return fmt.Errorf("transaction commitment mismatch: reference commitment %v, sequenced commitment %v", + refCommitments.TransactionCommitment, sequencedCommitments.TransactionCommitment) } - if !shadowCommitments.EventCommitment.Equal(sequenceCommitments.EventCommitment) { - return fmt.Errorf("event commitment mismatch: shadow commitment %v, sequence commitment %v", - shadowCommitments.EventCommitment, sequenceCommitments.EventCommitment) + if !refCommitments.EventCommitment.Equal(sequencedCommitments.EventCommitment) { + return fmt.Errorf("event commitment mismatch: reference commitment %v, sequenced commitment %v", + refCommitments.EventCommitment, sequencedCommitments.EventCommitment) } - if shadowCommitments.ReceiptCommitment != nil && !shadowCommitments.ReceiptCommitment.Equal(sequenceCommitments.ReceiptCommitment) { - return fmt.Errorf("receipt commitment mismatch: shadow commitment %v, sequence commitment %v", - shadowCommitments.ReceiptCommitment, sequenceCommitments.ReceiptCommitment) + if refCommitments.ReceiptCommitment != nil && !refCommitments.ReceiptCommitment.Equal(sequencedCommitments.ReceiptCommitment) { + return fmt.Errorf("receipt commitment mismatch: reference commitment %v, sequenced commitment %v", + refCommitments.ReceiptCommitment, sequencedCommitments.ReceiptCommitment) } - if shadowCommitments.StateDiffCommitment != nil && !shadowCommitments.StateDiffCommitment.Equal(sequenceCommitments.StateDiffCommitment) { - return fmt.Errorf("state diff commitment mismatch: shadow commitment %v, sequence commitment %v", - shadowCommitments.StateDiffCommitment, sequenceCommitments.StateDiffCommitment) + if refCommitments.StateDiffCommitment != nil && !refCommitments.StateDiffCommitment.Equal(sequencedCommitments.StateDiffCommitment) { + return fmt.Errorf("state diff commitment mismatch: reference commitment %v, sequenced commitment %v", + refCommitments.StateDiffCommitment, sequencedCommitments.StateDiffCommitment) } return nil } -func (b *Blockchain) validateHeader(shadowHeader, sequenceHeader *core.Header) error { - if !shadowHeader.ParentHash.Equal(sequenceHeader.ParentHash) { - return fmt.Errorf("parent hash mismatch: shadowHeader parent hash %v, sequenceHeader parent hash %v", - shadowHeader.ParentHash, sequenceHeader.ParentHash) +func (b *Blockchain) validateHeader(refHeader, sequenceHeader *core.Header) error { + if !refHeader.ParentHash.Equal(sequenceHeader.ParentHash) { + return fmt.Errorf("parent hash mismatch: reference header parent hash %v, sequenced header parent hash %v", + refHeader.ParentHash, sequenceHeader.ParentHash) } - if shadowHeader.Number != sequenceHeader.Number { - return fmt.Errorf("block number mismatch: shadowHeader number %v, sequenceHeader number %v", - shadowHeader.Number, sequenceHeader.Number) + if refHeader.Number != sequenceHeader.Number { + return fmt.Errorf("block number mismatch: reference header number %v, sequenced header number %v", + refHeader.Number, sequenceHeader.Number) } - if !shadowHeader.SequencerAddress.Equal(sequenceHeader.SequencerAddress) { - return fmt.Errorf("sequencer address mismatch: shadowHeader sequencer address %v, sequenceHeader sequencer address %v", - shadowHeader.SequencerAddress, sequenceHeader.SequencerAddress) + if !refHeader.SequencerAddress.Equal(sequenceHeader.SequencerAddress) { + return fmt.Errorf("sequencer address mismatch: reference header sequencer address %v, sequenced header sequencer address %v", + refHeader.SequencerAddress, sequenceHeader.SequencerAddress) } - if shadowHeader.TransactionCount != sequenceHeader.TransactionCount { - return fmt.Errorf("transaction count mismatch: shadowHeader transaction count %v, sequenceHeader transaction count %v", - shadowHeader.TransactionCount, sequenceHeader.TransactionCount) + if refHeader.TransactionCount != sequenceHeader.TransactionCount { + return fmt.Errorf("transaction count mismatch: reference header transaction count %v, sequenced header transaction count %v", + refHeader.TransactionCount, sequenceHeader.TransactionCount) } - if shadowHeader.EventCount != sequenceHeader.EventCount { - return fmt.Errorf("event count mismatch: shadowHeader event count %v, sequenceHeader event count %v", - shadowHeader.EventCount, sequenceHeader.EventCount) + if refHeader.EventCount != sequenceHeader.EventCount { + return fmt.Errorf("event count mismatch: reference header event count %v, sequenced header event count %v", + refHeader.EventCount, sequenceHeader.EventCount) } - if shadowHeader.Timestamp != sequenceHeader.Timestamp { - return fmt.Errorf("timestamp mismatch: shadowHeader timestamp %v, sequenceHeader timestamp %v", - shadowHeader.Timestamp, sequenceHeader.Timestamp) + if refHeader.Timestamp != sequenceHeader.Timestamp { + return fmt.Errorf("timestamp mismatch: reference header timestamp %v, sequenced header timestamp %v", + refHeader.Timestamp, sequenceHeader.Timestamp) } - if shadowHeader.ProtocolVersion != sequenceHeader.ProtocolVersion { - return fmt.Errorf("protocol version mismatch: shadowHeader protocol version %v, sequenceHeader protocol version %v", - shadowHeader.ProtocolVersion, sequenceHeader.ProtocolVersion) + if refHeader.ProtocolVersion != sequenceHeader.ProtocolVersion { + return fmt.Errorf("protocol version mismatch: reference header protocol version %v, sequenced header protocol version %v", + refHeader.ProtocolVersion, sequenceHeader.ProtocolVersion) } - if !shadowHeader.GasPrice.Equal(sequenceHeader.GasPrice) { - return fmt.Errorf("gas price mismatch: shadowHeader gas price %v, sequenceHeader gas price %v", - shadowHeader.GasPrice, sequenceHeader.GasPrice) + if !refHeader.GasPrice.Equal(sequenceHeader.GasPrice) { + return fmt.Errorf("gas price mismatch: reference header gas price %v, sequenced header gas price %v", + refHeader.GasPrice, sequenceHeader.GasPrice) } - if !shadowHeader.GasPriceSTRK.Equal(sequenceHeader.GasPriceSTRK) { - return fmt.Errorf("gas price STRK mismatch: shadowHeader gas price STRK %v, sequenceHeader gas price STRK %v", - shadowHeader.GasPriceSTRK, sequenceHeader.GasPriceSTRK) + if !refHeader.GasPriceSTRK.Equal(sequenceHeader.GasPriceSTRK) { + return fmt.Errorf("gas price STRK mismatch: reference header gas price STRK %v, sequenced header gas price STRK %v", + refHeader.GasPriceSTRK, sequenceHeader.GasPriceSTRK) } - if shadowHeader.L1DAMode != sequenceHeader.L1DAMode { - return fmt.Errorf("L1 data availability mode mismatch: shadowHeader L1DAMode %v, sequenceHeader L1DAMode %v", - shadowHeader.L1DAMode, sequenceHeader.L1DAMode) + if refHeader.L1DAMode != sequenceHeader.L1DAMode { + return fmt.Errorf("L1 data availability mode mismatch: reference header L1DAMode %v, sequenced header L1DAMode %v", + refHeader.L1DAMode, sequenceHeader.L1DAMode) } - if !shadowHeader.L1DataGasPrice.PriceInFri.Equal(sequenceHeader.L1DataGasPrice.PriceInFri) { - return fmt.Errorf("L1 data gas PriceInFri mismatch: shadowHeader L1DataGasPrice %v, sequenceHeader L1DataGasPrice %v", - shadowHeader.L1DataGasPrice, sequenceHeader.L1DataGasPrice) + if !refHeader.L1DataGasPrice.PriceInFri.Equal(sequenceHeader.L1DataGasPrice.PriceInFri) { + return fmt.Errorf("L1 data gas PriceInFri mismatch: reference header L1DataGasPrice %v, sequenced header L1DataGasPrice %v", + refHeader.L1DataGasPrice, sequenceHeader.L1DataGasPrice) } - if !shadowHeader.L1DataGasPrice.PriceInWei.Equal(sequenceHeader.L1DataGasPrice.PriceInWei) { - return fmt.Errorf("L1 data gas PriceInFri mismatch: shadowHeader L1DataGasPrice %v, sequenceHeader L1DataGasPrice %v", - shadowHeader.L1DataGasPrice, sequenceHeader.L1DataGasPrice) + if !refHeader.L1DataGasPrice.PriceInWei.Equal(sequenceHeader.L1DataGasPrice.PriceInWei) { + return fmt.Errorf("L1 data gas PriceInFri mismatch: reference header L1DataGasPrice %v, sequenced header L1DataGasPrice %v", + refHeader.L1DataGasPrice, sequenceHeader.L1DataGasPrice) } - if !shadowHeader.GlobalStateRoot.Equal(sequenceHeader.GlobalStateRoot) { - return fmt.Errorf("global state root mismatch: shadowHeader global state root %v, sequenceHeader global state root %v", - shadowHeader.GlobalStateRoot, sequenceHeader.GlobalStateRoot) + if !refHeader.GlobalStateRoot.Equal(sequenceHeader.GlobalStateRoot) { + return fmt.Errorf("global state root mismatch: reference header global state root %v, sequenced header global state root %v", + refHeader.GlobalStateRoot, sequenceHeader.GlobalStateRoot) } - if !shadowHeader.Hash.Equal(sequenceHeader.Hash) { - return fmt.Errorf("hash mismatch: shadowHeader hash %v, sequenceHeader hash %v", shadowHeader.Hash, sequenceHeader.Hash) + if !refHeader.Hash.Equal(sequenceHeader.Hash) { + return fmt.Errorf("hash mismatch: reference header hash %v, sequenced header hash %v", refHeader.Hash, sequenceHeader.Hash) } return nil } diff --git a/builder/builder.go b/builder/builder.go index 22b36e0265..1926a1372c 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -249,7 +249,7 @@ func (b *Builder) runShadowMode(ctx context.Context) error { go func() { if pErr := b.shadowTxns(ctx); pErr != nil { - b.log.Errorw("shadowTxns", "err", pErr) + b.log.Errorw("shadowing transactions", "err", pErr) } }()