Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add maxL2GasPrice #2294

Merged
merged 6 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ func Test_Defaults(t *testing.T) {
path: "L2GasPriceSuggester.DefaultGasPriceWei",
expectedValue: uint64(2000000000),
},
{
path: "L2GasPriceSuggester.MaxGasPriceWei",
expectedValue: uint64(0),
},
{
path: "MTClient.URI",
expectedValue: "zkevm-prover:50061",
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Type = "follower"
UpdatePeriod = "10s"
Factor = 0.15
DefaultGasPriceWei = 2000000000
MaxGasPriceWei = 0
CleanHistoryPeriod = "1h"
CleanHistoryTimeRetention = "5m"

Expand Down
1 change: 1 addition & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ PrivateKeys = [
[L2GasPriceSuggester]
Type = "default"
DefaultGasPriceWei = 1000000000
MaxGasPriceWei = 0

[MTClient]
URI = "zkevm-prover:50061"
Expand Down
1 change: 1 addition & 0 deletions gasprice/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
Type EstimatorType `mapstructure:"Type"`

DefaultGasPriceWei uint64 `mapstructure:"DefaultGasPriceWei"`
MaxGasPriceWei uint64 `mapstructure:"MaxGasPriceWei"`
MaxPrice *big.Int `mapstructure:"MaxPrice"`
IgnorePrice *big.Int `mapstructure:"IgnorePrice"`
CheckBlocks int `mapstructure:"CheckBlocks"`
Expand Down
5 changes: 5 additions & 0 deletions gasprice/follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func (f *FollowerGasPrice) UpdateGasPriceAvg() {
log.Warn("setting minGasPrice for L2")
result = minGasPrice
}
maxGasPrice := new(big.Int).SetUint64(f.cfg.MaxGasPriceWei)
if f.cfg.MaxGasPriceWei > 0 && result.Cmp(maxGasPrice) == 1 { // result > maxGasPrice
log.Warn("setting maxGasPrice for L2")
ToniRamirezM marked this conversation as resolved.
Show resolved Hide resolved
result = maxGasPrice
}
var truncateValue *big.Int
log.Debug("Full L2 gas price value: ", result, ". Length: ", len(result.String()))
numLength := len(result.String())
Expand Down
1 change: 1 addition & 0 deletions test/config/debug.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ PrivateKeys = [
[L2GasPriceSuggester]
Type = "default"
DefaultGasPriceWei = 1000000000
MaxGasPriceWei = 0

[MTClient]
URI = "127.0.0.1:50061"
Expand Down
1 change: 1 addition & 0 deletions test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Type = "default"
UpdatePeriod = "10s"
Factor = 0.5
DefaultGasPriceWei = 1000000000
MaxGasPriceWei = 0

[MTClient]
URI = "zkevm-prover:50061"
Expand Down