Skip to content

Commit

Permalink
refactor(taiko-client): rm unused tier fee (#17740)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Jul 5, 2024
1 parent 6fc318a commit 3e139fa
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 132 deletions.
31 changes: 0 additions & 31 deletions packages/taiko-client/cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,6 @@ var (

// Optional flags used by proposer.
var (
// Tier fee related.
OptimisticTierFee = &cli.Float64Flag{
Name: "tierFee.optimistic",
Usage: "Initial tier fee (in GWei) paid to prover to generate an optimistic proofs",
Category: proposerCategory,
EnvVars: []string{"TIER_FEE_OPTIMISTIC"},
}
SgxTierFee = &cli.Float64Flag{
Name: "tierFee.sgx",
Usage: "Initial tier fee (in GWei) paid to prover to generate a SGX proofs",
Category: proposerCategory,
EnvVars: []string{"TIER_FEE_SGX"},
}
TierFeePriceBump = &cli.Uint64Flag{
Name: "tierFee.priceBump",
Usage: "Price bump percentage when no prover wants to accept the block at initial fee",
Value: 10,
Category: proposerCategory,
EnvVars: []string{"TIER_FEE_PRICE_BUMP"},
}
MaxTierFeePriceBumps = &cli.Uint64Flag{
Name: "tierFee.maxPriceBumps",
Usage: "If nobody accepts block at initial tier fee, how many iterations to increase tier fee before giving up",
Category: proposerCategory,
Value: 3,
EnvVars: []string{"TIER_FEE_MAX_PRICE_BUMPS"},
}
// Proposing epoch related.
ProposeInterval = &cli.DurationFlag{
Name: "epoch.interval",
Expand Down Expand Up @@ -167,10 +140,6 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
AllowZeroInterval,
MaxProposedTxListsPerEpoch,
ProverEndpoints,
OptimisticTierFee,
SgxTierFee,
TierFeePriceBump,
MaxTierFeePriceBumps,
ProposeBlockIncludeParentMetaHash,
BlobAllowed,
}, TxmgrFlags)
4 changes: 0 additions & 4 deletions packages/taiko-client/driver/chain_syncer/blob/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ func (s *BlobSyncerTestSuite) initProposer() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
ExtraData: "test",
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
Expand Down
4 changes: 0 additions & 4 deletions packages/taiko-client/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,6 @@ func (s *DriverTestSuite) InitProposer() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 0,
Expand Down
19 changes: 0 additions & 19 deletions packages/taiko-client/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package proposer
import (
"crypto/ecdsa"
"fmt"
"math/big"
"net/url"
"strings"
"time"
Expand Down Expand Up @@ -38,10 +37,6 @@ type Config struct {
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit uint64
ProverEndpoints []*url.URL
OptimisticTierFee *big.Int
SgxTierFee *big.Int
TierFeePriceBump *big.Int
MaxTierFeePriceBumps uint64
IncludeParentMetaHash bool
BlobAllowed bool
TxmgrConfigs *txmgr.CLIConfig
Expand Down Expand Up @@ -84,16 +79,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
proverEndpoints = append(proverEndpoints, endpoint)
}

optimisticTierFee, err := utils.GWeiToWei(c.Float64(flags.OptimisticTierFee.Name))
if err != nil {
return nil, err
}

sgxTierFee, err := utils.GWeiToWei(c.Float64(flags.SgxTierFee.Name))
if err != nil {
return nil, err
}

minTip, err := utils.GWeiToWei(c.Float64(flags.MinTip.Name))
if err != nil {
return nil, err
Expand Down Expand Up @@ -125,10 +110,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
AllowZeroInterval: c.Uint64(flags.AllowZeroInterval.Name),
ProposeBlockTxGasLimit: c.Uint64(flags.TxGasLimit.Name),
ProverEndpoints: proverEndpoints,
OptimisticTierFee: optimisticTierFee,
SgxTierFee: sgxTierFee,
TierFeePriceBump: new(big.Int).SetUint64(c.Uint64(flags.TierFeePriceBump.Name)),
MaxTierFeePriceBumps: c.Uint64(flags.MaxTierFeePriceBumps.Name),
IncludeParentMetaHash: c.Bool(flags.ProposeBlockIncludeParentMetaHash.Name),
BlobAllowed: c.Bool(flags.BlobAllowed.Name),
TxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli(
Expand Down
17 changes: 0 additions & 17 deletions packages/taiko-client/proposer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package proposer

import (
"context"
"fmt"
"os"
"strings"
"time"
Expand All @@ -13,7 +12,6 @@ import (

"github.com/taikoxyz/taiko-mono/packages/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/cmd/flags"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/utils"
)

var (
Expand All @@ -23,7 +21,6 @@ var (
taikoL2 = os.Getenv("TAIKO_L2_ADDRESS")
taikoToken = os.Getenv("TAIKO_TOKEN_ADDRESS")
proverEndpoints = "http://localhost:9876,http://localhost:1234"
tierFee = 100.0
proposeInterval = "10s"
rpcTimeout = "5s"
)
Expand All @@ -48,12 +45,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
s.Equal(1, len(c.LocalAddresses))
s.Equal(goldenTouchAddress, c.LocalAddresses[0])
s.Equal(5*time.Second, c.Timeout)
tierFeeGWei, err := utils.GWeiToWei(tierFee)
s.Nil(err)
s.Equal(tierFeeGWei.Uint64(), c.OptimisticTierFee.Uint64())
s.Equal(tierFeeGWei.Uint64(), c.SgxTierFee.Uint64())
s.Equal(uint64(15), c.TierFeePriceBump.Uint64())
s.Equal(uint64(5), c.MaxTierFeePriceBumps)
s.Equal(true, c.IncludeParentMetaHash)

for i, e := range strings.Split(proverEndpoints, ",") {
Expand All @@ -78,10 +69,6 @@ func (s *ProposerTestSuite) TestNewConfigFromCliContext() {
"--" + flags.RPCTimeout.Name, rpcTimeout,
"--" + flags.TxGasLimit.Name, "100000",
"--" + flags.ProverEndpoints.Name, proverEndpoints,
"--" + flags.OptimisticTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.SgxTierFee.Name, fmt.Sprint(tierFee),
"--" + flags.TierFeePriceBump.Name, "15",
"--" + flags.MaxTierFeePriceBumps.Name, "5",
"--" + flags.ProposeBlockIncludeParentMetaHash.Name, "true",
}))
}
Expand Down Expand Up @@ -137,11 +124,7 @@ func (s *ProposerTestSuite) SetupApp() *cli.App {
&cli.DurationFlag{Name: flags.ProposeInterval.Name},
&cli.StringFlag{Name: flags.TxPoolLocals.Name},
&cli.StringFlag{Name: flags.ProverEndpoints.Name},
&cli.Uint64Flag{Name: flags.OptimisticTierFee.Name},
&cli.Uint64Flag{Name: flags.SgxTierFee.Name},
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
&cli.Uint64Flag{Name: flags.TierFeePriceBump.Name},
&cli.Uint64Flag{Name: flags.MaxTierFeePriceBumps.Name},
&cli.BoolFlag{Name: flags.ProposeBlockIncludeParentMetaHash.Name},
}
app.Flags = append(app.Flags, flags.TxmgrFlags...)
Expand Down
38 changes: 1 addition & 37 deletions packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package proposer

import (
"bytes"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -40,8 +39,7 @@ type Proposer struct {

proposingTimer *time.Timer

tiers []*rpc.TierProviderTierWithID
tierFees []encoding.TierFee
tiers []*rpc.TierProviderTierWithID

// Transaction builder
txBuilder builder.ProposeBlockTransactionBuilder
Expand Down Expand Up @@ -92,9 +90,6 @@ func (p *Proposer) InitFromConfig(ctx context.Context, cfg *Config, txMgr *txmgr
if p.tiers, err = p.rpc.GetTiers(ctx); err != nil {
return err
}
if err := p.initTierFees(); err != nil {
return err
}

if txMgr != nil {
p.txmgr = txMgr
Expand Down Expand Up @@ -400,34 +395,3 @@ func (p *Proposer) updateProposingTicker() {
func (p *Proposer) Name() string {
return "proposer"
}

// initTierFees initializes the proving fees for every proof tier configured in the protocol for the proposer.
func (p *Proposer) initTierFees() error {
for _, tier := range p.tiers {
log.Info(
"Protocol tier",
"id", tier.ID,
"name", string(bytes.TrimRight(tier.VerifierName[:], "\x00")),
"validityBond", utils.WeiToEther(tier.ValidityBond),
"contestBond", utils.WeiToEther(tier.ContestBond),
"provingWindow", tier.ProvingWindow,
"cooldownWindow", tier.CooldownWindow,
)

switch tier.ID {
case encoding.TierOptimisticID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.OptimisticTierFee})
case encoding.TierSgxID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: p.SgxTierFee})
case encoding.TierGuardianMinorityID:
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: common.Big0})
case encoding.TierGuardianMajorityID:
// Guardian prover should not charge any fee.
p.tierFees = append(p.tierFees, encoding.TierFee{Tier: tier.ID, Fee: common.Big0})
default:
return fmt.Errorf("unknown tier: %d", tier.ID)
}
}

return nil
}
4 changes: 0 additions & 4 deletions packages/taiko-client/proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ func (s *ProposerTestSuite) SetupTest() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
TierFeePriceBump: common.Big2,
MaxTierFeePriceBumps: 3,
ExtraData: "test",
ProposeBlockTxGasLimit: 10_000_000,
TxmgrConfigs: &txmgr.CLIConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ func (s *EventHandlerTestSuite) SetupTest() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
TxmgrConfigs: &txmgr.CLIConfig{
L1RPCURL: os.Getenv("L1_NODE_WS_ENDPOINT"),
NumConfirmations: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: s.ProverEndpoints,
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
}, txMgr))

s.proposer = prop
Expand Down
4 changes: 0 additions & 4 deletions packages/taiko-client/prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ func (s *ProverTestSuite) SetupTest() {
ProposeInterval: 1024 * time.Hour,
MaxProposedTxListsPerEpoch: 1,
ProverEndpoints: []*url.URL{proverServerURL},
OptimisticTierFee: common.Big256,
SgxTierFee: common.Big256,
MaxTierFeePriceBumps: 3,
TierFeePriceBump: common.Big2,
}, s.txmgr))

s.proposer = prop
Expand Down

0 comments on commit 3e139fa

Please sign in to comment.