diff --git a/src/config/ChainConfig.zig b/src/config/ChainConfig.zig index 1bedb4e30..bd9354996 100644 --- a/src/config/ChainConfig.zig +++ b/src/config/ChainConfig.zig @@ -72,6 +72,17 @@ PROPOSER_REORG_CUTOFF_BPS: u64, ATTESTATION_DUE_BPS: u64, ATTESTATION_DUE_BPS_GLOAS: u64, +// Gloas (EIP-7732) +AGGREGATE_DUE_BPS_GLOAS: u64, +SYNC_MESSAGE_DUE_BPS_GLOAS: u64, +CONTRIBUTION_DUE_BPS_GLOAS: u64, +PAYLOAD_DUE_BPS: u64, +PAYLOAD_ATTESTATION_DUE_BPS: u64, +MIN_BUILDER_WITHDRAWABILITY_DELAY: u64, +CHURN_LIMIT_QUOTIENT_GLOAS: u64, +CONSOLIDATION_CHURN_LIMIT_QUOTIENT: u64, +MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS: u64, + // Deposit contract DEPOSIT_CHAIN_ID: u64, DEPOSIT_NETWORK_ID: u64, diff --git a/src/config/networks/gnosis.zig b/src/config/networks/gnosis.zig index ee2377ffd..ebb2b719c 100644 --- a/src/config/networks/gnosis.zig +++ b/src/config/networks/gnosis.zig @@ -65,6 +65,18 @@ pub const chain_config = ChainConfig{ .ATTESTATION_DUE_BPS = 3333, .ATTESTATION_DUE_BPS_GLOAS = 2500, + // Gloas (EIP-7732) + // TODO: These are placeholders. Need to re-visit after gnosis values are out + .AGGREGATE_DUE_BPS_GLOAS = 5000, + .SYNC_MESSAGE_DUE_BPS_GLOAS = 2500, + .CONTRIBUTION_DUE_BPS_GLOAS = 5000, + .PAYLOAD_DUE_BPS = 7500, + .PAYLOAD_ATTESTATION_DUE_BPS = 7500, + .MIN_BUILDER_WITHDRAWABILITY_DELAY = 8192, + .CHURN_LIMIT_QUOTIENT_GLOAS = 32768, + .CONSOLIDATION_CHURN_LIMIT_QUOTIENT = 65536, + .MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS = 256000000000, + // Deposit contract .DEPOSIT_CHAIN_ID = 100, .DEPOSIT_NETWORK_ID = 100, diff --git a/src/config/networks/mainnet.zig b/src/config/networks/mainnet.zig index d20ef1460..2416d89aa 100644 --- a/src/config/networks/mainnet.zig +++ b/src/config/networks/mainnet.zig @@ -65,6 +65,17 @@ pub const chain_config = ChainConfig{ .ATTESTATION_DUE_BPS = 3333, .ATTESTATION_DUE_BPS_GLOAS = 2500, + // Gloas (EIP-7732) + .AGGREGATE_DUE_BPS_GLOAS = 5000, + .SYNC_MESSAGE_DUE_BPS_GLOAS = 2500, + .CONTRIBUTION_DUE_BPS_GLOAS = 5000, + .PAYLOAD_DUE_BPS = 7500, + .PAYLOAD_ATTESTATION_DUE_BPS = 7500, + .MIN_BUILDER_WITHDRAWABILITY_DELAY = 8192, + .CHURN_LIMIT_QUOTIENT_GLOAS = 32768, + .CONSOLIDATION_CHURN_LIMIT_QUOTIENT = 65536, + .MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS = 256000000000, + // Deposit contract .DEPOSIT_CHAIN_ID = 1, .DEPOSIT_NETWORK_ID = 1, diff --git a/src/config/networks/minimal.zig b/src/config/networks/minimal.zig index ae5c2b0d8..69b6af743 100644 --- a/src/config/networks/minimal.zig +++ b/src/config/networks/minimal.zig @@ -65,6 +65,17 @@ pub const chain_config = ChainConfig{ .ATTESTATION_DUE_BPS = 3333, .ATTESTATION_DUE_BPS_GLOAS = 2500, + // Gloas (EIP-7732) + .AGGREGATE_DUE_BPS_GLOAS = 5000, + .SYNC_MESSAGE_DUE_BPS_GLOAS = 2500, + .CONTRIBUTION_DUE_BPS_GLOAS = 5000, + .PAYLOAD_DUE_BPS = 7500, + .PAYLOAD_ATTESTATION_DUE_BPS = 7500, + .MIN_BUILDER_WITHDRAWABILITY_DELAY = 2, + .CHURN_LIMIT_QUOTIENT_GLOAS = 16, + .CONSOLIDATION_CHURN_LIMIT_QUOTIENT = 32, + .MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS = 128000000000, + // Deposit contract .DEPOSIT_CHAIN_ID = 5, .DEPOSIT_NETWORK_ID = 5, diff --git a/src/consensus_types/gloas.zig b/src/consensus_types/gloas.zig index 393b4bf6d..40c3af009 100644 --- a/src/consensus_types/gloas.zig +++ b/src/consensus_types/gloas.zig @@ -77,10 +77,35 @@ pub const AggregateAndProof = electra.AggregateAndProof; pub const SignedAggregateAndProof = electra.SignedAggregateAndProof; pub const SignedBeaconBlockHeader = electra.SignedBeaconBlockHeader; -// Execution payload types remain for envelope usage -pub const ExecutionPayload = electra.ExecutionPayload; +// ExecutionPayloadHeader retained for light client usage pub const ExecutionPayloadHeader = electra.ExecutionPayloadHeader; +// RLP-encoded block access list (EIP-7928) +pub const BlockAccessList = ssz.ByteListType(preset.MAX_BYTES_PER_TRANSACTION); + +// Gloas ExecutionPayload adds block_access_list (EIP-7928) and slot_number (EIP-7843) +pub const ExecutionPayload = ssz.VariableContainerType(struct { + parent_hash: p.Bytes32, + fee_recipient: p.Bytes20, + state_root: p.Bytes32, + receipts_root: p.Bytes32, + logs_bloom: bellatrix.LogsBloom, + prev_randao: p.Bytes32, + block_number: p.Uint64, + gas_limit: p.Uint64, + gas_used: p.Uint64, + timestamp: p.Uint64, + extra_data: bellatrix.ExtraData, + base_fee_per_gas: p.Uint256, + block_hash: p.Bytes32, + transactions: bellatrix.Transactions, + withdrawals: capella.Withdrawals, + blob_gas_used: p.Uint64, + excess_blob_gas: p.Uint64, + block_access_list: BlockAccessList, + slot_number: p.Uint64, +}); + // Reuse Fulu DAS types pub const RowIndex = fulu.RowIndex; pub const ColumnIndex = fulu.ColumnIndex; @@ -89,6 +114,13 @@ pub const Cell = fulu.Cell; pub const MatrixEntry = fulu.MatrixEntry; pub const ProposerLookahead = fulu.ProposerLookahead; +// Cached payload-timeliness committees for the prev/current epoch window (EIP-7732) +pub const PtcWindow = ssz.FixedVectorType( + ssz.FixedVectorType(p.ValidatorIndex, preset.PTC_SIZE, .{}), + (2 + preset.MIN_SEED_LOOKAHEAD) * preset.SLOTS_PER_EPOCH, + .{}, +); + // Light client types pub const LightClientHeader = electra.LightClientHeader; pub const LightClientBootstrap = electra.LightClientBootstrap; @@ -170,6 +202,7 @@ pub const ExecutionPayloadBid = ssz.VariableContainerType(struct { value: p.Uint64, execution_payment: p.Uint64, blob_kzg_commitments: ssz.FixedListType(p.KZGCommitment, preset.MAX_BLOB_COMMITMENTS_PER_BLOCK, .{}), + execution_requests_root: p.Root, }); pub const SignedExecutionPayloadBid = ssz.VariableContainerType(struct { @@ -182,8 +215,7 @@ pub const ExecutionPayloadEnvelope = ssz.VariableContainerType(struct { execution_requests: ExecutionRequests, builder_index: BuilderIndex, beacon_block_root: p.Root, - slot: p.Slot, - state_root: p.Root, + parent_beacon_block_root: p.Root, }); pub const SignedExecutionPayloadEnvelope = ssz.VariableContainerType(struct { @@ -209,6 +241,7 @@ pub const BeaconBlockBody = ssz.VariableContainerType(struct { // executionRequests removed in Gloas (EIP-7732) signed_execution_payload_bid: SignedExecutionPayloadBid, payload_attestations: ssz.FixedListType(PayloadAttestation, preset.MAX_PAYLOAD_ATTESTATIONS, .{}), + parent_execution_requests: ExecutionRequests, }); pub const BeaconBlock = ssz.VariableContainerType(struct { @@ -260,8 +293,8 @@ pub const BeaconState = ssz.VariableContainerType(struct { inactivity_scores: altair.InactivityScores, current_sync_committee: SyncCommittee, next_sync_committee: SyncCommittee, - // latestExecutionPayloadHeader removed in Gloas (EIP-7732) - latest_execution_payload_bid: ExecutionPayloadBid, + // latestExecutionPayloadHeader replaced by latest_block_hash in Gloas (EIP-7732) + latest_block_hash: p.Bytes32, next_withdrawal_index: p.WithdrawalIndex, next_withdrawal_validator_index: p.ValidatorIndex, historical_summaries: ssz.FixedListType(HistoricalSummary, preset.HISTORICAL_ROOTS_LIMIT, .{}), @@ -281,8 +314,9 @@ pub const BeaconState = ssz.VariableContainerType(struct { execution_payload_availability: ssz.BitVectorType(preset.SLOTS_PER_HISTORICAL_ROOT), builder_pending_payments: ssz.FixedVectorType(BuilderPendingPayment, 2 * preset.SLOTS_PER_EPOCH, .{}), builder_pending_withdrawals: ssz.FixedListType(BuilderPendingWithdrawal, preset.BUILDER_PENDING_WITHDRAWALS_LIMIT, .{}), - latest_block_hash: p.Bytes32, + latest_execution_payload_bid: ExecutionPayloadBid, payload_expected_withdrawals: Withdrawals, + ptc_window: PtcWindow, }); pub const BlobSidecar = electra.BlobSidecar; diff --git a/src/constants/root.zig b/src/constants/root.zig index 0038e7bf6..5aed64870 100644 --- a/src/constants/root.zig +++ b/src/constants/root.zig @@ -12,6 +12,7 @@ pub const GENESIS_SLOT = 0; pub const BLS_WITHDRAWAL_PREFIX = 0; pub const ETH1_ADDRESS_WITHDRAWAL_PREFIX = 1; pub const COMPOUNDING_WITHDRAWAL_PREFIX = 2; +pub const BUILDER_WITHDRAWAL_PREFIX = 3; // Gloas (EIP-7732) // Domain types @@ -27,13 +28,25 @@ pub const DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF = [_]u8{ 8, 0, 0, 0 }; pub const DOMAIN_CONTRIBUTION_AND_PROOF = [_]u8{ 9, 0, 0, 0 }; pub const DOMAIN_BLS_TO_EXECUTION_CHANGE = [_]u8{ 10, 0, 0, 0 }; +// Gloas (EIP-7732) domains +pub const DOMAIN_BEACON_BUILDER = [_]u8{ 11, 0, 0, 0 }; // 0x0B000000 +pub const DOMAIN_PTC_ATTESTER = [_]u8{ 12, 0, 0, 0 }; // 0x0C000000 +pub const DOMAIN_PROPOSER_PREFERENCES = [_]u8{ 13, 0, 0, 0 }; // 0x0D000000 + // Application specific domains pub const DOMAIN_APPLICATION_MASK = [_]u8{ 0, 0, 0, 1 }; pub const DOMAIN_APPLICATION_BUILDER = [_]u8{ 0, 0, 0, 1 }; // need to be updated when new domain is added -pub const ALL_DOMAINS = [_][4]u8{ DOMAIN_BEACON_PROPOSER, DOMAIN_BEACON_ATTESTER, DOMAIN_RANDAO, DOMAIN_DEPOSIT, DOMAIN_VOLUNTARY_EXIT, DOMAIN_SELECTION_PROOF, DOMAIN_AGGREGATE_AND_PROOF, DOMAIN_SYNC_COMMITTEE, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, DOMAIN_CONTRIBUTION_AND_PROOF, DOMAIN_BLS_TO_EXECUTION_CHANGE, DOMAIN_APPLICATION_MASK, DOMAIN_APPLICATION_BUILDER }; +pub const ALL_DOMAINS = [_][4]u8{ DOMAIN_BEACON_PROPOSER, DOMAIN_BEACON_ATTESTER, DOMAIN_RANDAO, DOMAIN_DEPOSIT, DOMAIN_VOLUNTARY_EXIT, DOMAIN_SELECTION_PROOF, DOMAIN_AGGREGATE_AND_PROOF, DOMAIN_SYNC_COMMITTEE, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, DOMAIN_CONTRIBUTION_AND_PROOF, DOMAIN_BLS_TO_EXECUTION_CHANGE, DOMAIN_BEACON_BUILDER, DOMAIN_PTC_ATTESTER, DOMAIN_PROPOSER_PREFERENCES, DOMAIN_APPLICATION_MASK, DOMAIN_APPLICATION_BUILDER }; + +// Gloas (EIP-7732) misc + +pub const BUILDER_INDEX_FLAG: u64 = 1 << 40; // 2**40 +pub const BUILDER_INDEX_SELF_BUILD: u64 = std.math.maxInt(u64); +pub const BUILDER_PAYMENT_THRESHOLD_NUMERATOR = 6; +pub const BUILDER_PAYMENT_THRESHOLD_DENOMINATOR = 10; // Participation flag indices diff --git a/src/preset/preset.zig b/src/preset/preset.zig index eb5bafe2c..dd85b491a 100644 --- a/src/preset/preset.zig +++ b/src/preset/preset.zig @@ -87,6 +87,7 @@ const PresetMainnet = struct { pub const MAX_PAYLOAD_ATTESTATIONS = 4; pub const BUILDER_REGISTRY_LIMIT = 1_099_511_627_776; pub const BUILDER_PENDING_WITHDRAWALS_LIMIT = 1_048_576; + pub const MAX_BUILDERS_PER_WITHDRAWALS_SWEEP = 16384; }; const PresetMinimal = struct { @@ -164,6 +165,7 @@ const PresetMinimal = struct { pub const MAX_PAYLOAD_ATTESTATIONS = 4; pub const BUILDER_REGISTRY_LIMIT = 1_099_511_627_776; pub const BUILDER_PENDING_WITHDRAWALS_LIMIT = 1_048_576; + pub const MAX_BUILDERS_PER_WITHDRAWALS_SWEEP = 16; }; const preset_str = @import("build_options").preset;