Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(all): changes based on protocol TaikoL1.getBlock() update #558

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
29b7d43eae8f85985178e87fb77184a41a0f7434
2607b5b027882d68cb7f6d423dc459d8083bdd3a
2 changes: 1 addition & 1 deletion bindings/gen_lib_proposing.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions bindings/gen_lib_verifying.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 28 additions & 13 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions driver/chain_syncer/beaconsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings/encoding"
Expand Down Expand Up @@ -102,11 +103,22 @@ func (s *Syncer) getVerifiedBlockPayload(ctx context.Context) (*big.Int, *engine
return nil, nil, err
}

blockInfo, err := s.rpc.TaikoL1.GetBlock(&bind.CallOpts{Context: ctx}, stateVars.B.LastVerifiedBlockId)
if err != nil {
return nil, nil, err
}

header, err := s.rpc.L2CheckPoint.HeaderByNumber(s.ctx, new(big.Int).SetUint64(stateVars.B.LastVerifiedBlockId))
if err != nil {
return nil, nil, err
}

if header.Hash() != blockInfo.Ts.BlockHash {
return nil, nil, fmt.Errorf(
"latest verified block hash mismatch: %s != %s", header.Hash(), common.BytesToHash(blockInfo.Ts.BlockHash[:]),
)
}

log.Info("Latest verified block header retrieved", "hash", header.Hash())

return new(big.Int).SetUint64(stateVars.B.LastVerifiedBlockId), encoding.ToExecutableData(header), nil
Expand Down
20 changes: 17 additions & 3 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,27 @@ func (s *Syncer) createExecutionPayloads(
return payload, nil
}

// checkLastVerifiedBlockMismatch checks if there is a mismatch between protocol's last verified block and
// the corresponding L2 EE block.
// checkLastVerifiedBlockMismatch checks if there is a mismatch between protocol's last verified block hash and
// the corresponding L2 EE block hash.
func (s *Syncer) checkLastVerifiedBlockMismatch(ctx context.Context) (bool, error) {
stateVars, err := s.rpc.GetProtocolStateVariables(&bind.CallOpts{Context: ctx})
if err != nil {
return false, err
}

return s.state.GetL2Head().Number.Uint64() < stateVars.B.LastVerifiedBlockId, nil
if s.state.GetL2Head().Number.Uint64() < stateVars.B.LastVerifiedBlockId {
return false, nil
}

blockInfo, err := s.rpc.TaikoL1.GetBlock(&bind.CallOpts{Context: ctx}, stateVars.B.LastVerifiedBlockId)
if err != nil {
return false, err
}

l2Header, err := s.rpc.L2.HeaderByNumber(ctx, new(big.Int).SetUint64(stateVars.B.LastVerifiedBlockId))
if err != nil {
return false, err
}

return blockInfo.Ts.BlockHash != l2Header.Hash(), nil
}
2 changes: 1 addition & 1 deletion driver/state/l1_current.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *State) ResetL1Current(
return err
}

l1Current, err := s.rpc.L1.HeaderByNumber(ctx, new(big.Int).SetUint64(blockInfo.ProposedIn))
l1Current, err := s.rpc.L1.HeaderByNumber(ctx, new(big.Int).SetUint64(blockInfo.Blk.ProposedIn))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (p *Proposer) sendProposeBlockTxWithBlobHash(
return nil, err
}

parentMetaHash = parent.MetaHash
parentMetaHash = parent.Blk.MetaHash
}

hookCalls := make([]encoding.HookCall, 0)
Expand Down Expand Up @@ -466,7 +466,7 @@ func (p *Proposer) sendProposeBlockTx(
return nil, err
}

parentMetaHash = parent.MetaHash
parentMetaHash = parent.Blk.MetaHash
}

hookCalls := make([]encoding.HookCall, 0)
Expand Down
2 changes: 1 addition & 1 deletion prover/proof_submitter/proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *ProofSubmitter) RequestProof(ctx context.Context, event *bindings.Taiko
L1SignalService: s.l1SignalService,
L2SignalService: s.l2SignalService,
TaikoL2: s.taikoL2Address,
MetaHash: blockInfo.MetaHash,
MetaHash: blockInfo.Blk.MetaHash,
BlockHash: block.Hash(),
ParentHash: block.ParentHash(),
StateRoot: l1Header.Root,
Expand Down
6 changes: 3 additions & 3 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ func (p *Prover) onTransitionContested(ctx context.Context, e *bindings.TaikoL1C
return err
}

return p.requestProofByBlockID(e.BlockId, new(big.Int).SetUint64(blockInfo.ProposedIn), e.Tier+1, nil)
return p.requestProofByBlockID(e.BlockId, new(big.Int).SetUint64(blockInfo.Blk.ProposedIn), e.Tier+1, nil)
}

// onBlockVerified update the latestVerified block in current state, and cancels
Expand Down Expand Up @@ -1013,14 +1013,14 @@ func (p *Prover) onTransitionProved(ctx context.Context, event *bindings.TaikoL1
log.Info(
"Contest a proven transition",
"blockID", event.BlockId,
"l1Height", blockInfo.ProposedIn,
"l1Height", blockInfo.Blk.ProposedIn,
"tier", event.Tier,
"parentHash", common.Bytes2Hex(event.Tran.ParentHash[:]),
"blockHash", common.Bytes2Hex(event.Tran.BlockHash[:]),
"stateRoot", common.Bytes2Hex(event.Tran.StateRoot[:]),
)

return p.requestProofByBlockID(event.BlockId, new(big.Int).SetUint64(blockInfo.ProposedIn), event.Tier, event)
return p.requestProofByBlockID(event.BlockId, new(big.Int).SetUint64(blockInfo.Blk.ProposedIn), event.Tier, event)
}

// Name returns the application name.
Expand Down
Loading