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/ci.yml b/.github/workflows/ci.yml index 6e969f5261..6c2543b5f3 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 @@ -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/.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 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/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index f5f91d8fa3..d2ac255fe2 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -394,7 +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) { + if chainConfig.IsPrague(vmContext.BlockNumber) && chainConfig.Bor == nil { // Parse the requests from the logs var allLogs []*types.Log for _, receipt := range receipts { 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 b1f04e8b7b..6aed8ab9d9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2282,6 +2282,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/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/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 029164c986..ed7ca31b6d 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,11 @@ type Request struct { start time.Time } -func NewHeimdallClient(urlString string) *HeimdallClient { +func NewHeimdallClient(urlString string, timeout time.Duration) *HeimdallClient { return &HeimdallClient{ urlString: urlString, client: http.Client{ - Timeout: apiHeimdallTimeout, + Timeout: timeout, }, closeCh: make(chan struct{}), } @@ -294,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(retryCall) + 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 @@ -469,7 +474,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/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") ) 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() diff --git a/core/chain_makers.go b/core/chain_makers.go index 15a37cdb7e..9235da87e9 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -360,7 +360,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse } var requests types.Requests - if config.IsPrague(b.header.Number) { + if config.IsPrague(b.header.Number) && config.Bor == nil { for _, r := range b.receipts { d, err := ParseDepositLogs(r.Logs, config) if err != nil { diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index b99bf7da23..5a4903aeae 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) @@ -391,7 +396,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat // Read requests if Prague is enabled. var requests types.Requests - if p.config.IsPrague(block.Number()) { + if p.config.IsPrague(block.Number()) && p.config.Bor == nil { requests, err = ParseDepositLogs(allLogs, p.config) if err != nil { return nil, err 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 }) } 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 4d14266abc..f6de15865e 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -176,6 +176,9 @@ type Config struct { // URL to connect to Heimdall node HeimdallURL string + // timeout in heimdall requests + HeimdallTimeout time.Duration + // No heimdall service WithoutHeimdall bool @@ -232,7 +235,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 d4adaed173..d99a86d24e 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -50,6 +50,7 @@ func (c Config) MarshalTOML() (interface{}, error) { BlobPool blobpool.Config GPO gasprice.Config EnablePreimageRecording bool + EnableWitnessCollection bool `toml:"-"` VMTrace string VMTraceJsonConfig string DocRoot string `toml:"-"` @@ -59,6 +60,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 @@ -112,6 +114,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 @@ -160,6 +163,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { BlobPool *blobpool.Config GPO *gasprice.Config EnablePreimageRecording *bool + EnableWitnessCollection *bool `toml:"-"` VMTrace *string VMTraceJsonConfig *string DocRoot *string `toml:"-"` @@ -169,6 +173,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 @@ -307,6 +312,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 } diff --git a/integration-tests/rpc_test.sh b/integration-tests/rpc_test.sh new file mode 100644 index 0000000000..00b4758f03 --- /dev/null +++ b/integration-tests/rpc_test.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +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 . --priv-key "$privKey" --rpc-url "$rpc_url" --log-req-res true + +cd - \ No newline at end of file diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index df76e04955..9d781ed368 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"` @@ -644,6 +646,7 @@ func DefaultConfig() *Config { }, Heimdall: &HeimdallConfig{ URL: "http://localhost:1317", + Timeout: 5 * time.Second, Without: false, GRPCAddress: "", }, @@ -930,6 +933,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..4087d2e84c 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 period for bor's outgoing requests to heimdall", + 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/miner/worker.go b/miner/worker.go index 1782e47441..469744b227 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1408,7 +1408,7 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR allLogs = append(allLogs, r.Logs...) } // Read requests if Prague is enabled. - if w.chainConfig.IsPrague(work.header.Number) { + 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} 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",