Skip to content

Commit

Permalink
consolidate gasless flags (#1211)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Staykov authored Sep 24, 2024
1 parent 3a9d7d4 commit edb5799
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type Config struct {
ForkID11 *big.Int `json:"forkID11,omitempty"`
ForkID12BananaBlock *big.Int `json:"forkID12BananaBlock,omitempty"`

SupportGasless bool `json:"supportGasless,omitempty"`
AllowFreeTransactions bool `json:"allowFreeTransactions,omitempty"`
}

func (c *Config) String() string {
Expand Down
14 changes: 9 additions & 5 deletions cmd/cdk-erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/ledgerwatch/erigon/params"
erigonapp "github.com/ledgerwatch/erigon/turbo/app"
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
"github.com/ledgerwatch/erigon/turbo/node"
"github.com/ledgerwatch/erigon/turbo/logging"
"github.com/ledgerwatch/erigon/turbo/node"
)

func main() {
Expand Down Expand Up @@ -109,13 +109,17 @@ func setFlagsFromConfigFile(ctx *cli.Context, filePath string) error {
for i, v := range sliceInterface {
s[i] = fmt.Sprintf("%v", v)
}
err := ctx.Set(key, strings.Join(s, ","))
if err != nil {
if err := ctx.Set(key, strings.Join(s, ",")); err != nil {
if deprecatedFlag, found := erigoncli.DeprecatedFlags[key]; found {
return fmt.Errorf("failed setting %s flag Flag is deprecated, use %s instead", key, deprecatedFlag)
}
return fmt.Errorf("failed setting %s flag with values=%s error=%s", key, s, err)
}
} else {
err := ctx.Set(key, fmt.Sprintf("%v", value))
if err != nil {
if err := ctx.Set(key, fmt.Sprintf("%v", value)); err != nil {
if deprecatedFlag, found := erigoncli.DeprecatedFlags[key]; found {
return fmt.Errorf("failed setting %s flag Flag is deprecated, use %s instead", key, deprecatedFlag)
}
return fmt.Errorf("failed setting %s flag with value=%v error=%s", key, value, err)
}
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,6 @@ var (
Usage: "Disable the virtual counters. This has an effect on on sequencer node and when external executor is not enabled.",
Value: false,
}
SupportGasless = cli.BoolFlag{
Name: "zkevm.gasless",
Usage: "Support gasless transactions",
Value: false,
}
ExecutorPayloadOutput = cli.StringFlag{
Name: "zkevm.executor-payload-output",
Usage: "Output the payload of the executor, serialised requests stored to disk by batch number",
Expand Down
3 changes: 2 additions & 1 deletion consensus/misc/eip1559_zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package misc

import (
"math/big"

"github.com/ledgerwatch/erigon/chain"
"github.com/ledgerwatch/erigon/core/types"
)

func CalcBaseFeeZk(config *chain.Config, parent *types.Header) *big.Int {
if config.SupportGasless {
if config.AllowFreeTransactions {
return big.NewInt(0)
}
if !config.IsLondon(parent.Number.Uint64() + 1) {
Expand Down
4 changes: 1 addition & 3 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// entering ZK territory!
cfg := backend.config

// update the chain config with the zero gas from the flags
backend.chainConfig.SupportGasless = cfg.Gasless

backend.chainConfig.AllowFreeTransactions = cfg.AllowFreeTransactions
l1Urls := strings.Split(cfg.L1RpcUrl, ",")

if cfg.Zk.L1CacheEnabled {
Expand Down
1 change: 0 additions & 1 deletion turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ var DefaultFlags = []cli.Flag{
&utils.DataStreamInactivityCheckInterval,
&utils.WitnessFullFlag,
&utils.SyncLimit,
&utils.SupportGasless,
&utils.ExecutorPayloadOutput,
&utils.DebugTimers,
&utils.DebugNoSync,
Expand Down
5 changes: 4 additions & 1 deletion turbo/cli/flags_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/urfave/cli/v2"
)

var DeprecatedFlags = map[string]string{
"zkevm.gasless": "zkevm.allow-free-transactions",
}

func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
checkFlag := func(flagName string, value interface{}) {
switch v := value.(type) {
Expand Down Expand Up @@ -163,7 +167,6 @@ func ApplyFlagsForZkConfig(ctx *cli.Context, cfg *ethconfig.Config) {
GasPriceFactor: ctx.Float64(utils.GasPriceFactor.Name),
WitnessFull: ctx.Bool(utils.WitnessFullFlag.Name),
SyncLimit: ctx.Uint64(utils.SyncLimit.Name),
Gasless: ctx.Bool(utils.SupportGasless.Name),
DebugTimers: ctx.Bool(utils.DebugTimers.Name),
DebugNoSync: ctx.Bool(utils.DebugNoSync.Name),
DebugLimit: ctx.Uint64(utils.DebugLimit.Name),
Expand Down

0 comments on commit edb5799

Please sign in to comment.