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

Commit

Permalink
feat(bindings): update contract bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jul 10, 2023
1 parent e190146 commit 27ec1dd
Show file tree
Hide file tree
Showing 18 changed files with 297 additions and 252 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
05da0e721aeecf38c9551bad6e1e763e485e4840
f8415a2f73e8a3cdc354a519b5c5af02e715fbf4
242 changes: 133 additions & 109 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions bindings/gen_taiko_l2.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion driver/anchor_tx_constructor/anchor_tx_constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *AnchorTxConstructor) AssembleAnchorTx(
"gasUsed", parentGasUsed,
)

return c.rpc.TaikoL2.Anchor(opts, l1Hash, signalRoot, l1Height.Uint64(), parentGasUsed)
return c.rpc.TaikoL2.Anchor(opts, l1Hash, signalRoot, l1Height.Uint64(), uint32(parentGasUsed))
}

// transactOpts is a utility method to create some transact options of the anchor transaction in given L2 block with
Expand Down
32 changes: 16 additions & 16 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *Syncer) onBlockProposed(
event *bindings.TaikoL1ClientBlockProposed,
endIter eventIterator.EndBlockProposedEventIterFunc,
) error {
if event.Id.Cmp(common.Big0) == 0 {
if event.BlockId.Cmp(common.Big0) == 0 {
return nil
}

Expand Down Expand Up @@ -140,7 +140,7 @@ func (s *Syncer) onBlockProposed(
} else {
reorged, l1CurrentToReset, lastInsertedBlockIDToReset, err = s.rpc.CheckL1Reorg(
ctx,
new(big.Int).Sub(event.Id, common.Big1),
new(big.Int).Sub(event.BlockId, common.Big1),
)
if err != nil {
return fmt.Errorf("failed to check whether L1 chain has been reorged: %w", err)
Expand All @@ -167,15 +167,15 @@ func (s *Syncer) onBlockProposed(
}

// Ignore those already inserted blocks.
if s.lastInsertedBlockID != nil && event.Id.Cmp(s.lastInsertedBlockID) <= 0 {
if s.lastInsertedBlockID != nil && event.BlockId.Cmp(s.lastInsertedBlockID) <= 0 {
return nil
}

log.Info(
"New BlockProposed event",
"L1Height", event.Raw.BlockNumber,
"L1Hash", event.Raw.BlockHash,
"BlockID", event.Id,
"BlockID", event.BlockId,
"Removed", event.Raw.Removed,
)

Expand All @@ -186,13 +186,13 @@ func (s *Syncer) onBlockProposed(
)
if s.progressTracker.Triggered() {
// Already synced through beacon sync, just skip this event.
if event.Id.Cmp(s.progressTracker.LastSyncedVerifiedBlockID()) <= 0 {
if event.BlockId.Cmp(s.progressTracker.LastSyncedVerifiedBlockID()) <= 0 {
return nil
}

parent, err = s.rpc.L2.HeaderByHash(ctx, s.progressTracker.LastSyncedVerifiedBlockHash())
} else {
parent, err = s.rpc.L2ParentByBlockId(ctx, event.Id)
parent, err = s.rpc.L2ParentByBlockId(ctx, event.BlockId)
}

if err != nil {
Expand All @@ -211,20 +211,20 @@ func (s *Syncer) onBlockProposed(
}

// Check whether the transactions list is valid.
txListBytes, hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.Id, tx.Data())
txListBytes, hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.BlockId, tx.Data())
if err != nil {
return fmt.Errorf("failed to validate transactions list: %w", err)
}

log.Info(
"Validate transactions list",
"blockID", event.Id,
"blockID", event.BlockId,
"hint", hint,
"invalidTxIndex", invalidTxIndex,
)

l1Origin := &rawdb.L1Origin{
BlockID: event.Id,
BlockID: event.BlockId,
L2BlockHash: common.Hash{}, // Will be set by taiko-geth.
L1BlockHeight: new(big.Int).SetUint64(event.Raw.BlockNumber),
L1BlockHash: event.Raw.BlockHash,
Expand All @@ -237,7 +237,7 @@ func (s *Syncer) onBlockProposed(

// If the transactions list is invalid, we simply insert an empty L2 block.
if hint != txListValidator.HintOK {
log.Info("Invalid transactions list, insert an empty L2 block instead", "blockID", event.Id)
log.Info("Invalid transactions list, insert an empty L2 block instead", "blockID", event.BlockId)
txListBytes = []byte{}
}

Expand All @@ -258,7 +258,7 @@ func (s *Syncer) onBlockProposed(

log.Info(
"🔗 New L2 block inserted",
"blockID", event.Id,
"blockID", event.BlockId,
"height", payloadData.Number,
"hash", payloadData.BlockHash,
"latestVerifiedBlockID", s.state.GetLatestVerifiedBlock().ID,
Expand All @@ -269,7 +269,7 @@ func (s *Syncer) onBlockProposed(
)

metrics.DriverL1CurrentHeightGauge.Update(int64(event.Raw.BlockNumber))
s.lastInsertedBlockID = event.Id
s.lastInsertedBlockID = event.BlockId

if s.progressTracker.Triggered() {
s.progressTracker.ClearMeta()
Expand Down Expand Up @@ -300,7 +300,7 @@ func (s *Syncer) insertNewHead(
var txList []*types.Transaction
if len(txListBytes) != 0 {
if err := rlp.DecodeBytes(txListBytes, &txList); err != nil {
log.Error("Invalid txList bytes", "blockID", event.Id)
log.Error("Invalid txList bytes", "blockID", event.BlockId)
return nil, err
}
}
Expand All @@ -314,8 +314,8 @@ func (s *Syncer) insertNewHead(
baseFee, err := s.rpc.TaikoL2.GetBasefee(
&bind.CallOpts{BlockNumber: parent.Number},
uint32(event.Meta.Timestamp-parentTimestamp),
uint64(event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit())),
parent.GasUsed,
uint32(event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit())),

Check failure on line 317 in driver/chain_syncer/calldata/syncer.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary conversion (unconvert)
uint32(parent.GasUsed),
)
if err != nil {
return nil, fmt.Errorf("failed to get L2 baseFee: %w", encoding.TryParsingCustomError(err))
Expand Down Expand Up @@ -351,7 +351,7 @@ func (s *Syncer) insertNewHead(
txList = append([]*types.Transaction{anchorTx}, txList...)

if txListBytes, err = rlp.EncodeToBytes(txList); err != nil {
log.Error("Encode txList error", "blockID", event.Id, "error", err)
log.Error("Encode txList error", "blockID", event.BlockId, "error", err)
return nil, err
}

Expand Down
14 changes: 11 additions & 3 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ func (s *CalldataSyncerTestSuite) TestProcessL1Blocks() {
}

func (s *CalldataSyncerTestSuite) TestOnBlockProposed() {
s.Nil(s.s.onBlockProposed(context.Background(), &bindings.TaikoL1ClientBlockProposed{Id: common.Big0}, func() {}))
s.NotNil(s.s.onBlockProposed(context.Background(), &bindings.TaikoL1ClientBlockProposed{Id: common.Big1}, func() {}))
s.Nil(s.s.onBlockProposed(
context.Background(),
&bindings.TaikoL1ClientBlockProposed{BlockId: common.Big0},
func() {},
))
s.NotNil(s.s.onBlockProposed(
context.Background(),
&bindings.TaikoL1ClientBlockProposed{BlockId: common.Big1},
func() {},
))
}

func (s *CalldataSyncerTestSuite) TestInsertNewHead() {
Expand All @@ -78,7 +86,7 @@ func (s *CalldataSyncerTestSuite) TestInsertNewHead() {
_, err = s.s.insertNewHead(
context.Background(),
&bindings.TaikoL1ClientBlockProposed{
Id: common.Big1,
BlockId: common.Big1,
Meta: bindings.TaikoDataBlockMetadata{
Id: 1,
L1Height: l1Head.NumberU64(),
Expand Down
4 changes: 2 additions & 2 deletions driver/state/l1_current.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func (s *State) ResetL1Current(
e *bindings.TaikoL1ClientBlockProven,
end eventIterator.EndBlockProvenEventIterFunc,
) error {
log.Debug("Filtered BlockProven event", "ID", e.Id, "hash", common.Hash(e.BlockHash))
log.Debug("Filtered BlockProven event", "ID", e.BlockId, "hash", common.Hash(e.BlockHash))
if e.BlockHash == targetHash {
heightOrID.ID = e.Id
heightOrID.ID = e.BlockId
end()
}

Expand Down
8 changes: 4 additions & 4 deletions driver/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ func (s *State) startSubscriptions(ctx context.Context) {
case <-ctx.Done():
return
case e := <-s.blockProposedCh:
s.setHeadBlockID(e.Id)
s.setHeadBlockID(e.BlockId)
case e := <-s.blockProvenCh:
if e.Prover != encoding.OracleProverAddress {
log.Info("✅ Block proven", "blockID", e.Id, "hash", common.Hash(e.BlockHash), "prover", e.Prover)
log.Info("✅ Block proven", "blockID", e.BlockId, "hash", common.Hash(e.BlockHash), "prover", e.Prover)
}
case e := <-s.blockVerifiedCh:
log.Info("📈 Block verified", "blockID", e.Id, "hash", common.Hash(e.BlockHash), "reward", e.Reward)
log.Info("📈 Block verified", "blockID", e.BlockId, "hash", common.Hash(e.BlockHash), "reward", e.ProofReward)
case e := <-s.crossChainSynced:
// Verify the protocol synced block, check if it exists in
// L2 execution engine.
Expand Down Expand Up @@ -305,7 +305,7 @@ func (s *State) getSyncedHeaderID(l1Height uint64, hash common.Hash) (*big.Int,
continue
}

return e.Id, nil
return e.BlockId, nil
}

return nil, fmt.Errorf("verified block %s BlockVerified event not found", hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func assembleBlockProposedIteratorCallback(
iter, err := taikoL1Client.FilterBlockProposed(
&bind.FilterOpts{Start: start.Number.Uint64(), End: &endHeight, Context: ctx},
filterQuery,
nil,
)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func SubscribeBlockProposed(
ch chan *bindings.TaikoL1ClientBlockProposed,
) event.Subscription {
return SubscribeEvent("BlockProposed", func(ctx context.Context) (event.Subscription, error) {
sub, err := taikoL1.WatchBlockProposed(nil, ch, nil)
sub, err := taikoL1.WatchBlockProposed(nil, ch, nil, nil)
if err != nil {
log.Error("Create TaikoL1.BlockProposed subscription error", "error", err)
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *ProposerTestSuite) TestProposeOp() {
// Propose txs in L2 execution engine's mempool
sink := make(chan *bindings.TaikoL1ClientBlockProposed)

sub, err := s.p.rpc.TaikoL1.WatchBlockProposed(nil, sink, nil)
sub, err := s.p.rpc.TaikoL1.WatchBlockProposed(nil, sink, nil, nil)
s.Nil(err)
defer func() {
sub.Unsubscribe()
Expand All @@ -82,7 +82,7 @@ func (s *ProposerTestSuite) TestProposeOp() {
parent, err := s.p.rpc.L2.BlockByNumber(context.Background(), nil)
s.Nil(err)

baseFee, err := s.p.rpc.TaikoL2.GetBasefee(nil, 1, uint64(gaslimit), parent.GasUsed())
baseFee, err := s.p.rpc.TaikoL2.GetBasefee(nil, 1, uint32(gaslimit), uint32(parent.GasUsed()))
s.Nil(err)

to := common.BytesToAddress(testutils.RandomBytes(32))
Expand Down
44 changes: 22 additions & 22 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ import (

// Config contains the configurations to initialize a Taiko prover.
type Config struct {
L1WsEndpoint string
L1HttpEndpoint string
L2WsEndpoint string
L2HttpEndpoint string
TaikoL1Address common.Address
TaikoProverPoolL1Address common.Address
TaikoL2Address common.Address
L1ProverPrivKey *ecdsa.PrivateKey
ZKEvmRpcdEndpoint string
ZkEvmRpcdParamsPath string
StartingBlockID *big.Int
MaxConcurrentProvingJobs uint
Dummy bool
OracleProver bool
OracleProverPrivateKey *ecdsa.PrivateKey
Graffiti string
RandomDummyProofDelayLowerBound *time.Duration
RandomDummyProofDelayUpperBound *time.Duration
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
CheckProofWindowExpiredIntervalInSeconds time.Duration
L1WsEndpoint string
L1HttpEndpoint string
L2WsEndpoint string
L2HttpEndpoint string
TaikoL1Address common.Address
TaikoProverPoolL1Address common.Address
TaikoL2Address common.Address
L1ProverPrivKey *ecdsa.PrivateKey
ZKEvmRpcdEndpoint string
ZkEvmRpcdParamsPath string
StartingBlockID *big.Int
MaxConcurrentProvingJobs uint
Dummy bool
OracleProver bool
OracleProverPrivateKey *ecdsa.PrivateKey
Graffiti string
RandomDummyProofDelayLowerBound *time.Duration
RandomDummyProofDelayUpperBound *time.Duration
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
CheckProofWindowExpiredInterval time.Duration
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -118,7 +118,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
RandomDummyProofDelayUpperBound: randomDummyProofDelayUpperBound,
BackOffMaxRetrys: c.Uint64(flags.BackOffMaxRetrys.Name),
BackOffRetryInterval: time.Duration(c.Uint64(flags.BackOffRetryInterval.Name)) * time.Second,
CheckProofWindowExpiredIntervalInSeconds: time.Duration(
CheckProofWindowExpiredInterval: time.Duration(
c.Uint64(flags.CheckProofWindowExpiredInterval.Name),
) * time.Second,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext_OracleProver() {
crypto.PubkeyToAddress(c.OracleProverPrivateKey.PublicKey),
)
s.Equal("", c.Graffiti)
s.Equal(30*time.Second, c.CheckProofWindowExpiredIntervalInSeconds)
s.Equal(30*time.Second, c.CheckProofWindowExpiredInterval)
s.Nil(new(Prover).InitFromCli(context.Background(), ctx))

return err
Expand Down
17 changes: 12 additions & 5 deletions prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func NewValidProofSubmitter(

// RequestProof implements the ProofSubmitter interface.
func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings.TaikoL1ClientBlockProposed) error {
l1Origin, err := s.rpc.WaitL1Origin(ctx, event.Id)
l1Origin, err := s.rpc.WaitL1Origin(ctx, event.BlockId)
if err != nil {
return fmt.Errorf("failed to fetch l1Origin, blockID: %d, err: %w", event.Id, err)
return fmt.Errorf("failed to fetch l1Origin, blockID: %d, err: %w", event.BlockId, err)
}

// Get the header of the block to prove from L2 execution engine.
Expand All @@ -103,7 +103,7 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings.
return fmt.Errorf("failed to get the L2 parent block by hash (%s): %w", block.ParentHash(), err)
}

blockInfo, err := s.rpc.TaikoL1.GetBlock(nil, event.Id)
blockInfo, err := s.rpc.TaikoL1.GetBlock(nil, event.BlockId)
if err != nil {
return err
}
Expand Down Expand Up @@ -134,8 +134,15 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings.
ParentGasUsed: parent.GasUsed(),
}

if err := s.proofProducer.RequestProof(ctx, opts, event.Id, &event.Meta, block.Header(), s.resultCh); err != nil {
return fmt.Errorf("failed to request proof (id: %d): %w", event.Id, err)
if err := s.proofProducer.RequestProof(
ctx,
opts,
event.BlockId,
&event.Meta,
block.Header(),
s.resultCh,
); err != nil {
return fmt.Errorf("failed to request proof (id: %d): %w", event.BlockId, err)
}

metrics.ProverQueuedProofCounter.Inc(1)
Expand Down
4 changes: 2 additions & 2 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *ProofSubmitterTestSuite) TestValidProofSubmitterRequestProofDeadlineExc

s.ErrorContains(
s.validProofSubmitter.RequestProof(
ctx, &bindings.TaikoL1ClientBlockProposed{Id: common.Big256}), "context deadline exceeded",
ctx, &bindings.TaikoL1ClientBlockProposed{BlockId: common.Big256}), "context deadline exceeded",
)
}

Expand Down Expand Up @@ -129,7 +129,7 @@ func (s *ProofSubmitterTestSuite) TestValidProofSubmitterRequestProofCancelled()

s.ErrorContains(
s.validProofSubmitter.RequestProof(
ctx, &bindings.TaikoL1ClientBlockProposed{Id: common.Big256}), "context canceled",
ctx, &bindings.TaikoL1ClientBlockProposed{BlockId: common.Big256}), "context canceled",
)
}

Expand Down
Loading

0 comments on commit 27ec1dd

Please sign in to comment.