Skip to content

Commit

Permalink
Merge branch 'main' into preconf-driver-apis
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 6, 2025
2 parents cc9f809 + 6157af5 commit 05953ae
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/fork-diff": "0.6.1",
"packages/guardian-prover-health-check": "0.1.0",
"packages/guardian-prover-health-check-ui": "0.2.0",
"packages/protocol": "1.10.0",
"packages/protocol": "1.11.0",
"packages/relayer": "0.12.0",
"packages/snaefell-ui": "1.1.0",
"packages/supplementary-contracts": "1.0.0",
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/ethereum-optimism/optimism v1.7.4
github.com/ethereum/go-ethereum v1.14.11
github.com/ethereum/hive v0.0.0-20240822135954-91829ccfb2c5
github.com/go-git/go-git/v5 v5.12.0
github.com/go-git/go-git/v5 v5.13.1
github.com/go-resty/resty/v2 v2.16.2
github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -56,7 +56,7 @@ require (
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
Expand All @@ -82,7 +82,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.1.1+incompatible // indirect
Expand All @@ -98,7 +98,7 @@ require (
github.com/fsouza/go-dockerclient v1.11.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-billy/v5 v5.6.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
Expand Down Expand Up @@ -188,7 +188,7 @@ require (
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
Expand Down
54 changes: 14 additions & 40 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ description: Taiko protocol page for "TaikoL1.sol".

## Key Events

1. **`DebugGasPerBlock`**
Provides gas usage metrics for block proposals or proofs.

- `isProposeBlock`: Indicates whether the event is for proposals or proofs.
- `gasUsed`: Gas consumed per block.
- `batchSize`: Number of blocks in the batch.

2. **`StateVariablesUpdated`**
1. **`StateVariablesUpdated`**
Signals updates to the state variables.

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ description: Taiko protocol page for "TaikoL2.sol".

- `parentHash`: Hash of the parent block.
- `parentGasExcess`: Gas excess for base fee calculation.
<br/><br/>

2. **`EIP1559Update`**
Emitted when gas parameters (e.g., target, excess, base fee) are updated.
Expand Down
215 changes: 215 additions & 0 deletions packages/protocol/CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@taiko/protocol",
"version": "1.10.0",
"version": "1.11.0",
"private": true,
"scripts": {
"buildMerkle": "ts-node ./utils/airdrop/buildMerkleTree.ts ./utils/airdrop/airdrop_db/example_claimList.json",
Expand Down
18 changes: 4 additions & 14 deletions packages/taiko-client/cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package flags

import (
"github.com/urfave/cli/v2"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/version"
)

// Required flags used by proposer.
Expand Down Expand Up @@ -69,14 +67,6 @@ var (
Value: 0,
EnvVars: []string{"EPOCH_ALLOW_ZERO_INTERVAL"},
}
// Proposing metadata related.
ExtraData = &cli.StringFlag{
Name: "extraData",
Usage: "Block extra data set by the proposer (default = client version)",
Value: version.CommitVersion(),
Category: proposerCategory,
EnvVars: []string{"EXTRA_DATA"},
}
// Transactions pool related.
TxPoolLocals = &cli.StringSliceFlag{
Name: "txPool.locals",
Expand Down Expand Up @@ -113,11 +103,12 @@ var (
EnvVars: []string{"L1_FALLBACK_TO_CALLDATA"},
}
RevertProtectionEnabled = &cli.BoolFlag{
Name: "revertProtection",
Usage: "Enable revert protection with the support of endpoint and contract",
Name: "l1.revertProtection",
Usage: "Enable revert protection within your ProverSet contract, " +
"this is effective only if your PBS service supports revert protection",
Value: false,
Category: proposerCategory,
EnvVars: []string{"REVERT_PROTECTION"},
EnvVars: []string{"L1_REVERT_PROTECTION"},
}
)

Expand All @@ -132,7 +123,6 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
ProposeInterval,
TxPoolLocals,
TxPoolLocalsOnly,
ExtraData,
MinGasUsed,
MinTxListBytes,
MinTip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
L2SuggestedFeeRecipient: common.HexToAddress(os.Getenv("L2_SUGGESTED_FEE_RECIPIENT")),
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ExtraData: "test",
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_WS"),
NumConfirmations: 0,
Expand Down
3 changes: 3 additions & 0 deletions packages/taiko-client/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var (
ProposerPoolContentFetchTime = factory.NewGauge(prometheus.GaugeOpts{Name: "proposer_pool_content_fetch_time"})
ProposerEstimatedCostCalldata = factory.NewGauge(prometheus.GaugeOpts{Name: "proposer_estimated_cost_calldata"})
ProposerEstimatedCostBlob = factory.NewGauge(prometheus.GaugeOpts{Name: "proposer_estimated_cost_blob"})
ProposerProposeByCalldata = factory.NewCounter(prometheus.CounterOpts{Name: "proposer_propose_by_calldata"})
ProposerProposeByBlob = factory.NewCounter(prometheus.CounterOpts{Name: "proposer_propose_by_blob"})
ProposerCostEstimationError = factory.NewGauge(prometheus.GaugeOpts{Name: "proposer_cost_estimation_error"})

// Prover
ProverLatestVerifiedIDGauge = factory.NewGauge(prometheus.GaugeOpts{Name: "prover_latestVerified_id"})
Expand Down
2 changes: 0 additions & 2 deletions packages/taiko-client/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Config struct {
*rpc.ClientConfig
L1ProposerPrivKey *ecdsa.PrivateKey
L2SuggestedFeeRecipient common.Address
ExtraData string
ProposeInterval time.Duration
LocalAddresses []common.Address
LocalAddressesOnly bool
Expand Down Expand Up @@ -93,7 +92,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
},
L1ProposerPrivKey: l1ProposerPrivKey,
L2SuggestedFeeRecipient: common.HexToAddress(l2SuggestedFeeRecipient),
ExtraData: c.String(flags.ExtraData.Name),
ProposeInterval: c.Duration(flags.ProposeInterval.Name),
LocalAddresses: localAddresses,
LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name),
Expand Down
1 change: 0 additions & 1 deletion packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (p *Proposer) InitFromConfig(
cfg.TaikoL1Address,
cfg.ProverSetAddress,
cfg.ProposeBlockTxGasLimit,
cfg.ExtraData,
p.chainConfig,
p.txmgrSelector,
cfg.RevertProtectionEnabled,
Expand Down
1 change: 0 additions & 1 deletion packages/taiko-client/proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (s *ProposerTestSuite) SetupTest() {
MinProposingInternal: 0,
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ExtraData: "test",
ProposeBlockTxGasLimit: 10_000_000,
FallbackToCalldata: true,
TxmgrConfigs: &txmgr.CLIConfig{
Expand Down
3 changes: 0 additions & 3 deletions packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type BlobTransactionBuilder struct {
proverSetAddress common.Address
l2SuggestedFeeRecipient common.Address
gasLimit uint64
extraData string
chainConfig *config.ChainConfig
revertProtectionEnabled bool
}
Expand All @@ -38,7 +37,6 @@ func NewBlobTransactionBuilder(
proverSetAddress common.Address,
l2SuggestedFeeRecipient common.Address,
gasLimit uint64,
extraData string,
chainConfig *config.ChainConfig,
revertProtectionEnabled bool,
) *BlobTransactionBuilder {
Expand All @@ -49,7 +47,6 @@ func NewBlobTransactionBuilder(
proverSetAddress,
l2SuggestedFeeRecipient,
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type CalldataTransactionBuilder struct {
taikoL1Address common.Address
proverSetAddress common.Address
gasLimit uint64
extraData string
chainConfig *config.ChainConfig
revertProtectionEnabled bool
}
Expand All @@ -37,7 +36,6 @@ func NewCalldataTransactionBuilder(
taikoL1Address common.Address,
proverSetAddress common.Address,
gasLimit uint64,
extraData string,
chainConfig *config.ChainConfig,
revertProtectionEnabled bool,
) *CalldataTransactionBuilder {
Expand All @@ -48,7 +46,6 @@ func NewCalldataTransactionBuilder(
taikoL1Address,
proverSetAddress,
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
common.HexToAddress(os.Getenv("TAIKO_L1")),
common.Address{},
0,
"test",
chainConfig,
false,
)
Expand All @@ -49,7 +48,6 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
common.Address{},
common.HexToAddress(os.Getenv("TAIKO_L2")),
10_000_000,
"test",
chainConfig,
false,
)
Expand Down
20 changes: 11 additions & 9 deletions packages/taiko-client/proposer/transaction_builder/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewBuilderWithFallback(
taikoL1Address common.Address,
proverSetAddress common.Address,
gasLimit uint64,
extraData string,
chainConfig *config.ChainConfig,
txmgrSelector *utils.TxMgrSelector,
revertProtectionEnabled bool,
Expand All @@ -58,7 +57,6 @@ func NewBuilderWithFallback(
proverSetAddress,
l2SuggestedFeeRecipient,
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
)
Expand All @@ -71,7 +69,6 @@ func NewBuilderWithFallback(
taikoL1Address,
proverSetAddress,
gasLimit,
extraData,
chainConfig,
revertProtectionEnabled,
)
Expand All @@ -90,7 +87,7 @@ func (b *TxBuilderWithFallback) BuildOntake(
return b.calldataTransactionBuilder.BuildOntake(ctx, txListBytesArray)
}
// If blob is enabled, and fallback is not enabled, just build a blob transaction.
if !b.fallback {
if !b.fallback || len(txListBytesArray) > 1 {
return b.blobTransactionBuilder.BuildOntake(ctx, txListBytesArray)
}

Expand All @@ -106,36 +103,41 @@ func (b *TxBuilderWithFallback) BuildOntake(

g.Go(func() error {
if txWithCalldata, err = b.calldataTransactionBuilder.BuildOntake(ctx, txListBytesArray); err != nil {
return err
return fmt.Errorf("failed to build type-2 transaction: %w", err)
}
if costCalldata, err = b.estimateCandidateCost(ctx, txWithCalldata); err != nil {
return err
return fmt.Errorf("failed to estimate type-2 transaction cost: %w", err)
}
return nil
})
g.Go(func() error {
if txWithBlob, err = b.blobTransactionBuilder.BuildOntake(ctx, txListBytesArray); err != nil {
return err
return fmt.Errorf("failed to build type-3 transaction: %w", err)
}
if costBlob, err = b.estimateCandidateCost(ctx, txWithBlob); err != nil {
return err
return fmt.Errorf("failed to estimate type-3 transaction cost: %w", err)
}
return nil
})

if err = g.Wait(); err != nil {
return nil, err
log.Error("Failed to estimate transactions cost, will build a type-3 transaction", "error", err)
metrics.ProposerCostEstimationError.Inc()
// If there is an error, just build a blob transaction.
return b.blobTransactionBuilder.BuildOntake(ctx, txListBytesArray)
}

metrics.ProposerEstimatedCostCalldata.Set(float64(costCalldata.Uint64()))
metrics.ProposerEstimatedCostBlob.Set(float64(costBlob.Uint64()))

if costCalldata.Cmp(costBlob) < 0 {
log.Info("Building a type-2 transaction", "costCalldata", costCalldata, "costBlob", costBlob)
metrics.ProposerProposeByCalldata.Inc()
return txWithCalldata, nil
}

log.Info("Building a type-3 transaction", "costCalldata", costCalldata, "costBlob", costBlob)
metrics.ProposerProposeByBlob.Inc()
return txWithBlob, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func (s *TransactionBuilderTestSuite) TestFallback() {
builder := s.newTestBuilderWithFallback(true, true, nil)
candidate, err := builder.BuildOntake(context.Background(), [][]byte{
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
})
s.Nil(err)
s.NotZero(len(candidate.Blobs))
Expand All @@ -63,7 +62,6 @@ func (s *TransactionBuilderTestSuite) TestFallback() {

candidate, err = builder.BuildOntake(context.Background(), [][]byte{
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
})
s.Nil(err)
s.Zero(len(candidate.Blobs))
Expand All @@ -81,7 +79,6 @@ func (s *TransactionBuilderTestSuite) TestFallback() {

candidate, err = builder.BuildOntake(context.Background(), [][]byte{
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
bytes.Repeat([]byte{1}, int(rpc.BlockMaxTxListBytes)),
})
s.Nil(err)
s.NotZero(len(candidate.Blobs))
Expand Down Expand Up @@ -133,7 +130,6 @@ func (s *TransactionBuilderTestSuite) newTestBuilderWithFallback(
common.HexToAddress(os.Getenv("TAIKO_L1")),
common.Address{},
10_000_000,
"test_fallback_builder",
chainConfig,
txmgrSelector,
true,
Expand Down

0 comments on commit 05953ae

Please sign in to comment.