diff --git a/hive_integration/nodocker/engine/withdrawals/wd_max_init_code_spec.nim b/hive_integration/nodocker/engine/withdrawals/wd_max_init_code_spec.nim deleted file mode 100644 index ffd2b0e11..000000000 --- a/hive_integration/nodocker/engine/withdrawals/wd_max_init_code_spec.nim +++ /dev/null @@ -1,127 +0,0 @@ -# Nimbus -# Copyright (c) 2023-2024 Status Research & Development GmbH -# Licensed under either of -# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or -# http://www.apache.org/licenses/LICENSE-2.0) -# * MIT license ([LICENSE-MIT](LICENSE-MIT) or -# http://opensource.org/licenses/MIT) -# at your option. This file may not be copied, modified, or distributed except -# according to those terms. - -import - std/typetraits, - chronos, - chronicles, - eth/common/eth_types_rlp, - ./wd_base_spec, - ../test_env, - ../engine_client, - ../types, - ../cancun/customizer, - ../../../../nimbus/constants, - web3/execution_types, - ../../../../nimbus/beacon/web3_eth_conv - -# EIP-3860 Shanghai Tests: -# Send transactions overflowing the MAX_INITCODE_SIZE -# limit set in EIP-3860, before and after the Shanghai -# fork. -type - MaxInitcodeSizeSpec* = ref object of WDBaseSpec - overflowMaxInitcodeTxCountBeforeFork*: uint64 - overflowMaxInitcodeTxCountAfterFork *: uint64 - -const - MAX_INITCODE_SIZE = EIP3860_MAX_INITCODE_SIZE - -proc execute*(ws: MaxInitcodeSizeSpec, env: TestEnv): bool = - testCond waitFor env.clMock.waitForTTD() - - var - invalidTxCreator = BigInitcodeTx( - initcodeLength: MAX_INITCODE_SIZE + 1, - gasLimit: 2000000, - ) - - validTxCreator = BigInitcodeTx( - initcodeLength: MAX_INITCODE_SIZE, - gasLimit: 2000000, - ) - - if ws.overflowMaxInitcodeTxCountBeforeFork > 0: - doAssert(ws.getPreWithdrawalsBlockCount > 0, "invalid test configuration") - for i in 0.. 0: - error "No max initcode txs included before Shanghai. Txs must have been included before the MAX_INITCODE_SIZE limit was enabled" - - # Create a payload, no txs should be included - pbRes = env.clMock.produceSingleBlock(BlockProcessCallbacks( - onGetPayload: proc(): bool = - testCond env.clMock.latestPayloadBuilt.transactions.len == 0: - error "Client included tx exceeding the MAX_INITCODE_SIZE in payload" - return true - )) - - testCond pbRes - - # Send transactions after the fork - for i in txIncluded.. latestPayloadNumber { - r.expectationDescription = fmt.Sprintf(` - Sent start=%d and count=%d to engine_getPayloadBodiesByRangeV1, latest known block is %d, hence an empty list is expected. - `, req.Start, req.Count, latestPayloadNumber) - r.expectPayloadBodiesCount(0) - } else { - var count = req.Count - if req.Start+req.Count-1 > latestPayloadNumber { - count = latestPayloadNumber - req.Start + 1 - } - r.expectationDescription = fmt.Sprintf("Sent engine_getPayloadBodiesByRange(start=%d, count=%d), latest payload number in canonical chain is %d", req.Start, req.Count, latestPayloadNumber) - r.expectPayloadBodiesCount(count) - for i := req.Start; i < req.Start+count; i++ { - p := payloadHistory[i] - - r.expectPayloadBody(i-req.Start, ExecutionPayloadBodyV1{ - Transactions: p.Transactions, - Withdrawals: p.Withdrawals, - }) - } - } -} - - - -func (req GetPayloadBodyRequestByHashIndex) Verify(reqIndex int, testEngine *test.TestEngineClient, payloadHistory clmock.ExecutableDataHistory) { - info "Starting GetPayloadBodyByHash request %d", reqIndex) - startTime := time.Now() - defer func() { - info "Ended GetPayloadBodyByHash request %d, %s", reqIndex, time.Since(startTime)) - }() - payloads := make([]ExecutableData, 0) - hashes := make([]common.Hash, 0) - if len(req.BlockNumbers) > 0 { - for _, n := range req.BlockNumbers { - if p, ok := payloadHistory[n]; ok { - payloads = append(payloads, p) - hashes = append(hashes, p.BlockHash) - } else { - # signal to request an unknown hash (random) - randHash := common.Hash{} - randomBytes(randHash[:]) - payloads = append(payloads, nil) - hashes = append(hashes, randHash) - } - } - } - if req.Start > 0 && req.End > 0 { - for n := req.Start; n <= req.End; n++ { - if p, ok := payloadHistory[n]; ok { - payloads = append(payloads, p) - hashes = append(hashes, p.BlockHash) - } else { - # signal to request an unknown hash (random) - randHash := common.Hash{} - randomBytes(randHash[:]) - payloads = append(payloads, nil) - hashes = append(hashes, randHash) - } - } - } - if len(payloads) == 0 { - panic("invalid test") - } - - r := testEngine.TestEngineGetPayloadBodiesByHashV1(hashes) - r.expectPayloadBodiesCount(uint64(len(payloads))) - for i, p := range payloads { - var expectedPayloadBody ExecutionPayloadBodyV1 - if p != nil { - expectedPayloadBody = ExecutionPayloadBodyV1{ - Transactions: p.Transactions, - Withdrawals: p.Withdrawals, - } - } - r.expectPayloadBody(uint64(i), expectedPayloadBody) - } - -} -]# - -proc execute*(ws: GetPayloadBodiesSpec, t: TestEnv): bool = - WDBaseSpec(ws).skipBaseVerifications = true - testCond WDBaseSpec(ws).execute(t) - -#[ - payloadHistory := t.clMock.ExecutedPayloadHistory - - testEngine := t.TestEngine - - if ws.GenerateSidechain { - - # First generate an extra payload on top of the canonical chain - # Generate more withdrawals - nextWithdrawals, _ := ws.GenerateWithdrawalsForBlock(payloadHistory.latestWithdrawalsIndex(), ws.getWithdrawalsStartAccount()) - - f := t.rpcClient.forkchoiceUpdatedV2( - &beacon.ForkchoiceStateV1{ - HeadBlockHash: t.clMock.latestHeader.Hash(), - }, - PayloadAttributes{ - Timestamp: t.clMock.latestHeader.Time + ws.getBlockTimeIncrements(), - Withdrawals: nextWithdrawals, - }, - ) - f.expectPayloadStatus(PayloadExecutionStatus.valid) - - # Wait for payload to be built - await sleepAsync(time.Second) - - # Get the next canonical payload - p := t.rpcClient.getPayloadV2(f.Response.PayloadID) - p.expectNoError() - nextCanonicalPayload := &p.Payload - - # Now we have an extra payload that follows the canonical chain, - # but we need a side chain for the test. - customizer := CustomPayloadData( - Withdrawals: RandomizeWithdrawalsOrder(t.clMock.latestExecutedPayload.Withdrawals), - } - sidechainCurrent, _, err := customizer.CustomizePayload(&t.clMock.latestExecutedPayload, t.clMock.latestPayloadAttributes.BeaconRoot) - if err != nil { - error "Error obtaining custom sidechain payload: %v", t.TestName, err) - } - customizer = CustomPayloadData( - ParentHash: &sidechainCurrent.BlockHash, - Withdrawals: RandomizeWithdrawalsOrder(nextCanonicalPayload.Withdrawals), - } - sidechainHead, _, err := customizer.CustomizePayload(nextCanonicalPayload, t.clMock.latestPayloadAttributes.BeaconRoot) - if err != nil { - error "Error obtaining custom sidechain payload: %v", t.TestName, err) - } - - # Send both sidechain payloads as engine_newPayloadV2 - n1 := t.rpcClient.newPayloadV2(sidechainCurrent) - n1.expectStatus(PayloadExecutionStatus.valid) - n2 := t.rpcClient.newPayloadV2(sidechainHead) - n2.expectStatus(PayloadExecutionStatus.valid) - } else if ws.AfterSync { - # Spawn a secondary client which will need to sync to the primary client - secondaryEngine, err := hive_rpc.HiveRPCEngineStarter{}.StartClient(t.T, t.TestContext, t.Genesis, t.ClientParams, t.ClientFiles, t.Engine) - if err != nil { - error "Unable to spawn a secondary client: %v", t.TestName, err) - } - secondaryEngineTest := test.NewTestEngineClient(t, secondaryEngine) - t.clMock.AddEngineClient(secondaryEngine) - - loop: - for { - select { - case <-t.TimeoutContext.Done(): - error "Timeout while waiting for secondary client to sync", t.TestName) - case <-time.After(time.Second): - secondaryEngineTest.newPayloadV2( - &t.clMock.latestExecutedPayload, - ) - r := secondaryEngineTest.TestEngineForkchoiceUpdatedV2( - &t.clMock.latestForkchoice, - nil, - ) - if r.Response.PayloadStatus.Status == PayloadExecutionStatus.valid { - break loop - } - if r.Response.PayloadStatus.Status == PayloadExecutionStatus.invalid { - error "Syncing client rejected valid chain: %s", t.TestName, r.Response) - } - } - } - - # GetPayloadBodies will be sent to the secondary client - testEngine = secondaryEngineTest - } - - # Now send the range request, which should ignore any sidechain - if ws.Parallel { - wg := new(sync.WaitGroup) - type RequestIndex struct { - Request GetPayloadBodyRequest - Index int - } - workChan := make(chan *RequestIndex) - workers := 16 - wg.Add(workers) - for w := 0; w < workers; w++ { - go func() { - defer wg.Done() - for req := range workChan { - req.Request.Verify(req.Index, testEngine, payloadHistory) - } - }() - } - repeat := 1 - if ws.RequestsRepeat > 0 { - repeat = ws.RequestsRepeat - } - for j := 0; j < repeat; j++ { - for i, req := range ws.getPayloadBodiesRequests { - workChan <- &RequestIndex{ - Request: req, - Index: i + (j * repeat), - } - } - } - - close(workChan) - wg.Wait() - } else { - for i, req := range ws.getPayloadBodiesRequests { - req.Verify(i, testEngine, payloadHistory) -]#