From f30ef31c25f82c75542cb13a4dfc42dcf71e2c2d Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Wed, 19 Feb 2025 11:32:42 -0300 Subject: [PATCH 01/21] process parent block hash in state parallel --- core/parallel_state_processor.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index b99bf7da23..b73cb89fa4 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -301,7 +301,12 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat } blockContext := NewEVMBlockContext(header, p.bc, nil) + context := NewEVMBlockContext(header, p.bc.hc, nil) + vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, p.config, cfg) + if p.config.IsPrague(block.Number()) { + ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) + } // Iterate over and process the individual transactions for i, tx := range block.Transactions() { msg, err := TransactionToMessage(tx, types.MakeSigner(p.config, header.Number, header.Time), header.BaseFee) From e2f114b19b9ed2538b78c0bce387a9e921860ce4 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Wed, 19 Feb 2025 17:15:43 -0300 Subject: [PATCH 02/21] including heimdall timeout on config --- cmd/utils/bor_flags.go | 10 +++++++ cmd/utils/flags.go | 1 + consensus/bor/heimdall/client.go | 9 +++--- consensus/bor/heimdall/client_test.go | 6 ++-- docs/cli/server.md | 2 ++ eth/ethconfig/config.go | 5 +++- eth/ethconfig/gen_config.go | 42 +++++++++++++++++++++++---- internal/cli/server/config.go | 3 ++ internal/cli/server/flags.go | 6 ++++ scripts/getconfig.go | 1 + 10 files changed, 71 insertions(+), 14 deletions(-) diff --git a/cmd/utils/bor_flags.go b/cmd/utils/bor_flags.go index 76d965746c..7ff4115b77 100644 --- a/cmd/utils/bor_flags.go +++ b/cmd/utils/bor_flags.go @@ -2,6 +2,7 @@ package utils import ( "os" + "time" "github.com/urfave/cli/v2" @@ -22,6 +23,13 @@ var ( Value: "http://localhost:1317", } + // HeimdallTimeoutFlag flag for heimdall timeout + HeimdallTimeoutFlag = &cli.DurationFlag{ + Name: "bor.heimdalltimeout", + Usage: "Timeout of Heimdall service", + Value: 5 * time.Second, + } + // WithoutHeimdallFlag no heimdall (for testing purpose) WithoutHeimdallFlag = &cli.BoolFlag{ Name: "bor.withoutheimdall", @@ -56,6 +64,7 @@ var ( // BorFlags all bor related flags BorFlags = []cli.Flag{ HeimdallURLFlag, + HeimdallTimeoutFlag, WithoutHeimdallFlag, HeimdallgRPCAddressFlag, RunHeimdallFlag, @@ -67,6 +76,7 @@ var ( // SetBorConfig sets bor config func SetBorConfig(ctx *cli.Context, cfg *eth.Config) { cfg.HeimdallURL = ctx.String(HeimdallURLFlag.Name) + cfg.HeimdallTimeout = ctx.Duration(HeimdallTimeoutFlag.Name) cfg.WithoutHeimdall = ctx.Bool(WithoutHeimdallFlag.Name) cfg.HeimdallgRPCAddress = ctx.String(HeimdallgRPCAddressFlag.Name) cfg.RunHeimdall = ctx.Bool(RunHeimdallFlag.Name) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d0ceada34f..444b4ddd05 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2314,6 +2314,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh configs := ðconfig.Config{ Genesis: gspec, HeimdallURL: ctx.String(HeimdallURLFlag.Name), + HeimdallTimeout: ctx.Duration(HeimdallTimeoutFlag.Name), WithoutHeimdall: ctx.Bool(WithoutHeimdallFlag.Name), HeimdallgRPCAddress: ctx.String(HeimdallgRPCAddressFlag.Name), RunHeimdall: ctx.Bool(RunHeimdallArgsFlag.Name), diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 029164c986..c46078594e 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -33,7 +33,6 @@ var ( const ( heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB stateFetchLimit = 50 - apiHeimdallTimeout = 5 * time.Second retryCall = 5 * time.Second ) @@ -59,11 +58,13 @@ type Request struct { start time.Time } -func NewHeimdallClient(urlString string) *HeimdallClient { +func NewHeimdallClient(urlString string, timeout time.Duration) *HeimdallClient { + // REMOVE BEFORE PR + log.Info("############### timeout set on heimdall client", "valueSetByConfig", timeout) return &HeimdallClient{ urlString: urlString, client: http.Client{ - Timeout: apiHeimdallTimeout, + Timeout: timeout, }, closeCh: make(chan struct{}), } @@ -469,7 +470,7 @@ func internalFetch(ctx context.Context, client http.Client, u *url.URL) ([]byte, } func internalFetchWithTimeout(ctx context.Context, client http.Client, url *url.URL) ([]byte, error) { - ctx, cancel := context.WithTimeout(ctx, apiHeimdallTimeout) + ctx, cancel := context.WithTimeout(ctx, client.Timeout) defer cancel() // request data once diff --git a/consensus/bor/heimdall/client_test.go b/consensus/bor/heimdall/client_test.go index 0fa7665048..d2fb06df72 100644 --- a/consensus/bor/heimdall/client_test.go +++ b/consensus/bor/heimdall/client_test.go @@ -143,7 +143,7 @@ func TestFetchCheckpointFromMockHeimdall(t *testing.T) { require.NoError(t, err, "expect no error in starting mock heimdall server") // Create a new heimdall client and use same port for connection - client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port), 5*time.Second) _, err = client.FetchCheckpoint(context.Background(), -1) require.NoError(t, err, "expect no error in fetching checkpoint") @@ -194,7 +194,7 @@ func TestFetchMilestoneFromMockHeimdall(t *testing.T) { require.NoError(t, err, "expect no error in starting mock heimdall server") // Create a new heimdall client and use same port for connection - client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port), 5*time.Second) _, err = client.FetchMilestone(context.Background()) require.NoError(t, err, "expect no error in fetching milestone") @@ -250,7 +250,7 @@ func TestFetchShutdown(t *testing.T) { require.NoError(t, err, "expect no error in starting mock heimdall server") // Create a new heimdall client and use same port for connection - client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port)) + client := NewHeimdallClient(fmt.Sprintf("http://localhost:%d", port), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) diff --git a/docs/cli/server.md b/docs/cli/server.md index 4c4c86b004..3094b18705 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -8,6 +8,8 @@ The ```bor server``` command runs the Bor client. - ```bor.heimdall```: URL of Heimdall service (default: http://localhost:1317) +- ```bor.heimdalltimeout```: Timeout of Heimdall service (default: 5s) + - ```bor.heimdallgRPC```: Address of Heimdall gRPC service - ```bor.logs```: Enables bor log retrieval (default: false) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index b49c6e6079..5905bca861 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -186,6 +186,9 @@ type Config struct { // URL to connect to Heimdall node HeimdallURL string + // timeout in heimdall requests + HeimdallTimeout time.Duration + // No heimdall service WithoutHeimdall bool @@ -242,7 +245,7 @@ func CreateConsensusEngine(chainConfig *params.ChainConfig, ethConfig *Config, d } else if ethConfig.HeimdallgRPCAddress != "" { heimdallClient = heimdallgrpc.NewHeimdallGRPCClient(ethConfig.HeimdallgRPCAddress) } else { - heimdallClient = heimdall.NewHeimdallClient(ethConfig.HeimdallURL) + heimdallClient = heimdall.NewHeimdallClient(ethConfig.HeimdallURL, ethConfig.HeimdallTimeout) } return bor.New(chainConfig, db, blockchainAPI, spanner, heimdallClient, genesisContractsClient, false), nil diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 082e093578..ebfc37b86d 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -26,6 +26,9 @@ func (c Config) MarshalTOML() (interface{}, error) { NoPruning bool NoPrefetch bool TxLookupLimit uint64 `toml:",omitempty"` + TransactionHistory uint64 `toml:",omitempty"` + StateHistory uint64 `toml:",omitempty"` + StateScheme string `toml:",omitempty"` RequiredBlocks map[uint64]common.Hash `toml:"-"` LightServ int `toml:",omitempty"` LightIngress int `toml:",omitempty"` @@ -53,9 +56,9 @@ func (c Config) MarshalTOML() (interface{}, error) { BlobPool blobpool.Config GPO gasprice.Config EnablePreimageRecording bool - EnableWitnessCollection bool `toml:"-"` - VMTrace string - VMTraceJsonConfig string + EnableWitnessCollection bool `toml:"-"` + VMTrace string + VMTraceJsonConfig string DocRoot string `toml:"-"` RPCGasCap uint64 RPCReturnDataLimit uint64 @@ -63,6 +66,7 @@ func (c Config) MarshalTOML() (interface{}, error) { RPCTxFeeCap float64 OverrideCancun *big.Int `toml:",omitempty"` HeimdallURL string + HeimdallTimeout time.Duration WithoutHeimdall bool HeimdallgRPCAddress string RunHeimdall bool @@ -72,6 +76,7 @@ func (c Config) MarshalTOML() (interface{}, error) { ParallelEVM core.ParallelEVMConfig `toml:",omitempty"` DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"` OverrideVerkle *big.Int `toml:",omitempty"` + EnableBlockTracking bool } var enc Config enc.Genesis = c.Genesis @@ -82,6 +87,9 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.NoPruning = c.NoPruning enc.NoPrefetch = c.NoPrefetch enc.TxLookupLimit = c.TxLookupLimit + enc.TransactionHistory = c.TransactionHistory + enc.StateHistory = c.StateHistory + enc.StateScheme = c.StateScheme enc.RequiredBlocks = c.RequiredBlocks enc.LightServ = c.LightServ enc.LightIngress = c.LightIngress @@ -119,6 +127,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.RPCTxFeeCap = c.RPCTxFeeCap enc.OverrideCancun = c.OverrideCancun enc.HeimdallURL = c.HeimdallURL + enc.HeimdallTimeout = c.HeimdallTimeout enc.WithoutHeimdall = c.WithoutHeimdall enc.HeimdallgRPCAddress = c.HeimdallgRPCAddress enc.RunHeimdall = c.RunHeimdall @@ -128,6 +137,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.ParallelEVM = c.ParallelEVM enc.DevFakeAuthor = c.DevFakeAuthor enc.OverrideVerkle = c.OverrideVerkle + enc.EnableBlockTracking = c.EnableBlockTracking return &enc, nil } @@ -142,6 +152,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { NoPruning *bool NoPrefetch *bool TxLookupLimit *uint64 `toml:",omitempty"` + TransactionHistory *uint64 `toml:",omitempty"` + StateHistory *uint64 `toml:",omitempty"` + StateScheme *string `toml:",omitempty"` RequiredBlocks map[uint64]common.Hash `toml:"-"` LightServ *int `toml:",omitempty"` LightIngress *int `toml:",omitempty"` @@ -169,9 +182,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { BlobPool *blobpool.Config GPO *gasprice.Config EnablePreimageRecording *bool - EnableWitnessCollection *bool `toml:"-"` - VMTrace *string - VMTraceJsonConfig *string + EnableWitnessCollection *bool `toml:"-"` + VMTrace *string + VMTraceJsonConfig *string DocRoot *string `toml:"-"` RPCGasCap *uint64 RPCReturnDataLimit *uint64 @@ -179,6 +192,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { RPCTxFeeCap *float64 OverrideCancun *big.Int `toml:",omitempty"` HeimdallURL *string + HeimdallTimeout *time.Duration WithoutHeimdall *bool HeimdallgRPCAddress *string RunHeimdall *bool @@ -188,6 +202,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { ParallelEVM *core.ParallelEVMConfig `toml:",omitempty"` DevFakeAuthor *bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"` OverrideVerkle *big.Int `toml:",omitempty"` + EnableBlockTracking *bool } var dec Config if err := unmarshal(&dec); err != nil { @@ -217,6 +232,15 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.TxLookupLimit != nil { c.TxLookupLimit = *dec.TxLookupLimit } + if dec.TransactionHistory != nil { + c.TransactionHistory = *dec.TransactionHistory + } + if dec.StateHistory != nil { + c.StateHistory = *dec.StateHistory + } + if dec.StateScheme != nil { + c.StateScheme = *dec.StateScheme + } if dec.RequiredBlocks != nil { c.RequiredBlocks = dec.RequiredBlocks } @@ -328,6 +352,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.HeimdallURL != nil { c.HeimdallURL = *dec.HeimdallURL } + if dec.HeimdallTimeout != nil { + c.HeimdallTimeout = *dec.HeimdallTimeout + } if dec.WithoutHeimdall != nil { c.WithoutHeimdall = *dec.WithoutHeimdall } @@ -355,5 +382,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.OverrideVerkle != nil { c.OverrideVerkle = dec.OverrideVerkle } + if dec.EnableBlockTracking != nil { + c.EnableBlockTracking = *dec.EnableBlockTracking + } return nil } diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 1f6e451dbf..ead556ffeb 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -254,6 +254,8 @@ type HeimdallConfig struct { // URL is the url of the heimdall server URL string `hcl:"url,optional" toml:"url,optional"` + Timeout time.Duration `hcl:"timeout,optional" toml:"timeout,optional"` + // Without is used to disable remote heimdall during testing Without bool `hcl:"bor.without,optional" toml:"bor.without,optional"` @@ -930,6 +932,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* } n.HeimdallURL = c.Heimdall.URL + n.HeimdallTimeout = c.Heimdall.Timeout n.WithoutHeimdall = c.Heimdall.Without n.HeimdallgRPCAddress = c.Heimdall.GRPCAddress n.RunHeimdall = c.Heimdall.RunHeimdall diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 25fc6ce7ba..3f2e5fc0b6 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -167,6 +167,12 @@ func (c *Command) Flags(config *Config) *flagset.Flagset { Value: &c.cliConfig.Heimdall.URL, Default: c.cliConfig.Heimdall.URL, }) + f.DurationFlag(&flagset.DurationFlag{ + Name: "bor.heimdalltimeout", + Usage: "Timeout of Heimdall service", + Value: &c.cliConfig.Heimdall.Timeout, + Default: c.cliConfig.Heimdall.Timeout, + }) f.BoolFlag(&flagset.BoolFlag{ Name: "bor.withoutheimdall", Usage: "Run without Heimdall service (for testing purpose)", diff --git a/scripts/getconfig.go b/scripts/getconfig.go index 44ea9b51f3..0614065896 100644 --- a/scripts/getconfig.go +++ b/scripts/getconfig.go @@ -110,6 +110,7 @@ var nameTagMap = map[string]string{ "0-snapshot": "snapshot", "\"bor.logs\"": "bor.logs", "url": "bor.heimdall", + "timeout": "bor.heimdalltimeout", "\"bor.without\"": "bor.withoutheimdall", "grpc-address": "bor.heimdallgRPC", "\"bor.runheimdall\"": "bor.runheimdall", From 69ee62820f1e3fec5d64113edbbad8ed66c12165 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Wed, 19 Feb 2025 17:55:07 -0300 Subject: [PATCH 03/21] remove debug logs --- consensus/bor/heimdall/client.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index c46078594e..4c21c31fac 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -59,8 +59,6 @@ type Request struct { } func NewHeimdallClient(urlString string, timeout time.Duration) *HeimdallClient { - // REMOVE BEFORE PR - log.Info("############### timeout set on heimdall client", "valueSetByConfig", timeout) return &HeimdallClient{ urlString: urlString, client: http.Client{ From 133b5bd7bb751cf84730527d4293a24daba4eafd Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 03:49:00 -0300 Subject: [PATCH 04/21] checks for empty non empty requests scenario --- consensus/bor/bor.go | 10 ++++++++++ consensus/errors.go | 3 +++ 2 files changed, 13 insertions(+) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index a49e8c5a45..738fb61bce 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -391,6 +391,10 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head return consensus.ErrUnexpectedWithdrawals } + if header.RequestsHash != nil { + return consensus.ErrUnexpectedRequests + } + // All basic checks passed, verify cascading fields return c.verifyCascadingFields(chain, header, parents) } @@ -820,6 +824,9 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, if body.Withdrawals != nil || header.WithdrawalsHash != nil { return } + if body.Requests != nil || header.RequestsHash != nil { + return + } var ( stateSyncData []*types.StateSyncData @@ -906,6 +913,9 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ if body.Withdrawals != nil || header.WithdrawalsHash != nil { return nil, consensus.ErrUnexpectedWithdrawals } + if body.Requests != nil || header.RequestsHash != nil { + return nil, consensus.ErrUnexpectedRequests + } var ( stateSyncData []*types.StateSyncData diff --git a/consensus/errors.go b/consensus/errors.go index e9dd977a1e..f087cd19bd 100644 --- a/consensus/errors.go +++ b/consensus/errors.go @@ -41,4 +41,7 @@ var ( // ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals. ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals") + + // ErrUnexpectedRequests is returned if a pre-Shanghai block has requests. + ErrUnexpectedRequests = errors.New("unexpected requests") ) From 3154fc4e0e1a1db56f95eac08a8929a3552940be Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 10:04:51 -0300 Subject: [PATCH 05/21] fixing default flag value --- internal/cli/server/flags.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 3f2e5fc0b6..f09bc32fa0 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -1,6 +1,8 @@ package server import ( + "time" + "github.com/ethereum/go-ethereum/internal/cli/flagset" ) @@ -171,7 +173,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset { Name: "bor.heimdalltimeout", Usage: "Timeout of Heimdall service", Value: &c.cliConfig.Heimdall.Timeout, - Default: c.cliConfig.Heimdall.Timeout, + Default: 5 * time.Second, }) f.BoolFlag(&flagset.BoolFlag{ Name: "bor.withoutheimdall", From d694697285d4f8def773850ada3622807d0d2f2a Mon Sep 17 00:00:00 2001 From: kindknow <166522338+kindknow@users.noreply.github.com> Date: Thu, 20 Feb 2025 21:06:21 +0800 Subject: [PATCH 06/21] Merge pull request #1397 from kindknow/master chore: fix some function names in comment --- beacon/light/request/scheduler.go | 2 +- consensus/misc/eip1559/eip1559_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon/light/request/scheduler.go b/beacon/light/request/scheduler.go index e80daf805e..242ed56d28 100644 --- a/beacon/light/request/scheduler.go +++ b/beacon/light/request/scheduler.go @@ -269,7 +269,7 @@ func (s *Scheduler) addEvent(event Event) { s.Trigger() } -// filterEvent sorts each Event either as a request event or a server event, +// filterEvents sorts each Event either as a request event or a server event, // depending on its type. Request events are also sorted in a map based on the // module that originally initiated the request. It also ensures that no events // related to a server are returned before EvRegistered or after EvUnregistered. diff --git a/consensus/misc/eip1559/eip1559_test.go b/consensus/misc/eip1559/eip1559_test.go index 47f3e80edf..b4e1444e33 100644 --- a/consensus/misc/eip1559/eip1559_test.go +++ b/consensus/misc/eip1559/eip1559_test.go @@ -137,7 +137,7 @@ func TestCalcBaseFee(t *testing.T) { } } -// TestCalcBaseFee assumes all blocks are 1559-blocks post Delhi Hard Fork +// TestCalcBaseFeeDelhi assumes all blocks are 1559-blocks post Delhi Hard Fork func TestCalcBaseFeeDelhi(t *testing.T) { t.Parallel() From ccede75223717d4e61e3512f609d0fe8127f4fa9 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 11:03:17 -0300 Subject: [PATCH 07/21] removing requests from bor --- cmd/evm/internal/t8ntool/execution.go | 23 +---------------------- core/chain_makers.go | 13 +------------ core/parallel_state_processor.go | 11 +---------- miner/worker.go | 8 -------- 4 files changed, 3 insertions(+), 52 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index f5f91d8fa3..749ad32c63 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -394,28 +394,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, execRs.CurrentExcessBlobGas = (*math.HexOrDecimal64)(&excessBlobGas) execRs.CurrentBlobGasUsed = (*math.HexOrDecimal64)(&blobGasUsed) } - if chainConfig.IsPrague(vmContext.BlockNumber) { - // Parse the requests from the logs - var allLogs []*types.Log - for _, receipt := range receipts { - allLogs = append(allLogs, receipt.Logs...) - } - requests, err := core.ParseDepositLogs(allLogs, chainConfig) - if err != nil { - return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err)) - } - // Calculate the requests root - h := types.DeriveSha(requests, trie.NewStackTrie(nil)) - execRs.RequestsHash = &h - // Get the deposits from the requests - deposits := make(types.Deposits, 0) - for _, req := range requests { - if dep, ok := req.Inner().(*types.Deposit); ok { - deposits = append(deposits, dep) - } - } - execRs.DepositRequests = &deposits - } + // Re-create statedb instance with new root upon the updated database // for accessing latest states. statedb, err = state.New(root, statedb.Database()) diff --git a/core/chain_makers.go b/core/chain_makers.go index 15a37cdb7e..8cc5db4774 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -359,18 +359,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse gen(i, b) } - var requests types.Requests - if config.IsPrague(b.header.Number) { - for _, r := range b.receipts { - d, err := ParseDepositLogs(r.Logs, config) - if err != nil { - panic(fmt.Sprintf("failed to parse deposit log: %v", err)) - } - requests = append(requests, d...) - } - } - - body := types.Body{Transactions: b.txs, Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: requests} + body := types.Body{Transactions: b.txs, Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: nil} block, err := b.engine.FinalizeAndAssemble(cm, b.header, statedb, &body, b.receipts) if err != nil { panic(err) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index b73cb89fa4..85b60d9d07 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -394,21 +394,12 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat return nil, err } - // Read requests if Prague is enabled. - var requests types.Requests - if p.config.IsPrague(block.Number()) { - requests, err = ParseDepositLogs(allLogs, p.config) - if err != nil { - return nil, err - } - } - // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) p.engine.Finalize(p.bc, header, statedb, block.Body()) return &ProcessResult{ Receipts: receipts, - Requests: requests, + Requests: nil, Logs: allLogs, GasUsed: *usedGas, }, nil diff --git a/miner/worker.go b/miner/worker.go index 1782e47441..cccf430e3b 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1407,14 +1407,6 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR for _, r := range work.receipts { allLogs = append(allLogs, r.Logs...) } - // Read requests if Prague is enabled. - if w.chainConfig.IsPrague(work.header.Number) { - requests, err := core.ParseDepositLogs(allLogs, w.chainConfig) - if err != nil { - return &newPayloadResult{err: err} - } - body.Requests = requests - } block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, &body, work.receipts) if err != nil { From 2b0c071db7bacf620531371a257c5e5e1d33ec51 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 11:05:37 -0300 Subject: [PATCH 08/21] lint fix --- miner/worker.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index cccf430e3b..0e166b9dfd 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1403,10 +1403,6 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR } body := types.Body{Transactions: work.txs, Withdrawals: params.withdrawals} - allLogs := make([]*types.Log, 0) - for _, r := range work.receipts { - allLogs = append(allLogs, r.Logs...) - } block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, &body, work.receipts) if err != nil { From b29072c21e72bacc72a5abb81d9d8dd921bab91e Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 11:36:52 -0300 Subject: [PATCH 09/21] including missed change on statedb --- core/state/statedb.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/state/statedb.go b/core/state/statedb.go index 0001bfceb7..868f5ad8ea 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -994,6 +994,7 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject { // Insert into the live set obj := newObject(s, addr, acct) s.setStateObject(obj) + s.AccountLoaded++ return obj }) } From 2df763df6071261a1ed73ac1bcd86db1a50431ed Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Thu, 20 Feb 2025 14:04:48 -0300 Subject: [PATCH 10/21] Revert "removing requests from bor" This reverts commit ccede75223717d4e61e3512f609d0fe8127f4fa9. --- cmd/evm/internal/t8ntool/execution.go | 23 ++++++++++++++++++++++- core/chain_makers.go | 13 ++++++++++++- core/parallel_state_processor.go | 11 ++++++++++- miner/worker.go | 12 ++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 749ad32c63..d2ac255fe2 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -394,7 +394,28 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, execRs.CurrentExcessBlobGas = (*math.HexOrDecimal64)(&excessBlobGas) execRs.CurrentBlobGasUsed = (*math.HexOrDecimal64)(&blobGasUsed) } - + if chainConfig.IsPrague(vmContext.BlockNumber) && chainConfig.Bor == nil { + // Parse the requests from the logs + var allLogs []*types.Log + for _, receipt := range receipts { + allLogs = append(allLogs, receipt.Logs...) + } + requests, err := core.ParseDepositLogs(allLogs, chainConfig) + if err != nil { + return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err)) + } + // Calculate the requests root + h := types.DeriveSha(requests, trie.NewStackTrie(nil)) + execRs.RequestsHash = &h + // Get the deposits from the requests + deposits := make(types.Deposits, 0) + for _, req := range requests { + if dep, ok := req.Inner().(*types.Deposit); ok { + deposits = append(deposits, dep) + } + } + execRs.DepositRequests = &deposits + } // Re-create statedb instance with new root upon the updated database // for accessing latest states. statedb, err = state.New(root, statedb.Database()) diff --git a/core/chain_makers.go b/core/chain_makers.go index 8cc5db4774..9235da87e9 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -359,7 +359,18 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse gen(i, b) } - body := types.Body{Transactions: b.txs, Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: nil} + var requests types.Requests + if config.IsPrague(b.header.Number) && config.Bor == nil { + for _, r := range b.receipts { + d, err := ParseDepositLogs(r.Logs, config) + if err != nil { + panic(fmt.Sprintf("failed to parse deposit log: %v", err)) + } + requests = append(requests, d...) + } + } + + body := types.Body{Transactions: b.txs, Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: requests} block, err := b.engine.FinalizeAndAssemble(cm, b.header, statedb, &body, b.receipts) if err != nil { panic(err) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index 85b60d9d07..5a4903aeae 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -394,12 +394,21 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat return nil, err } + // Read requests if Prague is enabled. + var requests types.Requests + if p.config.IsPrague(block.Number()) && p.config.Bor == nil { + requests, err = ParseDepositLogs(allLogs, p.config) + if err != nil { + return nil, err + } + } + // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) p.engine.Finalize(p.bc, header, statedb, block.Body()) return &ProcessResult{ Receipts: receipts, - Requests: nil, + Requests: requests, Logs: allLogs, GasUsed: *usedGas, }, nil diff --git a/miner/worker.go b/miner/worker.go index 0e166b9dfd..469744b227 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1403,6 +1403,18 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR } body := types.Body{Transactions: work.txs, Withdrawals: params.withdrawals} + allLogs := make([]*types.Log, 0) + for _, r := range work.receipts { + allLogs = append(allLogs, r.Logs...) + } + // Read requests if Prague is enabled. + if w.chainConfig.IsPrague(work.header.Number) && w.chainConfig.Bor == nil { + requests, err := core.ParseDepositLogs(allLogs, w.chainConfig) + if err != nil { + return &newPayloadResult{err: err} + } + body.Requests = requests + } block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, &body, work.receipts) if err != nil { From 732478ce5f4ca160d2ce79deb5804c8790f054b8 Mon Sep 17 00:00:00 2001 From: Daniel Jones <105369507+djpolygon@users.noreply.github.com> Date: Fri, 21 Feb 2025 04:08:44 -0600 Subject: [PATCH 11/21] As 20.04 is being EOL for github runner support, moving to 22.04 (#1445) --- .github/workflows/amoy_deb_profiles.yml | 2 +- .github/workflows/mainnet_deb_profiles.yml | 2 +- .github/workflows/packager_deb.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/amoy_deb_profiles.yml b/.github/workflows/amoy_deb_profiles.yml index 4258967ec3..6f4d16fb7e 100644 --- a/.github/workflows/amoy_deb_profiles.yml +++ b/.github/workflows/amoy_deb_profiles.yml @@ -15,7 +15,7 @@ jobs: permissions: id-token: write contents: write - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/mainnet_deb_profiles.yml b/.github/workflows/mainnet_deb_profiles.yml index 46833e16e9..e8ee619c6f 100644 --- a/.github/workflows/mainnet_deb_profiles.yml +++ b/.github/workflows/mainnet_deb_profiles.yml @@ -15,7 +15,7 @@ jobs: permissions: id-token: write contents: write - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/packager_deb.yml b/.github/workflows/packager_deb.yml index f8efd7d4c2..f16013d55a 100644 --- a/.github/workflows/packager_deb.yml +++ b/.github/workflows/packager_deb.yml @@ -15,7 +15,7 @@ jobs: permissions: id-token: write contents: write - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 From acb3eb77940b19e47d6d3d75792b4f68f49706d4 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Mon, 24 Feb 2025 14:54:10 +0100 Subject: [PATCH 12/21] use ubuntu 22.04 --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e969f5261..4e115a8955 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -51,7 +51,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -79,7 +79,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -130,7 +130,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -167,7 +167,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} needs: [unit-tests, integration-tests] steps: @@ -182,7 +182,7 @@ jobs: if: (github.event.action != 'closed' || github.event.pull_request.merged == true) strategy: matrix: - os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments + os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From 41459a77c87e969f6014b71293ea9ab0f0a2b236 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 24 Feb 2025 17:19:20 -0300 Subject: [PATCH 13/21] rpc tests on ci --- .github/workflows/ci.yml | 7 ++++++- integration-tests/rpc_test.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 integration-tests/rpc_test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e969f5261..475c371a25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,7 +202,7 @@ jobs: uses: actions/checkout@v4 with: repository: maticnetwork/matic-cli - ref: master + ref: lmartins/ci-rpc-tests # temporary for validation path: matic-cli - name: Install dependencies on Linux @@ -250,6 +250,11 @@ jobs: cd - timeout 60m bash bor/integration-tests/smoke_test.sh + - name: Run RPC Tests + run: | + echo "Starting RPC Tests..." + timeout 5m bash bor/integration-tests/rpc_test.sh + - name: Upload logs if: always() uses: actions/upload-artifact@v4.4.0 diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh new file mode 100644 index 0000000000..9cfce3af7a --- /dev/null +++ b/integration-tests/rpc_test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +signersDump=$(jq . $signersFile) +privKey=$(echo "$signersDump" | jq -r ".[0].priv_key") +rpc_url="http://localhost:8545" + + +go run matic-cli/tests/rpc-tests/main.go --priv-key $privKey --rpc-url $rpc_url \ No newline at end of file From dd6689a6c72bbdee0d18946b78450d30707bc77f Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 24 Feb 2025 18:00:16 -0300 Subject: [PATCH 14/21] download dependencies to run script --- integration-tests/rpc_test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh index 9cfce3af7a..119567f9dc 100644 --- a/integration-tests/rpc_test.sh +++ b/integration-tests/rpc_test.sh @@ -5,5 +5,9 @@ signersDump=$(jq . $signersFile) privKey=$(echo "$signersDump" | jq -r ".[0].priv_key") rpc_url="http://localhost:8545" +cd matic-cli/tests/rpc-tests -go run matic-cli/tests/rpc-tests/main.go --priv-key $privKey --rpc-url $rpc_url \ No newline at end of file +go mod tidy +go main.go --priv-key $privKey --rpc-url $rpc_url + +cd - \ No newline at end of file From 9f6279c67a13c3ae22a8cc65e13d860769bf9865 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 24 Feb 2025 18:21:43 -0300 Subject: [PATCH 15/21] small fix on ci rpc tests --- integration-tests/rpc_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh index 119567f9dc..05bc9f708f 100644 --- a/integration-tests/rpc_test.sh +++ b/integration-tests/rpc_test.sh @@ -8,6 +8,6 @@ rpc_url="http://localhost:8545" cd matic-cli/tests/rpc-tests go mod tidy -go main.go --priv-key $privKey --rpc-url $rpc_url +go run main.go --priv-key $privKey --rpc-url $rpc_url cd - \ No newline at end of file From 318047f9516918f961636ecb99c1fb47b0ba07ca Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 24 Feb 2025 19:14:23 -0300 Subject: [PATCH 16/21] rpc script fix --- integration-tests/rpc_test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh index 05bc9f708f..c55e4133c7 100644 --- a/integration-tests/rpc_test.sh +++ b/integration-tests/rpc_test.sh @@ -1,13 +1,14 @@ #!/bin/bash set -e -signersDump=$(jq . $signersFile) +signersFile="matic-cli/devnet/devnet/signer-dump.json" +signersDump=$(jq . "$signersFile") privKey=$(echo "$signersDump" | jq -r ".[0].priv_key") rpc_url="http://localhost:8545" cd matic-cli/tests/rpc-tests go mod tidy -go run main.go --priv-key $privKey --rpc-url $rpc_url +go run . --priv-key "$privKey" --rpc-url "$rpc_url" cd - \ No newline at end of file From c94033070a58a2b3ec77f2851013f469fa06c2a4 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 24 Feb 2025 22:52:20 -0300 Subject: [PATCH 17/21] enable log req res --- integration-tests/rpc_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh index c55e4133c7..00b4758f03 100644 --- a/integration-tests/rpc_test.sh +++ b/integration-tests/rpc_test.sh @@ -9,6 +9,6 @@ rpc_url="http://localhost:8545" cd matic-cli/tests/rpc-tests go mod tidy -go run . --priv-key "$privKey" --rpc-url "$rpc_url" +go run . --priv-key "$privKey" --rpc-url "$rpc_url" --log-req-res true cd - \ No newline at end of file From 5b350dccff021dc6dedb3fa0996d941595cc9caf Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Tue, 25 Feb 2025 00:32:33 -0300 Subject: [PATCH 18/21] going back to master branch matic-cli --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 475c371a25..dc7f55cc10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,7 +202,7 @@ jobs: uses: actions/checkout@v4 with: repository: maticnetwork/matic-cli - ref: lmartins/ci-rpc-tests # temporary for validation + ref: master path: matic-cli - name: Install dependencies on Linux From 844603ea4eead83c38dc91c5a0322ba04ec9af2c Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Tue, 25 Feb 2025 15:13:36 -0300 Subject: [PATCH 19/21] resolving comments --- consensus/bor/heimdall/client.go | 3 +-- internal/cli/server/config.go | 1 + internal/cli/server/flags.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 4c21c31fac..0e19aac356 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -33,7 +33,6 @@ var ( const ( heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB stateFetchLimit = 50 - retryCall = 5 * time.Second ) type StateSyncEventsResponse struct { @@ -293,7 +292,7 @@ func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err) // create a new ticker for retrying the request - ticker := time.NewTicker(retryCall) + ticker := time.NewTicker(client.Timeout) defer ticker.Stop() const logEach = 5 diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index e870e7dcd5..9d781ed368 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -646,6 +646,7 @@ func DefaultConfig() *Config { }, Heimdall: &HeimdallConfig{ URL: "http://localhost:1317", + Timeout: 5 * time.Second, Without: false, GRPCAddress: "", }, diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index f09bc32fa0..84aafab712 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -171,7 +171,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset { }) f.DurationFlag(&flagset.DurationFlag{ Name: "bor.heimdalltimeout", - Usage: "Timeout of Heimdall service", + Usage: "Timeout period for bor's outgoing requests to heimdall", Value: &c.cliConfig.Heimdall.Timeout, Default: 5 * time.Second, }) From a7e322202344779af9acc5514e0fdfbf92805179 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Tue, 25 Feb 2025 16:51:27 -0300 Subject: [PATCH 20/21] fix edge case on ticker --- consensus/bor/heimdall/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 0e19aac356..ed7ca31b6d 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -33,6 +33,7 @@ var ( const ( heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB stateFetchLimit = 50 + retryCall = 5 * time.Second ) type StateSyncEventsResponse struct { @@ -292,7 +293,13 @@ func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err) // create a new ticker for retrying the request - ticker := time.NewTicker(client.Timeout) + var ticker *time.Ticker + if client.Timeout != 0 { + ticker = time.NewTicker(client.Timeout) + } else { + // only reach here when HeimdallClient is HeimdallGRPCClient or HeimdallAppClient + ticker = time.NewTicker(retryCall) + } defer ticker.Stop() const logEach = 5 From 5f6e2d334cbed39b0e8487094ad5e6d6ac298bbc Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Wed, 26 Feb 2025 03:06:01 -0300 Subject: [PATCH 21/21] minor nit fixed --- internal/cli/server/flags.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 84aafab712..4087d2e84c 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -1,8 +1,6 @@ package server import ( - "time" - "github.com/ethereum/go-ethereum/internal/cli/flagset" ) @@ -173,7 +171,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset { Name: "bor.heimdalltimeout", Usage: "Timeout period for bor's outgoing requests to heimdall", Value: &c.cliConfig.Heimdall.Timeout, - Default: 5 * time.Second, + Default: c.cliConfig.Heimdall.Timeout, }) f.BoolFlag(&flagset.BoolFlag{ Name: "bor.withoutheimdall",