Skip to content

Commit

Permalink
Merge branch 'main' into pacaya_fork
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 16, 2025
2 parents 60592c0 + 65f763b commit d5a472d
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"packages/relayer": "0.12.0",
"packages/snaefell-ui": "1.1.0",
"packages/supplementary-contracts": "1.0.0",
"packages/taiko-client": "0.42.1",
"packages/taiko-client": "0.43.0",
"packages/taikoon-ui": "1.3.0",
"packages/ui-lib": "1.0.0"
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,38 @@ These are the bare minimum required settings along with a functional Taiko node

</Steps>

Please find all relevant bond, cooldown, and proving window information [here](/network-reference/network-configuration/#cooldown-window-proving-window-and-bonds).

## Enabling batch proving/proof aggregation (optional)

<Aside type="danger">
We don't recommend users utilize this function unless they already run a fairly active and successful proposer.

By enabling proof aggregation, you will be opening yourself up to more risk as you will be putting up more TAIKO as bond at one time.

The recommended value for SGX_BATCH_SIZE is 10+ as you will see the most gas saved at this value and above. We will NOT refund any lost bonds due to misconfiguration, please evaluate and use this function at your own risk.

We highly recommend you test the function on Hekla before enabling it for mainnet.
</Aside>

Batch proving has been enabled in release 0.43.0 of [the taiko alethia client!](https://github.com/taikoxyz/taiko-mono/releases/tag/taiko-alethia-client-v0.43.0)

Please use [simple-taiko-node release 1.8.2](https://github.com/taikoxyz/simple-taiko-node/releases/tag/v1.8.2) or above to enable this functionality.

**This functionality can be enabled simply by setting `SGX_BATCH_SIZE` in your `.env` file to a number greater than 1.**

If it is set to 1 or unset your prover will submit proofs upon assignment (standard function).
When enabled, your prover will submit a batch of proofs when x number of blocks are assigned, x being `SGX_BATCH_SIZE`.

As provers are given a proof window for every assigned proof, it can become the case that while waiting for a batch size to be fulfilled the already assigned proofs exit their proof window and become unassigned.
To prevent this, we have introduced another flag `FORCE_BATCH_PROVING_INTERVAL`. This flag will only be functional if batch proving is enabled.

This flag will force the prover to submit a batch of proofs every x minutes, regardless of the batch size being fulfilled. We don't recommend this value be set > 45 minutes, as the provingWindow is 60 minutes and any closer will put you at risk of having proof assignments expire. It is by default set to 30 minutes.

<Aside>
The following steps can be done through the [ProverSet contract](/guides/node-operators/deploy-a-proverset/#deploying-a-proverset) if you have deployed one. We highly recommend this for a stable setup.
</Aside>

Please find all relevant bond, cooldown, and proving window information [here](/network-reference/network-configuration/#cooldown-window-proving-window-and-bonds).

### Approve TaikoL1 as TAIKO spender (mainnet)

<Steps>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The cooldown window describes how long after the proof has been provided that th

The proving window describes how long a prover has to provide a proof for a block after they have been assigned the block (i.e. a block has been proposed with them as the assigned prover).

You can find all the corresponding values below in the [deployed TierProviderBase contract](https://etherscan.io/address/0x394E30d83d020469a1F8b16E89D7fD5FdB1935b0#code#F3#L1)!
You can find all the corresponding values below for Mainnet in the [deployed TierProviderBase contract](https://etherscan.io/address/0x394E30d83d020469a1F8b16E89D7fD5FdB1935b0#code#F3#L1)!

| Tier | Cooldown Window | Proving Window | Bond |
| ----------------- | --------------- | -------------- | --------- |
Expand All @@ -24,6 +24,18 @@ You can find all the corresponding values below in the [deployed TierProviderBas
| Guardian Minority | 240 minutes | 240 minutes | 225 TAIKO |
| Guardian | 240 minutes | 240 minutes | 0 TAIKO |

You can find all the corresponding values below for Hekla in the [most recent protocol release](https://github.com/taikoxyz/taiko-mono/blob/taiko-alethia-protocol-v1.11.0/packages/protocol/contracts/layer1/tiers/TierProviderBase.sol)

| Tier | Cooldown Window | Proving Window | Bond |
| ----------------- | --------------- | -------------- | --------- |
| Optimistic | 1440 minutes | 60 minutes | 75 TAIKO |
| SGX | 240 minutes | 60 minutes | 150 TAIKO |
| TDX | 240 minutes | 60 minutes | 150 TAIKO |
| ZK SP1 | 240 minutes | 120 minutes | 225 TAIKO |
| ZK R0 | 240 minutes | 120 minutes | 225 TAIKO |
| Guardian Minority | 240 minutes | 120 minutes | 300 TAIKO |
| Guardian | 480 minutes | 0 minutes | 0 TAIKO |

## Tier configuration (Mainnet)

You can view the full `MainnetTierRouter` tier configuration [here](https://etherscan.io/address/0x8a4c692F12d3a9750E744A4CE24a1d351bE52E66#code):
Expand Down
30 changes: 30 additions & 0 deletions packages/taiko-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## [0.43.0](https://github.com/taikoxyz/taiko-mono/compare/taiko-alethia-client-v0.42.1...taiko-alethia-client-v0.43.0) (2025-01-14)


### Features

* **taiko-client:** only check and trigger P2P sync progress right after starting ([#18745](https://github.com/taikoxyz/taiko-mono/issues/18745)) ([a05e4c9](https://github.com/taikoxyz/taiko-mono/commit/a05e4c99bbcfd5f6f6e37b4222616e40b31cfbaf))
* **taiko-client:** remove soft blocks implementation ([#18744](https://github.com/taikoxyz/taiko-mono/issues/18744)) ([f645b23](https://github.com/taikoxyz/taiko-mono/commit/f645b23ae11bf5df9b5199d9a683d6b9f2c12d4b))
* **taiko-client:** soft block driver APIs ([#18273](https://github.com/taikoxyz/taiko-mono/issues/18273)) ([9fff7ff](https://github.com/taikoxyz/taiko-mono/commit/9fff7ff3cce99e915e8142a090a7fad2f1af5bd4))


### Bug Fixes

* **taiko-client:** check inner iterator errors in `BlockProposedIterator` ([#18757](https://github.com/taikoxyz/taiko-mono/issues/18757)) ([404efcc](https://github.com/taikoxyz/taiko-mono/commit/404efcc0ad7c5494635a53df94ea72108fa69bf2))
* **taiko-client:** check the `blockID` of the last verified block before using it as `FinalizedBlockHash` ([#18739](https://github.com/taikoxyz/taiko-mono/issues/18739)) ([8c364b1](https://github.com/taikoxyz/taiko-mono/commit/8c364b1f493cfda2823e3efc49ec0e8a8985884a))
* **taiko-client:** remove `finalizedBlock` info when P2P syncing ([#18735](https://github.com/taikoxyz/taiko-mono/issues/18735)) ([d81a630](https://github.com/taikoxyz/taiko-mono/commit/d81a6309c2e303eca57238c4e252b93083a55d2f))
* **taiko-client:** revert `tracker.triggered` related changes ([#18737](https://github.com/taikoxyz/taiko-mono/issues/18737)) ([e76d865](https://github.com/taikoxyz/taiko-mono/commit/e76d865a3f482b6165f2b7cc5bb0f4a5065b3bc2))


### Chores

* **taiko-client:** add softBlock server start log ([#18731](https://github.com/taikoxyz/taiko-mono/issues/18731)) ([23594ff](https://github.com/taikoxyz/taiko-mono/commit/23594ff2e44f51b0409c76368429d2c3a156a802))
* **taiko-client:** bump `taiko-geth` dep ([#18730](https://github.com/taikoxyz/taiko-mono/issues/18730)) ([554f679](https://github.com/taikoxyz/taiko-mono/commit/554f679b01199da363587adee0ec88a0c1846483))
* **taiko-client:** cleanup some unused variables in `bindings` package ([#18752](https://github.com/taikoxyz/taiko-mono/issues/18752)) ([13ccc54](https://github.com/taikoxyz/taiko-mono/commit/13ccc5466e40422b971f426661f3d7adef8d3d17))
* **taiko-client:** improve `TxBuilderWithFallback` logs ([#18738](https://github.com/taikoxyz/taiko-mono/issues/18738)) ([01ebba3](https://github.com/taikoxyz/taiko-mono/commit/01ebba3a61d0bbd8251bed1f91b09b9abfcc99c7))


### Tests

* **taiko-client:** improve tests for blob sync ([#18764](https://github.com/taikoxyz/taiko-mono/issues/18764)) ([4df3edc](https://github.com/taikoxyz/taiko-mono/commit/4df3edc04b0d241b2bb540f4f664ff0c3dd0449a))

## [0.42.1](https://github.com/taikoxyz/taiko-mono/compare/taiko-alethia-client-v0.42.0...taiko-alethia-client-v0.42.1) (2025-01-07)


Expand Down
37 changes: 1 addition & 36 deletions packages/taiko-client/driver/chain_syncer/beaconsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/state"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
Expand All @@ -22,7 +19,6 @@ type Syncer struct {
ctx context.Context
rpc *rpc.Client
state *state.State
syncMode string
progressTracker *SyncProgressTracker // Sync progress tracker
}

Expand All @@ -31,10 +27,9 @@ func NewSyncer(
ctx context.Context,
rpc *rpc.Client,
state *state.State,
syncMode string,
progressTracker *SyncProgressTracker,
) *Syncer {
return &Syncer{ctx, rpc, state, syncMode, progressTracker}
return &Syncer{ctx, rpc, state, progressTracker}
}

// TriggerBeaconSync triggers the L2 execution engine to start performing a beacon sync, if the
Expand Down Expand Up @@ -101,36 +96,6 @@ func (s *Syncer) getBlockPayload(ctx context.Context, blockID uint64) (*engine.E
return nil, err
}

// If the sync mode is `full`, we need to verify the protocol verified block hash before syncing.
if s.syncMode == downloader.FullSync.String() {
blockNum := new(big.Int).SetUint64(blockID)
var blockInfo bindings.TaikoDataBlockV2
if s.state.IsOnTake(blockNum) {
blockInfo, err = s.rpc.GetL2BlockInfoV2(ctx, blockNum)
} else {
blockInfo, err = s.rpc.GetL2BlockInfo(ctx, blockNum)
}
if err != nil {
return nil, err
}
ts, err := s.rpc.GetTransition(
ctx,
new(big.Int).SetUint64(blockInfo.BlockId),

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

log.Info("Block header to sync retrieved", "hash", header.Hash())

return encoding.ToExecutableData(header), nil
Expand Down
2 changes: 2 additions & 0 deletions packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (s *Syncer) onBlockProposed(
}
// Ignore those already inserted blocks.
if s.lastInsertedBlockID != nil && meta.GetBlockID().Cmp(s.lastInsertedBlockID) <= 0 {
log.Debug("Skip already inserted block", "blockID", meta.GetBlockID(), "lastInsertedBlockID", s.lastInsertedBlockID)
return nil
}

Expand All @@ -224,6 +225,7 @@ func (s *Syncer) onBlockProposed(
if s.progressTracker.Triggered() {
// Already synced through beacon sync, just skip this event.
if meta.GetBlockID().Cmp(s.progressTracker.LastSyncedBlockID()) <= 0 {
log.Debug("Skip already beacon synced block", "blockID", meta.GetBlockID())
return nil
}

Expand Down
96 changes: 96 additions & 0 deletions packages/taiko-client/driver/chain_syncer/blob/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import (
"time"

"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/taiko"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings"
Expand Down Expand Up @@ -53,6 +56,99 @@ func (s *BlobSyncerTestSuite) SetupTest() {
s.initProposer()
}

func (s *BlobSyncerTestSuite) TestBlobSyncRobustness() {
ctx := context.Background()

meta := s.ProposeAndInsertValidBlock(s.p, s.s)

block, err := s.RPCClient.L2.BlockByNumber(ctx, meta.GetBlockID())
s.Nil(err)

lastVerifiedBlockInfo, err := s.s.rpc.GetLastVerifiedBlock(ctx)
s.Nil(err)

txListBytes, err := rlp.EncodeToBytes(block.Transactions())
s.Nil(err)

parent, err := s.RPCClient.L2ParentByBlockID(context.Background(), meta.GetBlockID())
s.Nil(err)

// Reset l2 chain.
s.Nil(rpc.SetHead(ctx, s.RPCClient.L2, common.Big0))

attributes := &engine.PayloadAttributes{
Timestamp: meta.GetTimestamp(),
Random: meta.GetDifficulty(),
SuggestedFeeRecipient: meta.GetCoinbase(),
Withdrawals: make([]*types.Withdrawal, 0),
BlockMetadata: &engine.BlockMetadata{
Beneficiary: meta.GetCoinbase(),
GasLimit: uint64(meta.GetGasLimit()) + taiko.AnchorGasLimit,
Timestamp: meta.GetTimestamp(),
TxList: txListBytes,
MixHash: meta.GetDifficulty(),
ExtraData: meta.GetExtraData(),
},
BaseFeePerGas: block.BaseFee(),
L1Origin: &rawdb.L1Origin{
BlockID: meta.GetBlockID(),
L2BlockHash: common.Hash{}, // Will be set by taiko-geth.
L1BlockHeight: meta.GetRawBlockHeight(),
L1BlockHash: meta.GetRawBlockHash(),
},
}

step0 := func() *engine.ForkChoiceResponse {
fcRes, err := s.RPCClient.L2Engine.ForkchoiceUpdate(
ctx,
&engine.ForkchoiceStateV1{HeadBlockHash: parent.Hash()},
attributes,
)
s.Nil(err)
s.Equal(engine.VALID, fcRes.PayloadStatus.Status)
s.True(true, fcRes.PayloadID != nil)
return fcRes
}

step1 := func(fcRes *engine.ForkChoiceResponse) *engine.ExecutableData {
payload, err := s.RPCClient.L2Engine.GetPayload(ctx, fcRes.PayloadID)
s.Nil(err)
return payload
}

step2 := func(payload *engine.ExecutableData) *engine.ExecutableData {
execStatus, err := s.RPCClient.L2Engine.NewPayload(ctx, payload)
s.Nil(err)
s.Equal(engine.VALID, execStatus.Status)
return payload
}

step3 := func(payload *engine.ExecutableData) {
fcRes, err := s.RPCClient.L2Engine.ForkchoiceUpdate(ctx, &engine.ForkchoiceStateV1{
HeadBlockHash: payload.BlockHash,
SafeBlockHash: lastVerifiedBlockInfo.BlockHash,
FinalizedBlockHash: lastVerifiedBlockInfo.BlockHash,
}, nil)
s.Nil(err)
s.Equal(engine.VALID, fcRes.PayloadStatus.Status)
}

loopSize := 10
for i := 0; i < loopSize; i++ {
step0()
}

for i := 0; i < loopSize; i++ {
step1(step0())
}

for i := 0; i < loopSize; i++ {
step2(step1(step0()))
}

step3(step2(step1(step0())))
}

func (s *BlobSyncerTestSuite) TestProcessL1Blocks() {
s.Nil(s.s.ProcessL1Blocks(context.Background()))
}
Expand Down
34 changes: 4 additions & 30 deletions packages/taiko-client/driver/chain_syncer/chain_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"net/url"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/driver/chain_syncer/beaconsync"
Expand All @@ -30,9 +28,6 @@ type L2ChainSyncer struct {
// Monitors
progressTracker *beaconsync.SyncProgressTracker

// Sync mode
syncMode string

// If this flag is activated, will try P2P beacon sync if current node is behind of the protocol's
// the latest verified block head
p2pSync bool
Expand All @@ -52,11 +47,7 @@ func New(
tracker := beaconsync.NewSyncProgressTracker(rpc.L2, p2pSyncTimeout)
go tracker.Track(ctx)

syncMode, err := rpc.L2.GetSyncMode(ctx)
if err != nil {
return nil, err
}
beaconSyncer := beaconsync.NewSyncer(ctx, rpc, state, syncMode, tracker)
beaconSyncer := beaconsync.NewSyncer(ctx, rpc, state, tracker)
blobSyncer, err := blob.NewSyncer(
ctx,
rpc,
Expand All @@ -77,7 +68,6 @@ func New(
beaconSyncer: beaconSyncer,
blobSyncer: blobSyncer,
progressTracker: tracker,
syncMode: syncMode,
p2pSync: p2pSync,
}, nil
}
Expand Down Expand Up @@ -193,25 +183,9 @@ func (s *L2ChainSyncer) needNewBeaconSyncTriggered() (uint64, bool, error) {
return 0, false, nil
}

// For full sync mode, we will use the verified block head,
// and for snap sync mode, we will use the latest block head.
var (
blockID uint64
err error
)
switch s.syncMode {
case downloader.SnapSync.String():
if blockID, err = s.rpc.L2CheckPoint.BlockNumber(s.ctx); err != nil {
return 0, false, err
}
case downloader.FullSync.String():
stateVars, err := s.rpc.GetProtocolStateVariables(&bind.CallOpts{Context: s.ctx})
if err != nil {
return 0, false, err
}
blockID = stateVars.B.LastVerifiedBlockId
default:
return 0, false, fmt.Errorf("invalid sync mode: %s", s.syncMode)
blockID, err := s.rpc.L2CheckPoint.BlockNumber(s.ctx)
if err != nil {
return 0, false, err
}

// If the protocol's block head is zero, we simply return false.
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package version

// Version info.
const Version = "0.42.1" // x-release-please-version
const Version = "0.43.0" // x-release-please-version

var meta = "dev"

Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "taiko-client",
"version": "0.42.1",
"version": "0.43.0",
"private": true
}
Loading

0 comments on commit d5a472d

Please sign in to comment.