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

Commit

Permalink
Merge branch 'main' into integrate-anchor-circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jul 18, 2023
2 parents 3299bd1 + 9eefc8d commit aea72aa
Show file tree
Hide file tree
Showing 27 changed files with 651 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7.14.2
version: 8.4.0
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.11.0"
".": "0.12.0"
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [0.12.0](https://github.com/taikoxyz/taiko-client/compare/v0.11.0...v0.12.0) (2023-07-10)


### Features

* **all:** update bindings && integrate new circuits for L3 ([#290](https://github.com/taikoxyz/taiko-client/issues/290)) ([59469fa](https://github.com/taikoxyz/taiko-client/commit/59469fac2fefe1046d805dc1f19911150e453d87))
* **bindings:** update contract bindings ([#310](https://github.com/taikoxyz/taiko-client/issues/310)) ([021f113](https://github.com/taikoxyz/taiko-client/commit/021f113c2add574843f889b525d55789752b1bd6))
* **prover:** add some prover logs ([#305](https://github.com/taikoxyz/taiko-client/issues/305)) ([e36c76c](https://github.com/taikoxyz/taiko-client/commit/e36c76c7ea6d912477dc8ce61e4639faef00eb5c))
* **prover:** implement staking based tokenomics in client ([#292](https://github.com/taikoxyz/taiko-client/issues/292)) ([7324547](https://github.com/taikoxyz/taiko-client/commit/7324547a80182e93193479089bd334fcce5df7ce))


### Bug Fixes

* **driver:** fix a P2P sync issue ([#298](https://github.com/taikoxyz/taiko-client/issues/298)) ([2ffa052](https://github.com/taikoxyz/taiko-client/commit/2ffa0528110db70f34dd3ef6f48008487caa78a2))
* **prover:** fix a fork choice checking issue ([#309](https://github.com/taikoxyz/taiko-client/issues/309)) ([a393ed8](https://github.com/taikoxyz/taiko-client/commit/a393ed85fed4046039b66bda51bb645ed84d8461))
* **prover:** fix an unlock issue ([#306](https://github.com/taikoxyz/taiko-client/issues/306)) ([392eb78](https://github.com/taikoxyz/taiko-client/commit/392eb78f3721fedea66bd2f361010e2495e385c6))

## [0.11.0](https://github.com/taikoxyz/taiko-client/compare/v0.10.0...v0.11.0) (2023-06-26)


Expand Down
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.

18 changes: 16 additions & 2 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var (
Usage: "Private key of oracle prover",
Category: proverCategory,
}
OracleProofSubmissionDelay = &cli.Uint64Flag{
Name: "oracleProofSubmissionDelay",
Usage: "Oracle proof submission delay in seconds",
Value: 0,
Category: proverCategory,
}
Graffiti = &cli.StringFlag{
Name: "graffiti",
Usage: "When string is passed, adds additional graffiti info to proof evidence",
Expand All @@ -73,14 +79,20 @@ var (
Name: "taikoProverPoolL1",
Usage: "TaikoProverPoolL1 contract address",
Required: true,
Category: commonCategory,
Category: proverCategory,
}
CheckProofWindowExpiredInterval = &cli.Uint64Flag{
Name: "prover.checkProofWindowExpiredInterval",
Usage: "Interval in seconds to check for expired proof windows from other provers",
Category: commonCategory,
Category: proverCategory,
Value: 15,
}
ProveUnassignedBlocks = &cli.BoolFlag{
Name: "prover.proveUnassignedBlocks",
Usage: "Whether you want to prove unassigned blocks, or only work on assigned proofs",
Category: proverCategory,
Value: true,
}
)

// All prover flags.
Expand All @@ -97,7 +109,9 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
RandomDummyProofDelay,
OracleProver,
OracleProverPrivateKey,
OracleProofSubmissionDelay,
Graffiti,
TaikoProverPoolL1Address,
CheckProofWindowExpiredInterval,
ProveUnassignedBlocks,
})
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,
event.Meta.GasLimit+uint32(s.anchorConstructor.GasLimit()),
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
5 changes: 4 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ var (
ProverSentProofCounter = metrics.NewRegisteredCounter("prover/proof/all/sent", nil)
ProverSentValidProofCounter = metrics.NewRegisteredCounter("prover/proof/valid/sent", nil)
ProverSentInvalidProofCounter = metrics.NewRegisteredCounter("prover/proof/invalid/sent", nil)
ProverProofsAssigned = metrics.NewRegisteredCounter("prover/proof/assigned", nil)
ProverSlashedCounter = metrics.NewRegisteredCounter("prover/slashed", nil)
ProverSlashedAmount = metrics.NewRegisteredCounter("prover/slashed/amount", nil)
ProverReceivedProposedBlockGauge = metrics.NewRegisteredGauge("prover/proposed/received", nil)
ProverReceivedProvenBlockGauge = metrics.NewRegisteredGauge("prover/proven/received", nil)
ProverProofRewardGauge = metrics.NewRegisteredGauge("prover/proofReward", nil)
ProverAllProofRewardGauge = metrics.NewRegisteredGauge("prover/allProofReward", nil)
ProverNormalProofRewardGauge = metrics.NewRegisteredGauge("prover/normalProofReward", nil)
)

// Serve starts the metrics server on the given address, will be closed when the given
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
5 changes: 0 additions & 5 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ func NeedNewProof(
return true, nil
}

if fc.Prover == encoding.OracleProverAddress {
log.Info("Only oracle proof submitted, try generating a normal proof", "blockID", id)
return true, nil
}

if proverAddress == fc.Prover {
log.Info("📬 Block's proof has already been submitted by current prover", "blockID", id)
return false, nil
Expand Down
3 changes: 3 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func (p *Proposer) ProposeOp(ctx context.Context) error {
}

log.Info("Comparing proposer TKO balance to block fee", "proposer", p.l1ProposerAddress.Hex())
if err := p.CheckTaikoTokenBalance(); err != nil {
return fmt.Errorf("failed to check token balance: %w", err)
}

// Wait until L2 execution engine is synced at first.
if err := p.rpc.WaitTillL2ExecutionEngineSynced(ctx); err != nil {
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
Loading

0 comments on commit aea72aa

Please sign in to comment.