diff --git a/packages/beacon-node/test/spec/presets/index.test.ts b/packages/beacon-node/test/spec/presets/index.test.ts index d6486afa43f8..e8248dc18070 100644 --- a/packages/beacon-node/test/spec/presets/index.test.ts +++ b/packages/beacon-node/test/spec/presets/index.test.ts @@ -19,7 +19,7 @@ import {transition} from "./transition.js"; // Just disable all capella tests as well and renable when new vectors are released // because the latest withdrawals we implemented are a breaking change const skipOpts: SkipOpts = { - skippedForks: ["capella"], + skippedForks: ["eip4844"], skippedRunners: ["light_client", "sync"], skippedHandlers: ["full_withdrawals", "partial_withdrawals", "bls_to_execution_change", "withdrawals"], }; diff --git a/packages/beacon-node/test/spec/presets/sanity.ts b/packages/beacon-node/test/spec/presets/sanity.ts index 5780256dfa61..2bcdcb6f54eb 100644 --- a/packages/beacon-node/test/spec/presets/sanity.ts +++ b/packages/beacon-node/test/spec/presets/sanity.ts @@ -71,7 +71,7 @@ export const sanityBlocks: TestRunnerFn 0) { const latestWithdrawal = expectedWithdrawals[expectedWithdrawals.length - 1]; state.nextWithdrawalIndex = latestWithdrawal.index + 1; + } + + // Update the nextWithdrawalValidatorIndex + if (expectedWithdrawals.length === MAX_WITHDRAWALS_PER_PAYLOAD) { + // All slots filled, nextWithdrawalValidatorIndex should be validatorIndex having next turn + const latestWithdrawal = expectedWithdrawals[expectedWithdrawals.length - 1]; state.nextWithdrawalValidatorIndex = (latestWithdrawal.validatorIndex + 1) % state.validators.length; + } else { + // expected withdrawals came up short in the bound, so we move nextWithdrawalValidatorIndex to + // the next post the bound + state.nextWithdrawalValidatorIndex = + (state.nextWithdrawalValidatorIndex + MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP) % state.validators.length; } } @@ -34,14 +51,14 @@ export function getExpectedWithdrawals( const epoch = state.epochCtx.epoch; let withdrawalIndex = state.nextWithdrawalIndex; const {validators, balances, nextWithdrawalValidatorIndex} = state; - const validatorCount = validators.length; + const bound = Math.min(validators.length, MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP); let n = 0; const withdrawals: capella.Withdrawal[] = []; // Just run a bounded loop max iterating over all withdrawals // however breaks out once we have MAX_WITHDRAWALS_PER_PAYLOAD - for (n = 0; n < validatorCount; n++) { + for (n = 0; n < bound; n++) { // Get next validator in turn const validatorIndex = (nextWithdrawalValidatorIndex + n) % validators.length; diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index bb818f851d0a..1070ef6effee 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -279,7 +279,7 @@ export function initializeBeaconStateFromEth1( ssz.capella.ExecutionPayloadHeader.defaultViewDU(); } - if (GENESIS_SLOT >= config.CAPELLA_FORK_EPOCH) { + if (GENESIS_SLOT >= config.EIP4844_FORK_EPOCH) { const stateEip4844 = state as CompositeViewDU; stateEip4844.fork.previousVersion = config.EIP4844_FORK_VERSION; stateEip4844.fork.currentVersion = config.EIP4844_FORK_VERSION; diff --git a/packages/state-transition/test/perf/block/processWithdrawals.test.ts b/packages/state-transition/test/perf/block/processWithdrawals.test.ts index 6289e62fe282..58f1feb7b113 100644 --- a/packages/state-transition/test/perf/block/processWithdrawals.test.ts +++ b/packages/state-transition/test/perf/block/processWithdrawals.test.ts @@ -32,12 +32,13 @@ describe("getExpectedWithdrawals", () => { // Intermediate bad case {excessBalance: 0.1, eth1Credentials: 0.1, withdrawable: 0, withdrawn: 0, cache: true, sampled: 1_020}, {excessBalance: 0.03, eth1Credentials: 0.03, withdrawable: 0, withdrawn: 0, cache: true, sampled: 11_777}, - {excessBalance: 0.01, eth1Credentials: 0.01, withdrawable: 0, withdrawn: 0, cache: true, sampled: 141_069}, - // Worst case: All validators need to be probed - {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, cache: true, sampled: 250_000}, - {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, cache: false, sampled: 250_000}, - {excessBalance: 0, eth1Credentials: 1, withdrawable: 0, withdrawn: 0, cache: true, sampled: 250_000}, - {excessBalance: 0, eth1Credentials: 1, withdrawable: 0, withdrawn: 0, cache: false, sampled: 250_000}, + // Expected 141_069 but gets bounded at 16_384 + {excessBalance: 0.01, eth1Credentials: 0.01, withdrawable: 0, withdrawn: 0, cache: true, sampled: 16_384}, + // Worst case: All validators 250_000 need to be probed but get bounded at 16_384 + {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, cache: true, sampled: 16_384}, + {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, cache: false, sampled: 16_384}, + {excessBalance: 0, eth1Credentials: 1, withdrawable: 0, withdrawn: 0, cache: true, sampled: 16_384}, + {excessBalance: 0, eth1Credentials: 1, withdrawable: 0, withdrawn: 0, cache: false, sampled: 16_384}, ]; for (const opts of testCases) { diff --git a/packages/state-transition/test/unit/block/processWithdrawals.test.ts b/packages/state-transition/test/unit/block/processWithdrawals.test.ts index 6072a0ba5ae2..e5de11c3063d 100644 --- a/packages/state-transition/test/unit/block/processWithdrawals.test.ts +++ b/packages/state-transition/test/unit/block/processWithdrawals.test.ts @@ -17,9 +17,10 @@ describe("getExpectedWithdrawals", () => { {excessBalance: 0.95, eth1Credentials: 0.7, withdrawable: 0.05, withdrawn: 0, withdrawals: 16, sampled: 18}, // Intermediate bad case {excessBalance: 0.1, eth1Credentials: 0.1, withdrawable: 0, withdrawn: 0, withdrawals: 16, sampled: 1020}, - {excessBalance: 0.01, eth1Credentials: 0.01, withdrawable: 0, withdrawn: 0, withdrawals: 16, sampled: 141069}, - // Worst case: All validators need to be probed - {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, withdrawals: 0, sampled: vc}, + // Expected 141069 but gets bounded by 16384 + {excessBalance: 0.01, eth1Credentials: 0.01, withdrawable: 0, withdrawn: 0, withdrawals: 2, sampled: 16384}, + // Expected 250000 but gets bounded by 16384 + {excessBalance: 0, eth1Credentials: 0.0, withdrawable: 0, withdrawn: 0, withdrawals: 0, sampled: 16384}, ]; for (const opts of testCases) { diff --git a/packages/validator/src/util/params.ts b/packages/validator/src/util/params.ts index fdc6ba18f6a0..44a0cbf20276 100644 --- a/packages/validator/src/util/params.ts +++ b/packages/validator/src/util/params.ts @@ -209,6 +209,7 @@ function getSpecCriticalParams(localConfig: IChainConfig): Record