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

remove unit suffix from duration config params #1927

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/0xPolygonHermez/zkevm-node/merkletree"
"github.com/0xPolygonHermez/zkevm-node/metrics"
"github.com/0xPolygonHermez/zkevm-node/pool"
"github.com/0xPolygonHermez/zkevm-node/pricegetter"
"github.com/0xPolygonHermez/zkevm-node/sequencer"
"github.com/0xPolygonHermez/zkevm-node/sequencer/broadcast"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
Expand Down Expand Up @@ -59,7 +58,6 @@ type Config struct {
RPC jsonrpc.Config
Synchronizer synchronizer.Config
Sequencer sequencer.Config
PriceGetter pricegetter.Config
Aggregator aggregator.Config
NetworkConfig NetworkConfig
L2GasPriceSuggester gasprice.Config
Expand Down
37 changes: 10 additions & 27 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/0xPolygonHermez/zkevm-node/config"
"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/pricegetter"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -42,20 +41,12 @@ func Test_Defaults(t *testing.T) {
expectedValue: uint64(100),
},
{
path: "PriceGetter.Type",
expectedValue: pricegetter.DefaultType,
},
{
path: "PriceGetter.DefaultPrice",
expectedValue: pricegetter.TokenPrice{Float: new(big.Float).SetInt64(2000)},
},
{
path: "Sequencer.WaitPeriodPoolIsEmpty",
path: "Sequencer.NotSyncedWait",
expectedValue: types.NewDuration(1 * time.Second),
},
{
path: "Sequencer.LastBatchVirtualizationTimeMaxWaitPeriod",
expectedValue: types.NewDuration(5 * time.Second),
expectedValue: types.NewDuration(time.Hour),
},
{
path: "Sequencer.MaxTxsPerBatch",
Expand Down Expand Up @@ -118,19 +109,19 @@ func Test_Defaults(t *testing.T) {
expectedValue: uint64(131072),
},
{
path: "Sequencer.Finalizer.GERDeadlineTimeoutInSec",
path: "Sequencer.Finalizer.GERDeadlineTimeout",
expectedValue: types.NewDuration(5 * time.Second),
},
{
path: "Sequencer.Finalizer.ForcedBatchDeadlineTimeoutInSec",
path: "Sequencer.Finalizer.ForcedBatchDeadlineTimeout",
expectedValue: types.NewDuration(60 * time.Second),
},
{
path: "Sequencer.Finalizer.SendingToL1DeadlineTimeoutInSec",
path: "Sequencer.Finalizer.SendingToL1DeadlineTimeout",
expectedValue: types.NewDuration(20 * time.Second),
},
{
path: "Sequencer.Finalizer.SleepDurationInMs",
path: "Sequencer.Finalizer.SleepDuration",
expectedValue: types.NewDuration(100 * time.Millisecond),
},
{
Expand Down Expand Up @@ -201,14 +192,6 @@ func Test_Defaults(t *testing.T) {
path: "EthTxManager.ForcedGas",
expectedValue: uint64(0),
},
{
path: "PriceGetter.Type",
expectedValue: pricegetter.DefaultType,
},
{
path: "PriceGetter.DefaultPrice",
expectedValue: pricegetter.TokenPrice{Float: new(big.Float).SetInt64(2000)},
},
{
path: "L2GasPriceSuggester.DefaultGasPriceWei",
expectedValue: uint64(1000000000),
Expand Down Expand Up @@ -307,12 +290,12 @@ func Test_Defaults(t *testing.T) {
expectedValue: int(8123),
},
{
path: "RPC.ReadTimeoutInSec",
expectedValue: time.Duration(60),
path: "RPC.ReadTimeout",
expectedValue: types.NewDuration(60 * time.Second),
},
{
path: "RPC.WriteTimeoutInSec",
expectedValue: time.Duration(60),
path: "RPC.WriteTimeout",
expectedValue: types.NewDuration(60 * time.Second),
},
{
path: "RPC.SequencerNodeURI",
Expand Down
28 changes: 10 additions & 18 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ MaxConns = 200

[Pool]
FreeClaimGasLimit = 150000
MaxTxBytesSize=30132
MaxTxDataBytesSize=30000
MaxTxBytesSize = 30132
MaxTxDataBytesSize = 30000
DefaultMinGasPriceAllowed = 1000000000
MinAllowedGasPriceInterval = "5m"
PollMinAllowedGasPriceInterval = "15s"
Expand Down Expand Up @@ -52,8 +52,8 @@ ForcedGas = 0
[RPC]
Host = "0.0.0.0"
Port = 8123
ReadTimeoutInSec = 60
WriteTimeoutInSec = 60
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 50
SequencerNodeURI = ""
BroadcastURI = "127.0.0.1:61090"
Expand All @@ -70,9 +70,9 @@ GenBlockNumber = 74
TrustedSequencerURL = ""

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
NotSyncedWait = "1s"
WaitPeriodSendSequence = "5s"
LastBatchVirtualizationTimeMaxWaitPeriod = "5s"
LastBatchVirtualizationTimeMaxWaitPeriod = "1h"
BlocksAmountForTxsToBeDeleted = 100
FrequencyToCheckTxsForDelete = "12h"
MaxTxsPerBatch = 150
Expand All @@ -98,10 +98,10 @@ TxLifetimeCheckTimeout = "10m"
MaxTxLifetime = "3h"
MaxTxSizeForL1 = 131072
[Sequencer.Finalizer]
GERDeadlineTimeoutInSec = "5s"
ForcedBatchDeadlineTimeoutInSec = "60s"
SendingToL1DeadlineTimeoutInSec = "20s"
SleepDurationInMs = "100ms"
GERDeadlineTimeout = "5s"
ForcedBatchDeadlineTimeout = "60s"
SendingToL1DeadlineTimeout = "20s"
SleepDuration = "100ms"
ResourcePercentageToCloseBatch = 10
GERFinalityNumberOfBlocks = 64
ClosingSignalsManagerWaitForCheckingL1Timeout = "10s"
Expand All @@ -113,14 +113,9 @@ MaxTxSizeForL1 = 131072
[Sequencer.DBManager]
PoolRetrievalInterval = "500ms"

[PriceGetter]
Type = "default"
DefaultPrice = "2000"

[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "90s"
TxProfitabilityCheckerType = "acceptall"
Expand All @@ -133,9 +128,6 @@ GeneratingProofCleanupThreshold = "10m"
Type = "default"
DefaultGasPriceWei = 1000000000

[Prover]
ProverURI = "0.0.0.0:50051"

[MTClient]
URI = "127.0.0.1:50061"

Expand Down
15 changes: 7 additions & 8 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ MultiGasProvider = false
[RPC]
Host = "0.0.0.0"
Port = 8545
ReadTimeoutInSec = 60
WriteTimeoutInSec = 60
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 5000
SequencerNodeURI = "https://internal.zkevm-test.net:2083/"
BroadcastURI = "internal.zkevm-test.net:61090"
Expand All @@ -61,7 +61,7 @@ GenBlockNumber = 74
TrustedSequencerURL = ""

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
NotSyncedWait = "1s"
WaitPeriodSendSequence = "5s"
LastBatchVirtualizationTimeMaxWaitPeriod = "5s"
BlocksAmountForTxsToBeDeleted = 100
Expand Down Expand Up @@ -89,10 +89,10 @@ TxLifetimeCheckTimeout = "10m"
MaxTxLifetime = "3h"
MaxTxSizeForL1 = 131072
[Sequencer.Finalizer]
GERDeadlineTimeoutInSec = "5s"
ForcedBatchDeadlineTimeoutInSec = "60s"
SendingToL1DeadlineTimeoutInSec = "20s"
SleepDurationInMs = "100ms"
GERDeadlineTimeout = "5s"
ForcedBatchDeadlineTimeout = "60s"
SendingToL1DeadlineTimeout = "20s"
SleepDuration = "100ms"
ResourcePercentageToCloseBatch = 10
GERFinalityNumberOfBlocks = 0
ClosingSignalsManagerWaitForCheckingL1Timeout = "10s"
Expand All @@ -107,7 +107,6 @@ MaxTxSizeForL1 = 131072
[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "30s"
TxProfitabilityCheckerType = "acceptall"
Expand Down
4 changes: 2 additions & 2 deletions config/environments/public/public.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ MultiGasProvider = false
[RPC]
Host = "0.0.0.0"
Port = 8545
ReadTimeoutInSec = 60
WriteTimeoutInSec = 60
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 5000
SequencerNodeURI = "https://rpc.public.zkevm-test.net/"
BroadcastURI = "public-grpc.zkevm-test.net:61090"
Expand Down
54 changes: 54 additions & 0 deletions config/types/duration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package types

import (
"encoding/json"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestDurationUnmarshal(t *testing.T) {
type testCase struct {
name string
input string
expectedResult *Duration
expectedErr error
}

testCases := []testCase{
{
name: "valid duration",
input: "60s",
expectedResult: &Duration{Duration: time.Minute},
},
{
name: "int value",
input: "60",
expectedErr: fmt.Errorf("time: missing unit in duration \"60\""),
},
{
name: "no duration value",
input: "abc",
expectedErr: fmt.Errorf("time: invalid duration \"abc\""),
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
var d Duration
input, err := json.Marshal(testCase.input)
require.NoError(t, err)
err = json.Unmarshal(input, &d)

if testCase.expectedResult != nil {
require.Equal(t, (*testCase.expectedResult).Nanoseconds(), d.Nanoseconds())
}

if err != nil {
require.Equal(t, testCase.expectedErr.Error(), err.Error())
}
})
}
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
zkevm-prover:
container_name: zkevm-prover
restart: unless-stopped
image: hermeznetwork/zkevm-prover:9e70a64
image: hermeznetwork/zkevm-prover:6d6e3aa
depends_on:
zkevm-state-db:
condition: service_healthy
Expand Down
Loading