From 57075d000d1a6396c33d42e5da97be19bfcfb6f1 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Mon, 5 Dec 2022 19:21:33 +0530 Subject: [PATCH] Add support for new flags in new config.toml, which were present in old config.toml (#612) * added HTTPTimeouts, and TrieTimeout flag in new tol, from old toml * added RAW fields for these time.Duration flags * updated the conversion script to support these extra 4 flags * removed hcl and json config tests as we are only supporting toml config files * updated toml files with cache.timeout field * updated toml files with jsonrpc.timeouts field * tests/bor: expect a call for latest checkpoint * tests/bor: expect a call for latest checkpoint * packaging/templates: update cache values for archive nodes Co-authored-by: Manav Darji --- builder/files/config.toml | 57 ++++++++++--------- docs/cli/example_config.toml | 5 ++ internal/cli/dumpconfig.go | 4 ++ internal/cli/server/config.go | 50 ++++++++++++++++ internal/cli/server/config_test.go | 33 ----------- internal/cli/server/testdata/test.hcl | 13 ----- internal/cli/server/testdata/test.json | 12 ---- .../templates/mainnet-v1/archive/config.toml | 11 +++- .../mainnet-v1/sentry/sentry/bor/config.toml | 5 ++ .../sentry/validator/bor/config.toml | 5 ++ .../mainnet-v1/without-sentry/bor/config.toml | 5 ++ .../templates/testnet-v4/archive/config.toml | 13 +++-- .../testnet-v4/sentry/sentry/bor/config.toml | 5 ++ .../sentry/validator/bor/config.toml | 5 ++ .../testnet-v4/without-sentry/bor/config.toml | 5 ++ scripts/getconfig.go | 30 +++++++++- scripts/getconfig.sh | 48 ++++++++++++++++ tests/bor/bor_test.go | 26 ++++++--- 18 files changed, 233 insertions(+), 99 deletions(-) delete mode 100644 internal/cli/server/testdata/test.hcl delete mode 100644 internal/cli/server/testdata/test.json diff --git a/builder/files/config.toml b/builder/files/config.toml index e2267469bb..fc95cd1a64 100644 --- a/builder/files/config.toml +++ b/builder/files/config.toml @@ -61,32 +61,36 @@ syncmode = "full" # [jsonrpc] - # ipcdisable = false - # ipcpath = "" - # gascap = 50000000 - # txfeecap = 5.0 - # [jsonrpc.http] - # enabled = false - # port = 8545 - # prefix = "" - # host = "localhost" - # api = ["eth", "net", "web3", "txpool", "bor"] - # vhosts = ["*"] - # corsdomain = ["*"] - # [jsonrpc.ws] - # enabled = false - # port = 8546 - # prefix = "" - # host = "localhost" - # api = ["web3", "net"] - # origins = ["*"] - # [jsonrpc.graphql] - # enabled = false - # port = 0 - # prefix = "" - # host = "" - # vhosts = ["*"] - # corsdomain = ["*"] +# ipcdisable = false +# ipcpath = "" +# gascap = 50000000 +# txfeecap = 5.0 +# [jsonrpc.http] +# enabled = false +# port = 8545 +# prefix = "" +# host = "localhost" +# api = ["eth", "net", "web3", "txpool", "bor"] +# vhosts = ["*"] +# corsdomain = ["*"] +# [jsonrpc.ws] +# enabled = false +# port = 8546 +# prefix = "" +# host = "localhost" +# api = ["web3", "net"] +# origins = ["*"] +# [jsonrpc.graphql] +# enabled = false +# port = 0 +# prefix = "" +# host = "" +# vhosts = ["*"] +# corsdomain = ["*"] +# [jsonrpc.timeouts] +# read = "30s" +# write = "30s" +# idle = "2m0s" [gpo] # blocks = 20 @@ -122,6 +126,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" [accounts] # allow-insecure-unlock = true diff --git a/docs/cli/example_config.toml b/docs/cli/example_config.toml index cdf2a989d7..64ef60ae12 100644 --- a/docs/cli/example_config.toml +++ b/docs/cli/example_config.toml @@ -86,6 +86,10 @@ ethstats = "" # Reporting URL of a ethstats service (nodename:sec host = "" # vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. corsdomain = ["localhost"] # Comma separated list of domains from which to accept cross origin requests (browser enforced) + [jsonrpc.timeouts] + read = "30s" + write = "30s" + idle = "2m0s" [gpo] blocks = 20 # Number of recent blocks to check for gas prices @@ -126,6 +130,7 @@ ethstats = "" # Reporting URL of a ethstats service (nodename:sec preimages = false # Enable recording the SHA3/keccak preimages of trie keys txlookuplimit = 2350000 # Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain) triesinmemory = 128 # Number of block states (tries) to keep in memory + timeout = "1h0m0s" # Time after which the Merkle Patricia Trie is stored to disc from memory [accounts] unlock = [] # Comma separated list of accounts to unlock diff --git a/internal/cli/dumpconfig.go b/internal/cli/dumpconfig.go index dad0be923d..a748af3357 100644 --- a/internal/cli/dumpconfig.go +++ b/internal/cli/dumpconfig.go @@ -52,12 +52,16 @@ func (c *DumpconfigCommand) Run(args []string) int { userConfig := command.GetConfig() // convert the big.Int and time.Duration fields to their corresponding Raw fields + userConfig.JsonRPC.HttpTimeout.ReadTimeoutRaw = userConfig.JsonRPC.HttpTimeout.ReadTimeout.String() + userConfig.JsonRPC.HttpTimeout.WriteTimeoutRaw = userConfig.JsonRPC.HttpTimeout.WriteTimeout.String() + userConfig.JsonRPC.HttpTimeout.IdleTimeoutRaw = userConfig.JsonRPC.HttpTimeout.IdleTimeout.String() userConfig.TxPool.RejournalRaw = userConfig.TxPool.Rejournal.String() userConfig.TxPool.LifeTimeRaw = userConfig.TxPool.LifeTime.String() userConfig.Sealer.GasPriceRaw = userConfig.Sealer.GasPrice.String() userConfig.Gpo.MaxPriceRaw = userConfig.Gpo.MaxPrice.String() userConfig.Gpo.IgnorePriceRaw = userConfig.Gpo.IgnorePrice.String() userConfig.Cache.RejournalRaw = userConfig.Cache.Rejournal.String() + userConfig.Cache.TrieTimeoutRaw = userConfig.Cache.TrieTimeout.String() if err := toml.NewEncoder(os.Stdout).Encode(userConfig); err != nil { c.UI.Error(err.Error()) diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 6bbe3d781a..5657e85b20 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -33,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rpc" ) type Config struct { @@ -238,6 +239,8 @@ type JsonRPCConfig struct { // Graphql has the json-rpc graphql related settings Graphql *APIConfig `hcl:"graphql,block" toml:"graphql,block"` + + HttpTimeout *HttpTimeouts `hcl:"timeouts,block" toml:"timeouts,block"` } type GRPCConfig struct { @@ -271,6 +274,33 @@ type APIConfig struct { Origins []string `hcl:"origins,optional" toml:"origins,optional"` } +// Used from rpc.HTTPTimeouts +type HttpTimeouts struct { + // ReadTimeout is the maximum duration for reading the entire + // request, including the body. + // + // Because ReadTimeout does not let Handlers make per-request + // decisions on each request body's acceptable deadline or + // upload rate, most users will prefer to use + // ReadHeaderTimeout. It is valid to use them both. + ReadTimeout time.Duration `hcl:"-,optional" toml:"-"` + ReadTimeoutRaw string `hcl:"read,optional" toml:"read,optional"` + + // WriteTimeout is the maximum duration before timing out + // writes of the response. It is reset whenever a new + // request's header is read. Like ReadTimeout, it does not + // let Handlers make decisions on a per-request basis. + WriteTimeout time.Duration `hcl:"-,optional" toml:"-"` + WriteTimeoutRaw string `hcl:"write,optional" toml:"write,optional"` + + // IdleTimeout is the maximum amount of time to wait for the + // next request when keep-alives are enabled. If IdleTimeout + // is zero, the value of ReadTimeout is used. If both are + // zero, ReadHeaderTimeout is used. + IdleTimeout time.Duration `hcl:"-,optional" toml:"-"` + IdleTimeoutRaw string `hcl:"idle,optional" toml:"idle,optional"` +} + type GpoConfig struct { // Blocks is the number of blocks to track to compute the price oracle Blocks uint64 `hcl:"blocks,optional" toml:"blocks,optional"` @@ -367,6 +397,10 @@ type CacheConfig struct { // TxLookupLimit sets the maximum number of blocks from head whose tx indices are reserved. TxLookupLimit uint64 `hcl:"txlookuplimit,optional" toml:"txlookuplimit,optional"` + + // Time after which the Merkle Patricia Trie is stored to disc from memory + TrieTimeout time.Duration `hcl:"-,optional" toml:"-"` + TrieTimeoutRaw string `hcl:"timeout,optional" toml:"timeout,optional"` } type AccountsConfig struct { @@ -480,6 +514,11 @@ func DefaultConfig() *Config { Cors: []string{"localhost"}, VHost: []string{"localhost"}, }, + HttpTimeout: &HttpTimeouts{ + ReadTimeout: 30 * time.Second, + WriteTimeout: 30 * time.Second, + IdleTimeout: 120 * time.Second, + }, }, Ethstats: "", Telemetry: &TelemetryConfig{ @@ -511,6 +550,7 @@ func DefaultConfig() *Config { NoPrefetch: false, Preimages: false, TxLookupLimit: 2350000, + TrieTimeout: 60 * time.Minute, }, Accounts: &AccountsConfig{ Unlock: []string{}, @@ -570,9 +610,13 @@ func (c *Config) fillTimeDurations() error { td *time.Duration str *string }{ + {"jsonrpc.timeouts.read", &c.JsonRPC.HttpTimeout.ReadTimeout, &c.JsonRPC.HttpTimeout.ReadTimeoutRaw}, + {"jsonrpc.timeouts.write", &c.JsonRPC.HttpTimeout.WriteTimeout, &c.JsonRPC.HttpTimeout.WriteTimeoutRaw}, + {"jsonrpc.timeouts.idle", &c.JsonRPC.HttpTimeout.IdleTimeout, &c.JsonRPC.HttpTimeout.IdleTimeoutRaw}, {"txpool.lifetime", &c.TxPool.LifeTime, &c.TxPool.LifeTimeRaw}, {"txpool.rejournal", &c.TxPool.Rejournal, &c.TxPool.RejournalRaw}, {"cache.rejournal", &c.Cache.Rejournal, &c.Cache.RejournalRaw}, + {"cache.timeout", &c.Cache.TrieTimeout, &c.Cache.TrieTimeoutRaw}, } for _, x := range tds { @@ -830,6 +874,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* n.NoPrefetch = c.Cache.NoPrefetch n.Preimages = c.Cache.Preimages n.TxLookupLimit = c.Cache.TxLookupLimit + n.TrieTimeout = c.Cache.TrieTimeout } n.RPCGasCap = c.JsonRPC.GasCap @@ -928,6 +973,11 @@ func (c *Config) buildNode() (*node.Config, error) { WSPathPrefix: c.JsonRPC.Ws.Prefix, GraphQLCors: c.JsonRPC.Graphql.Cors, GraphQLVirtualHosts: c.JsonRPC.Graphql.VHost, + HTTPTimeouts: rpc.HTTPTimeouts{ + ReadTimeout: c.JsonRPC.HttpTimeout.ReadTimeout, + WriteTimeout: c.JsonRPC.HttpTimeout.WriteTimeout, + IdleTimeout: c.JsonRPC.HttpTimeout.IdleTimeout, + }, } // dev mode diff --git a/internal/cli/server/config_test.go b/internal/cli/server/config_test.go index 5f3118996b..3e6bb76b59 100644 --- a/internal/cli/server/config_test.go +++ b/internal/cli/server/config_test.go @@ -1,7 +1,6 @@ package server import ( - "math/big" "testing" "time" @@ -101,38 +100,6 @@ func TestDefaultDatatypeOverride(t *testing.T) { assert.Equal(t, c0, expected) } -func TestConfigLoadFile(t *testing.T) { - readFile := func(path string) { - config, err := readConfigFile(path) - assert.NoError(t, err) - - assert.Equal(t, config, &Config{ - DataDir: "./data", - P2P: &P2PConfig{ - MaxPeers: 30, - }, - TxPool: &TxPoolConfig{ - LifeTime: 1 * time.Second, - }, - Gpo: &GpoConfig{ - MaxPrice: big.NewInt(100), - }, - Sealer: &SealerConfig{}, - Cache: &CacheConfig{}, - }) - } - - // read file in hcl format - t.Run("hcl", func(t *testing.T) { - readFile("./testdata/test.hcl") - }) - - // read file in json format - t.Run("json", func(t *testing.T) { - readFile("./testdata/test.json") - }) -} - var dummyEnodeAddr = "enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303" func TestConfigBootnodesDefault(t *testing.T) { diff --git a/internal/cli/server/testdata/test.hcl b/internal/cli/server/testdata/test.hcl deleted file mode 100644 index 44138970fc..0000000000 --- a/internal/cli/server/testdata/test.hcl +++ /dev/null @@ -1,13 +0,0 @@ -datadir = "./data" - -p2p { - maxpeers = 30 -} - -txpool { - lifetime = "1s" -} - -gpo { - maxprice = "100" -} \ No newline at end of file diff --git a/internal/cli/server/testdata/test.json b/internal/cli/server/testdata/test.json deleted file mode 100644 index a08e5aceb1..0000000000 --- a/internal/cli/server/testdata/test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "datadir": "./data", - "p2p": { - "maxpeers": 30 - }, - "txpool": { - "lifetime": "1s" - }, - "gpo": { - "maxprice": "100" - } -} \ No newline at end of file diff --git a/packaging/templates/mainnet-v1/archive/config.toml b/packaging/templates/mainnet-v1/archive/config.toml index a0eda44c15..9eaafd3bee 100644 --- a/packaging/templates/mainnet-v1/archive/config.toml +++ b/packaging/templates/mainnet-v1/archive/config.toml @@ -79,6 +79,10 @@ gcmode = "archive" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" [gpo] # blocks = 20 @@ -105,15 +109,16 @@ gcmode = "archive" [cache] cache = 4096 - # gc = 25 - # snapshot = 10 + gc = 0 + snapshot = 20 # database = 50 - # trie = 15 + trie = 30 # journal = "triecache" # rejournal = "1h0m0s" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" # [accounts] # unlock = [] diff --git a/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml b/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml index b6d6b34f4d..94dd6634f0 100644 --- a/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml +++ b/packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml @@ -79,6 +79,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" [gpo] # blocks = 20 @@ -114,6 +118,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" # [accounts] # unlock = [] diff --git a/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml b/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml index e0a9be320f..9c55683c96 100644 --- a/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml +++ b/packaging/templates/mainnet-v1/sentry/validator/bor/config.toml @@ -81,6 +81,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" [gpo] # blocks = 20 @@ -116,6 +120,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" [accounts] allow-insecure-unlock = true diff --git a/packaging/templates/mainnet-v1/without-sentry/bor/config.toml b/packaging/templates/mainnet-v1/without-sentry/bor/config.toml index b316ce4e8f..573f1f3be8 100644 --- a/packaging/templates/mainnet-v1/without-sentry/bor/config.toml +++ b/packaging/templates/mainnet-v1/without-sentry/bor/config.toml @@ -81,6 +81,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" [gpo] # blocks = 20 @@ -116,6 +120,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 +# timeout = "1h0m0s" [accounts] allow-insecure-unlock = true diff --git a/packaging/templates/testnet-v4/archive/config.toml b/packaging/templates/testnet-v4/archive/config.toml index ce0d0ff983..1762fdf117 100644 --- a/packaging/templates/testnet-v4/archive/config.toml +++ b/packaging/templates/testnet-v4/archive/config.toml @@ -79,6 +79,10 @@ gcmode = "archive" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" # [gpo] # blocks = 20 @@ -103,17 +107,18 @@ gcmode = "archive" # organization = "" # [telemetry.influx.tags] -# [cache] +[cache] # cache = 1024 - # gc = 25 - # snapshot = 10 + gc = 0 + snapshot = 20 # database = 50 - # trie = 15 + trie = 30 # journal = "triecache" # rejournal = "1h0m0s" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" # [accounts] # unlock = [] diff --git a/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml b/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml index 3655478d45..ae191cec2c 100644 --- a/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml +++ b/packaging/templates/testnet-v4/sentry/sentry/bor/config.toml @@ -79,6 +79,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" # [gpo] # blocks = 20 @@ -114,6 +118,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" # [accounts] # unlock = [] diff --git a/packaging/templates/testnet-v4/sentry/validator/bor/config.toml b/packaging/templates/testnet-v4/sentry/validator/bor/config.toml index 9d30428205..b441cc137d 100644 --- a/packaging/templates/testnet-v4/sentry/validator/bor/config.toml +++ b/packaging/templates/testnet-v4/sentry/validator/bor/config.toml @@ -81,6 +81,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" # [gpo] # blocks = 20 @@ -116,6 +120,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 + # timeout = "1h0m0s" [accounts] allow-insecure-unlock = true diff --git a/packaging/templates/testnet-v4/without-sentry/bor/config.toml b/packaging/templates/testnet-v4/without-sentry/bor/config.toml index 0e0aeae3a1..05a254e184 100644 --- a/packaging/templates/testnet-v4/without-sentry/bor/config.toml +++ b/packaging/templates/testnet-v4/without-sentry/bor/config.toml @@ -81,6 +81,10 @@ syncmode = "full" # host = "" # vhosts = ["*"] # corsdomain = ["*"] + # [jsonrpc.timeouts] + # read = "30s" + # write = "30s" + # idle = "2m0s" # [gpo] # blocks = 20 @@ -116,6 +120,7 @@ syncmode = "full" # noprefetch = false # preimages = false # txlookuplimit = 2350000 +# timeout = "1h0m0s" [accounts] allow-insecure-unlock = true diff --git a/scripts/getconfig.go b/scripts/getconfig.go index 7fbd39ac6d..59e3ff749d 100644 --- a/scripts/getconfig.go +++ b/scripts/getconfig.go @@ -357,6 +357,34 @@ func writeTempStaticTrustedTOML(path string) { log.Fatal(err) } } + + if data.Has("Node.HTTPTimeouts.ReadTimeout") { + err = os.WriteFile("./tempHTTPTimeoutsReadTimeout.toml", []byte(data.Get("Node.HTTPTimeouts.ReadTimeout").(string)), 0600) + if err != nil { + log.Fatal(err) + } + } + + if data.Has("Node.HTTPTimeouts.WriteTimeout") { + err = os.WriteFile("./tempHTTPTimeoutsWriteTimeout.toml", []byte(data.Get("Node.HTTPTimeouts.WriteTimeout").(string)), 0600) + if err != nil { + log.Fatal(err) + } + } + + if data.Has("Node.HTTPTimeouts.IdleTimeout") { + err = os.WriteFile("./tempHTTPTimeoutsIdleTimeout.toml", []byte(data.Get("Node.HTTPTimeouts.IdleTimeout").(string)), 0600) + if err != nil { + log.Fatal(err) + } + } + + if data.Has("Eth.TrieTimeout") { + err = os.WriteFile("./tempHTTPTimeoutsTrieTimeout.toml", []byte(data.Get("Eth.TrieTimeout").(string)), 0600) + if err != nil { + log.Fatal(err) + } + } } func getStaticTrustedNodes(args []string) { @@ -574,7 +602,7 @@ func commentFlags(path string, updatedArgs []string) { flag = strconv.Itoa(passwordFlag) + "-" + flag } - if flag != "static-nodes" && flag != "trusted-nodes" { + if flag != "static-nodes" && flag != "trusted-nodes" && flag != "read" && flag != "write" && flag != "idle" && flag != "timeout" { flag = nameTagMap[flag] tempFlag := false diff --git a/scripts/getconfig.sh b/scripts/getconfig.sh index 472af08802..d00bf35ec8 100755 --- a/scripts/getconfig.sh +++ b/scripts/getconfig.sh @@ -112,6 +112,54 @@ else echo "neither JSON nor TOML TrustedNodes found" fi +if [[ -f ./tempHTTPTimeoutsReadTimeout.toml ]] +then + echo "HTTPTimeouts.ReadTimeout found" + read=$(head -1 ./tempHTTPTimeoutsReadTimeout.toml) + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%read = \"30s\"%read = \"${read}\"%" $confPath + else + sed -i "s%read = \"30s\"%read = \"${read}\"%" $confPath + fi + rm ./tempHTTPTimeoutsReadTimeout.toml +fi + +if [[ -f ./tempHTTPTimeoutsWriteTimeout.toml ]] +then + echo "HTTPTimeouts.WriteTimeout found" + write=$(head -1 ./tempHTTPTimeoutsWriteTimeout.toml) + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%write = \"30s\"%write = \"${write}\"%" $confPath + else + sed -i "s%write = \"30s\"%write = \"${write}\"%" $confPath + fi + rm ./tempHTTPTimeoutsWriteTimeout.toml +fi + +if [[ -f ./tempHTTPTimeoutsIdleTimeout.toml ]] +then + echo "HTTPTimeouts.IdleTimeout found" + idle=$(head -1 ./tempHTTPTimeoutsIdleTimeout.toml) + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%idle = \"2m0s\"%idle = \"${idle}\"%" $confPath + else + sed -i "s%idle = \"2m0s\"%idle = \"${idle}\"%" $confPath + fi + rm ./tempHTTPTimeoutsIdleTimeout.toml +fi + +if [[ -f ./tempHTTPTimeoutsTrieTimeout.toml ]] +then + echo "Eth.TrieTimeout found" + timeout=$(head -1 ./tempHTTPTimeoutsTrieTimeout.toml) + shopt -s nocasematch; if [[ "$OS" == "darwin"* ]]; then + sed -i '' "s%timeout = \"1h0m0s\"%timeout = \"${timeout}\"%" $confPath + else + sed -i "s%timeout = \"1h0m0s\"%timeout = \"${timeout}\"%" $confPath + fi + rm ./tempHTTPTimeoutsTrieTimeout.toml +fi + printf "\n" # comment flags in $configPath that were not passed through $startPath diff --git a/tests/bor/bor_test.go b/tests/bor/bor_test.go index 36d515c557..243b0182bb 100644 --- a/tests/bor/bor_test.go +++ b/tests/bor/bor_test.go @@ -101,6 +101,11 @@ func TestFetchStateSyncEvents(t *testing.T) { h := mocks.NewMockIHeimdallClient(ctrl) h.EXPECT().Close().AnyTimes() h.EXPECT().Span(uint64(1)).Return(&res.Result, nil).AnyTimes() + h.EXPECT().FetchLatestCheckpoint().Return(&checkpoint.Checkpoint{ + StartBlock: big.NewInt(1), + EndBlock: big.NewInt(2), + RootHash: common.Hash{}, + }, nil).AnyTimes() // B.2 Mock State Sync events fromID := uint64(1) @@ -136,6 +141,11 @@ func TestFetchStateSyncEvents_2(t *testing.T) { h := mocks.NewMockIHeimdallClient(ctrl) h.EXPECT().Close().AnyTimes() h.EXPECT().Span(uint64(1)).Return(&res.Result, nil).AnyTimes() + h.EXPECT().FetchLatestCheckpoint().Return(&checkpoint.Checkpoint{ + StartBlock: big.NewInt(1), + EndBlock: big.NewInt(2), + RootHash: common.Hash{}, + }, nil).AnyTimes() // Mock State Sync events // at # sprintSize, events are fetched for [fromID, (block-sprint).Time) @@ -287,6 +297,8 @@ func getMockedHeimdallClient(t *testing.T) (*mocks.MockIHeimdallClient, *span.He h.EXPECT().StateSyncEvents(gomock.Any(), gomock.Any()). Return([]*clerk.EventRecordWithTime{getSampleEventRecord(t)}, nil).AnyTimes() + // h.EXPECT().FetchLatestCheckpoint().Return([]*clerk.EventRecordWithTime{getSampleEventRecord(t)}, nil).AnyTimes() + return h, heimdallSpan, ctrl } @@ -324,13 +336,13 @@ func getEventRecords(t *testing.T) []*clerk.EventRecordWithTime { // TestEIP1559Transition tests the following: // -// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. -// 2. Gas accounting for access lists on EIP-1559 transactions is correct. -// 3. Only the transaction's tip will be received by the coinbase. -// 4. The transaction sender pays for both the tip and baseFee. -// 5. The coinbase receives only the partially realized tip when -// gasFeeCap - gasTipCap < baseFee. -// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). +// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. +// 2. Gas accounting for access lists on EIP-1559 transactions is correct. +// 3. Only the transaction's tip will be received by the coinbase. +// 4. The transaction sender pays for both the tip and baseFee. +// 5. The coinbase receives only the partially realized tip when +// gasFeeCap - gasTipCap < baseFee. +// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). func TestEIP1559Transition(t *testing.T) { var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")