From 7fc12bf5f7009dbb2ad1e49e99c5efa89a81b4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:29:19 -0300 Subject: [PATCH 01/11] Set .fork_version to deneb --- .fork_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fork_version b/.fork_version index 6e2a11e5e..b89946e8e 100644 --- a/.fork_version +++ b/.fork_version @@ -1 +1 @@ -capella +deneb From 19aa54b2dc9e0b7280fd1dd2b8362abc05800a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:07:46 -0300 Subject: [PATCH 02/11] Use on_deneb macro instead of deneb? bc dialyzer --- .../fork_choice/handlers.ex | 2 +- .../hard_fork_alias_injection.ex | 21 ++++++++++++++----- .../state_transition/accessors.ex | 4 +++- .../state_transition/epoch_processing.ex | 3 ++- .../state_transition/operations.ex | 9 ++++---- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/lambda_ethereum_consensus/fork_choice/handlers.ex b/lib/lambda_ethereum_consensus/fork_choice/handlers.ex index 0db5a2d86..bcaec1b33 100644 --- a/lib/lambda_ethereum_consensus/fork_choice/handlers.ex +++ b/lib/lambda_ethereum_consensus/fork_choice/handlers.ex @@ -189,7 +189,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do # Make it a task so it runs concurrently with the state transition payload_verification_task = Task.async(fn -> - if HardForkAliasInjection.deneb?() do + HardForkAliasInjection.on_deneb do versioned_hashes = block.body.blob_kzg_commitments |> Enum.map(&Misc.kzg_commitment_to_versioned_hash/1) diff --git a/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex b/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex index be75db1a9..ce068074e 100644 --- a/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex +++ b/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex @@ -34,16 +34,27 @@ defmodule HardForkAliasInjection do ## Examples - iex> HardForkAliasInjection.on_deneb(true, false) + iex> HardForkAliasInjection.on_deneb(do: true, else: false) #{is_deneb} + + iex> HardForkAliasInjection.on_deneb(do: true) + #{if is_deneb, do: true, else: nil} """ if is_deneb do - defmacro on_deneb(code, _default) do - code + defmacro on_deneb(do: do_clause) do + do_clause + end + + defmacro on_deneb(do: do_clause, else: _else_clause) do + do_clause end else - defmacro on_deneb(_code, default) do - default + defmacro on_deneb(do: _do_clause) do + nil + end + + defmacro on_deneb(do: _do_clause, else: else_clause) do + else_clause end end end diff --git a/lib/lambda_ethereum_consensus/state_transition/accessors.ex b/lib/lambda_ethereum_consensus/state_transition/accessors.ex index 34e8af144..852d968a3 100644 --- a/lib/lambda_ethereum_consensus/state_transition/accessors.ex +++ b/lib/lambda_ethereum_consensus/state_transition/accessors.ex @@ -392,7 +392,9 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do end defp compute_target_indices(is_matching_target, inclusion_delay) do - if HardForkAliasInjection.deneb?() do + HardForkAliasInjection.on_deneb do + _ = inclusion_delay + if is_matching_target, do: [Constants.timely_target_flag_index()], else: [] diff --git a/lib/lambda_ethereum_consensus/state_transition/epoch_processing.ex b/lib/lambda_ethereum_consensus/state_transition/epoch_processing.ex index 5da07ba4e..556bba332 100644 --- a/lib/lambda_ethereum_consensus/state_transition/epoch_processing.ex +++ b/lib/lambda_ethereum_consensus/state_transition/epoch_processing.ex @@ -142,9 +142,10 @@ defmodule LambdaEthereumConsensus.StateTransition.EpochProcessing do activation_exit_epoch = Misc.compute_activation_exit_epoch(current_epoch) churn_limit = - if HardForkAliasInjection.deneb?(), + HardForkAliasInjection.on_deneb( do: Accessors.get_validator_activation_churn_limit(state), else: Accessors.get_validator_churn_limit(state) + ) result = validators diff --git a/lib/lambda_ethereum_consensus/state_transition/operations.ex b/lib/lambda_ethereum_consensus/state_transition/operations.ex index 170a98ab1..f77fa936c 100644 --- a/lib/lambda_ethereum_consensus/state_transition/operations.ex +++ b/lib/lambda_ethereum_consensus/state_transition/operations.ex @@ -235,7 +235,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do payload.timestamp != Misc.compute_timestamp_at_slot(state, state.slot) -> {:error, "Timestamp verification failed"} - HardForkAliasInjection.on_deneb(body.blob_kzg_commitments |> length(), -1) > + HardForkAliasInjection.on_deneb(do: body.blob_kzg_commitments |> length(), else: -1) > ChainSpec.get("MAX_BLOBS_PER_BLOCK") -> {:error, "Too many commitments"} @@ -270,12 +270,13 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do transactions_root: transactions_root, withdrawals_root: withdrawals_root ] ++ - if HardForkAliasInjection.deneb?(), + HardForkAliasInjection.on_deneb( do: [ blob_gas_used: payload.blob_gas_used, excess_blob_gas: payload.excess_blob_gas ], else: [] + ) header = struct!(ExecutionPayloadHeader, fields) @@ -566,7 +567,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do current_epoch < validator.activation_epoch + ChainSpec.get("SHARD_COMMITTEE_PERIOD") -> {:error, "validator cannot exit yet"} - not ((if HardForkAliasInjection.deneb?() do + not ((HardForkAliasInjection.on_deneb do Misc.compute_domain( Constants.domain_voluntary_exit(), fork_version: ChainSpec.get("CAPELLA_FORK_VERSION"), @@ -846,7 +847,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do end defp check_valid_slot_range(data, state) do - if HardForkAliasInjection.deneb?() do + HardForkAliasInjection.on_deneb do if data.slot + ChainSpec.get("MIN_ATTESTATION_INCLUSION_DELAY") <= state.slot do :ok else From 76a70f79be76f786e426ce6cbb6526ffaa0a03ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:41:40 -0300 Subject: [PATCH 03/11] Update fixtures with deneb features --- lib/types/beacon_chain/beacon_block_body_deneb.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/types/beacon_chain/beacon_block_body_deneb.ex b/lib/types/beacon_chain/beacon_block_body_deneb.ex index fbaa8ebdb..aa8e12b87 100644 --- a/lib/types/beacon_chain/beacon_block_body_deneb.ex +++ b/lib/types/beacon_chain/beacon_block_body_deneb.ex @@ -62,8 +62,9 @@ defmodule Types.BeaconBlockBodyDeneb do {:sync_aggregate, Types.SyncAggregate}, {:execution_payload, Types.ExecutionPayloadDeneb}, {:bls_to_execution_changes, - {:list, Types.BLSToExecutionChange, ChainSpec.get("MAX_BLS_TO_EXECUTION_CHANGES")}}, - {:blob_kzg_commitments, {:list, TypeAliases.kzg_commitment()}} + {:list, Types.SignedBLSToExecutionChange, ChainSpec.get("MAX_BLS_TO_EXECUTION_CHANGES")}}, + {:blob_kzg_commitments, + {:list, TypeAliases.kzg_commitment(), ChainSpec.get("MAX_BLOB_COMMITMENTS_PER_BLOCK")}} ] end end From 6327c6597eb12ea409386c9fbba466b7974d9800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:41:53 -0300 Subject: [PATCH 04/11] Fix `Types.BeaconBlockBodyDeneb` schema --- test/fixtures/block.ex | 144 +++++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 56 deletions(-) diff --git a/test/fixtures/block.ex b/test/fixtures/block.ex index f8c9a409d..d38751c81 100644 --- a/test/fixtures/block.ex +++ b/test/fixtures/block.ex @@ -6,17 +6,25 @@ defmodule Fixtures.Block do alias Fixtures.Random alias LambdaEthereumConsensus.Utils.BitVector - @spec signed_beacon_block :: Types.SignedBeaconBlock.t() + alias Types.BeaconBlock + alias Types.BeaconBlockBody + alias Types.BeaconState + alias Types.ExecutionPayload + alias Types.ExecutionPayloadHeader + alias Types.SignedBeaconBlock + use HardForkAliasInjection + + @spec signed_beacon_block :: SignedBeaconBlock.t() def signed_beacon_block do - %Types.SignedBeaconBlock{ + %SignedBeaconBlock{ message: beacon_block(), signature: Random.bls_signature() } end - @spec beacon_block :: Types.BeaconBlock.t() + @spec beacon_block :: BeaconBlock.t() def beacon_block do - %Types.BeaconBlock{ + %BeaconBlock{ parent_root: Random.root(), slot: Random.uint64(), proposer_index: Random.uint64(), @@ -25,21 +33,29 @@ defmodule Fixtures.Block do } end - @spec beacon_block_body :: Types.BeaconBlockBody.t() + @spec beacon_block_body :: BeaconBlockBody.t() def beacon_block_body do - %Types.BeaconBlockBody{ - randao_reveal: Random.bls_signature(), - eth1_data: eth1_data(), - graffiti: Random.hash32(), - proposer_slashings: [], - attester_slashings: [], - attestations: [], - deposits: [], - voluntary_exits: [], - sync_aggregate: sync_aggregate(), - execution_payload: execution_payload(), - bls_to_execution_changes: [] - } + fields = + [ + randao_reveal: Random.bls_signature(), + eth1_data: eth1_data(), + graffiti: Random.hash32(), + proposer_slashings: [], + attester_slashings: [], + attestations: [], + deposits: [], + voluntary_exits: [], + sync_aggregate: sync_aggregate(), + execution_payload: execution_payload(), + bls_to_execution_changes: [] + ] ++ + HardForkAliasInjection.on_deneb do + [blob_kzg_commitments: []] + else + [] + end + + struct!(BeaconBlockBody, fields) end @spec eth1_data :: Types.Eth1Data.t() @@ -59,25 +75,33 @@ defmodule Fixtures.Block do } end - @spec execution_payload :: Types.ExecutionPayload.t() + @spec execution_payload :: ExecutionPayload.t() def execution_payload do - %Types.ExecutionPayload{ - parent_hash: Random.hash32(), - fee_recipient: Random.execution_address(), - state_root: Random.root(), - receipts_root: Random.root(), - logs_bloom: Random.binary(256), - prev_randao: Random.hash32(), - block_number: Random.uint64(), - gas_limit: Random.uint64(), - gas_used: Random.uint64(), - timestamp: Random.uint64(), - extra_data: Random.binary(30), - base_fee_per_gas: Random.uint64(), - block_hash: Random.binary(32), - transactions: [], - withdrawals: [] - } + fields = + [ + parent_hash: Random.hash32(), + fee_recipient: Random.execution_address(), + state_root: Random.root(), + receipts_root: Random.root(), + logs_bloom: Random.binary(256), + prev_randao: Random.hash32(), + block_number: Random.uint64(), + gas_limit: Random.uint64(), + gas_used: Random.uint64(), + timestamp: Random.uint64(), + extra_data: Random.binary(30), + base_fee_per_gas: Random.uint64(), + block_hash: Random.binary(32), + transactions: [], + withdrawals: [] + ] ++ + HardForkAliasInjection.on_deneb do + [blob_gas_used: 0, excess_blob_gas: 0] + else + [] + end + + struct!(ExecutionPayload, fields) end @spec fork :: Types.Fork.t() @@ -124,30 +148,38 @@ defmodule Fixtures.Block do } end - @spec execution_payload_header :: Types.ExecutionPayloadHeader.t() + @spec execution_payload_header :: ExecutionPayloadHeader.t() def execution_payload_header do - %Types.ExecutionPayloadHeader{ - parent_hash: Random.binary(32), - fee_recipient: Random.binary(20), - state_root: Random.root(), - receipts_root: Random.root(), - logs_bloom: Random.binary(256), - prev_randao: Random.binary(32), - block_number: Random.uint64(), - gas_limit: Random.uint64(), - gas_used: Random.uint64(), - timestamp: Random.uint64(), - extra_data: Random.binary(30), - base_fee_per_gas: Random.uint256(), - block_hash: Random.binary(32), - transactions_root: Random.root(), - withdrawals_root: Random.root() - } + fields = + [ + parent_hash: Random.binary(32), + fee_recipient: Random.binary(20), + state_root: Random.root(), + receipts_root: Random.root(), + logs_bloom: Random.binary(256), + prev_randao: Random.binary(32), + block_number: Random.uint64(), + gas_limit: Random.uint64(), + gas_used: Random.uint64(), + timestamp: Random.uint64(), + extra_data: Random.binary(30), + base_fee_per_gas: Random.uint256(), + block_hash: Random.binary(32), + transactions_root: Random.root(), + withdrawals_root: Random.root() + ] ++ + HardForkAliasInjection.on_deneb do + [blob_gas_used: 0, excess_blob_gas: 0] + else + [] + end + + struct!(ExecutionPayloadHeader, fields) end - @spec beacon_state :: Types.BeaconState.t() + @spec beacon_state :: BeaconState.t() def beacon_state do - %Types.BeaconState{ + %BeaconState{ genesis_time: Random.uint64(), genesis_validators_root: Random.root(), slot: Random.uint64(), From 0fa662a38ee77968deb57b1f00c9ce0919edb493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:24:51 -0300 Subject: [PATCH 05/11] Enable passing deneb tests --- test/spec/runners/epoch_processing.ex | 4 +--- test/spec/runners/finality.ex | 6 ++++++ test/spec/runners/fork_choice.ex | 11 +++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/spec/runners/epoch_processing.ex b/test/spec/runners/epoch_processing.ex index bf1daefc1..561310128 100644 --- a/test/spec/runners/epoch_processing.ex +++ b/test/spec/runners/epoch_processing.ex @@ -38,9 +38,7 @@ defmodule EpochProcessingTestRunner do end @impl TestRunner - def skip?(%SpecTestCase{fork: "deneb"}) do - false - end + def skip?(%SpecTestCase{fork: "deneb"}), do: false @impl TestRunner def skip?(_), do: true diff --git a/test/spec/runners/finality.ex b/test/spec/runners/finality.ex index c5e0d2644..5ba065c3b 100644 --- a/test/spec/runners/finality.ex +++ b/test/spec/runners/finality.ex @@ -19,6 +19,12 @@ defmodule FinalityTestRunner do Enum.member?(@disabled_cases, testcase) end + @impl TestRunner + def skip?(%SpecTestCase{fork: "deneb", case: _testcase}) do + # TODO: all of them fail + true + end + @impl TestRunner def skip?(_), do: true diff --git a/test/spec/runners/fork_choice.ex b/test/spec/runners/fork_choice.ex index 8c7448fba..d4d6021f9 100644 --- a/test/spec/runners/fork_choice.ex +++ b/test/spec/runners/fork_choice.ex @@ -78,6 +78,13 @@ defmodule ForkChoiceTestRunner do # "withholding_attack_unviable_honest_chain" ] + @disabled_deneb [ + "invalid_data_unavailable", + "invalid_wrong_proofs_length", + "invalid_incorrect_proof", + "invalid_wrong_blobs_length" + ] + @impl TestRunner def skip?(%SpecTestCase{fork: "capella", case: testcase}) do Enum.member?(@disabled_on_block_cases, testcase) or @@ -87,6 +94,10 @@ defmodule ForkChoiceTestRunner do Enum.member?(@disabled_withholding_cases, testcase) end + def skip?(%SpecTestCase{fork: "deneb", case: testcase}) do + Enum.member?(@disabled_deneb, testcase) + end + def skip?(_testcase), do: true @impl TestRunner From b1082482e9c778deff845a116a27dcbdc2f516ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:43:08 -0300 Subject: [PATCH 06/11] Mark failed spectest runners --- test/spec/runners/fork_choice.ex | 1 + test/spec/runners/light_client.ex | 5 +++++ test/spec/runners/random.ex | 5 +++++ test/spec/runners/rewards.ex | 7 +++++-- test/spec/runners/sanity.ex | 5 +++++ test/spec/runners/ssz_generic.ex | 10 +++------- test/spec/runners/ssz_static.ex | 12 ++++++++++-- test/spec/runners/sync.ex | 6 ++++-- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/test/spec/runners/fork_choice.ex b/test/spec/runners/fork_choice.ex index d4d6021f9..354e0f6eb 100644 --- a/test/spec/runners/fork_choice.ex +++ b/test/spec/runners/fork_choice.ex @@ -78,6 +78,7 @@ defmodule ForkChoiceTestRunner do # "withholding_attack_unviable_honest_chain" ] + # TODO: implement blob checks @disabled_deneb [ "invalid_data_unavailable", "invalid_wrong_proofs_length", diff --git a/test/spec/runners/light_client.ex b/test/spec/runners/light_client.ex index eae0e9bbb..01620af0d 100644 --- a/test/spec/runners/light_client.ex +++ b/test/spec/runners/light_client.ex @@ -19,6 +19,11 @@ defmodule LightClientTestRunner do Enum.member?(@disabled_handlers, testcase.handler) end + def skip?(%SpecTestCase{fork: "deneb"} = _testcase) do + # TODO: all of them fail + true + end + @impl TestRunner def skip?(_testcase) do true diff --git a/test/spec/runners/random.ex b/test/spec/runners/random.ex index a2ede505d..af53a07ea 100644 --- a/test/spec/runners/random.ex +++ b/test/spec/runners/random.ex @@ -30,6 +30,11 @@ defmodule RandomTestRunner do Enum.member?(@disabled_cases, testcase) end + def skip?(%SpecTestCase{fork: "deneb", case: _testcase}) do + # TODO: all of them fail + true + end + @impl TestRunner def skip?(_), do: true diff --git a/test/spec/runners/rewards.ex b/test/spec/runners/rewards.ex index adea7bb80..3795a8af3 100644 --- a/test/spec/runners/rewards.ex +++ b/test/spec/runners/rewards.ex @@ -15,10 +15,13 @@ defmodule RewardsTestRunner do ] @impl TestRunner - def skip?(%SpecTestCase{fork: fork, handler: handler}) do - fork != "capella" or Enum.member?(@disabled, handler) + def skip?(%SpecTestCase{fork: "capella", handler: handler}) do + Enum.member?(@disabled, handler) end + def skip?(%SpecTestCase{fork: "deneb"}), do: false + def skip?(_), do: true + @impl TestRunner def run_test_case(%SpecTestCase{} = testcase) do case_dir = SpecTestCase.dir(testcase) diff --git a/test/spec/runners/sanity.ex b/test/spec/runners/sanity.ex index 28402cd42..7813b89c9 100644 --- a/test/spec/runners/sanity.ex +++ b/test/spec/runners/sanity.ex @@ -105,6 +105,11 @@ defmodule SanityTestRunner do Enum.member?(@disabled_slot_cases, testcase) end + def skip?(%SpecTestCase{fork: "deneb"}) do + # TODO: all of them fail + true + end + def skip?(_), do: true @impl TestRunner diff --git a/test/spec/runners/ssz_generic.ex b/test/spec/runners/ssz_generic.ex index 55c7b6007..03416f2c7 100644 --- a/test/spec/runners/ssz_generic.ex +++ b/test/spec/runners/ssz_generic.ex @@ -6,7 +6,7 @@ defmodule SszGenericTestRunner do use ExUnit.CaseTemplate use TestRunner - @disabled [ + @disabled_handlers [ # "basic_vector", # "bitlist", # "bitvector" @@ -26,12 +26,8 @@ defmodule SszGenericTestRunner do @impl TestRunner def skip?(%SpecTestCase{fork: fork, handler: handler, case: cse}) do - skip_container? = - @disabled_containers - |> Enum.map(fn container -> String.contains?(cse, container) end) - |> Enum.any?() - - fork != "phase0" or Enum.member?(@disabled, handler) or skip_container? + skip_container? = Enum.any?(@disabled_containers, &String.contains?(cse, &1)) + fork != "phase0" or Enum.member?(@disabled_handlers, handler) or skip_container? end @impl TestRunner diff --git a/test/spec/runners/ssz_static.ex b/test/spec/runners/ssz_static.ex index 3b0f073e5..193f6388b 100644 --- a/test/spec/runners/ssz_static.ex +++ b/test/spec/runners/ssz_static.ex @@ -61,10 +61,18 @@ defmodule SszStaticTestRunner do ] @impl TestRunner - def skip?(%SpecTestCase{fork: fork, handler: handler}) do - fork != "capella" or Enum.member?(@disabled, handler) + def skip?(%SpecTestCase{fork: "capella", handler: handler}) do + Enum.member?(@disabled, handler) end + def skip?(%SpecTestCase{fork: "deneb", handler: handler}) do + # TODO: fix types + # Enum.member?(@disabled, handler) + true + end + + def skip?(_), do: true + @impl TestRunner def run_test_case(%SpecTestCase{} = testcase) do case_dir = SpecTestCase.dir(testcase) diff --git a/test/spec/runners/sync.ex b/test/spec/runners/sync.ex index dab32d54e..ec5bce6b6 100644 --- a/test/spec/runners/sync.ex +++ b/test/spec/runners/sync.ex @@ -18,11 +18,13 @@ defmodule SyncTestRunner do Enum.member?(@disabled_cases, testcase.case) end - @impl TestRunner - def skip?(_testcase) do + def skip?(%SpecTestCase{fork: "deneb"} = testcase) do + # TODO: fix true end + def skip?(_testcase), do: true + @impl TestRunner def run_test_case(%SpecTestCase{} = testcase) do original_engine_api_config = From 1c48901846986e103b911c067a75a66d02d8b0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:49:18 -0300 Subject: [PATCH 07/11] Specify `sync` requirements --- test/spec/runners/sync.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/spec/runners/sync.ex b/test/spec/runners/sync.ex index ec5bce6b6..39f2060d8 100644 --- a/test/spec/runners/sync.ex +++ b/test/spec/runners/sync.ex @@ -19,7 +19,8 @@ defmodule SyncTestRunner do end def skip?(%SpecTestCase{fork: "deneb"} = testcase) do - # TODO: fix + # TODO: update `EngineApiMock` to support the new `new_payload/3` function, + # and the runner to load the block's blobs if on deneb true end From 36436ee43d804d80e11eeac4090f43429c3f6b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:17:54 -0300 Subject: [PATCH 08/11] Fix types in ssz_static --- test/spec/runners/ssz_static.ex | 22 +++++++++++++++++++--- test/spec/runners/sync.ex | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/spec/runners/ssz_static.ex b/test/spec/runners/ssz_static.ex index 193f6388b..ceff8ec75 100644 --- a/test/spec/runners/ssz_static.ex +++ b/test/spec/runners/ssz_static.ex @@ -5,6 +5,14 @@ defmodule SszStaticTestRunner do alias LambdaEthereumConsensus.SszEx alias LambdaEthereumConsensus.Utils.Diff alias Ssz + alias Types.BeaconBlock + alias Types.BeaconBlockBody + alias Types.BeaconState + alias Types.ExecutionPayload + alias Types.ExecutionPayloadHeader + alias Types.SignedBeaconBlock + + use HardForkAliasInjection use ExUnit.CaseTemplate use TestRunner @@ -60,6 +68,15 @@ defmodule SszStaticTestRunner do "SyncCommitteeMessage" ] + @type_map %{ + "BeaconBlock" => BeaconBlock, + "BeaconBlockBody" => BeaconBlockBody, + "BeaconState" => BeaconState, + "ExecutionPayload" => ExecutionPayload, + "ExecutionPayloadHeader" => ExecutionPayloadHeader, + "SignedBeaconBlock" => SignedBeaconBlock + } + @impl TestRunner def skip?(%SpecTestCase{fork: "capella", handler: handler}) do Enum.member?(@disabled, handler) @@ -67,8 +84,7 @@ defmodule SszStaticTestRunner do def skip?(%SpecTestCase{fork: "deneb", handler: handler}) do # TODO: fix types - # Enum.member?(@disabled, handler) - true + Enum.member?(@disabled, handler) end def skip?(_), do: true @@ -115,6 +131,6 @@ defmodule SszStaticTestRunner do end defp parse_type(%SpecTestCase{handler: handler}) do - Module.concat(Types, handler) + Map.get(@type_map, handler, Module.concat(Types, handler)) end end diff --git a/test/spec/runners/sync.ex b/test/spec/runners/sync.ex index 39f2060d8..f27370d74 100644 --- a/test/spec/runners/sync.ex +++ b/test/spec/runners/sync.ex @@ -18,7 +18,7 @@ defmodule SyncTestRunner do Enum.member?(@disabled_cases, testcase.case) end - def skip?(%SpecTestCase{fork: "deneb"} = testcase) do + def skip?(%SpecTestCase{fork: "deneb"}) do # TODO: update `EngineApiMock` to support the new `new_payload/3` function, # and the runner to load the block's blobs if on deneb true From 3344ce439e5780a78b9087bafa6da8872cc0eb11 Mon Sep 17 00:00:00 2001 From: Martin Paulucci Date: Tue, 12 Mar 2024 18:28:08 -0300 Subject: [PATCH 09/11] Unskip passing tests on deneb. --- test/spec/runners/finality.ex | 5 ++--- test/spec/runners/helpers/process_blocks.ex | 3 ++- test/spec/runners/random.ex | 5 +++++ test/spec/runners/sanity.ex | 9 ++++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/spec/runners/finality.ex b/test/spec/runners/finality.ex index 5ba065c3b..99f7a3cc3 100644 --- a/test/spec/runners/finality.ex +++ b/test/spec/runners/finality.ex @@ -20,9 +20,8 @@ defmodule FinalityTestRunner do end @impl TestRunner - def skip?(%SpecTestCase{fork: "deneb", case: _testcase}) do - # TODO: all of them fail - true + def skip?(%SpecTestCase{fork: "deneb", case: testcase}) do + Enum.member?(@disabled_cases, testcase) end @impl TestRunner diff --git a/test/spec/runners/helpers/process_blocks.ex b/test/spec/runners/helpers/process_blocks.ex index a59867d9d..8340f8d8f 100644 --- a/test/spec/runners/helpers/process_blocks.ex +++ b/test/spec/runners/helpers/process_blocks.ex @@ -8,6 +8,7 @@ defmodule Helpers.ProcessBlocks do alias LambdaEthereumConsensus.StateTransition alias LambdaEthereumConsensus.Utils.Diff alias Types.BeaconState + alias Types.SignedBeaconBlock use HardForkAliasInjection @@ -27,7 +28,7 @@ defmodule Helpers.ProcessBlocks do |> Enum.map(fn index -> SpecTestUtils.read_ssz_from_file!( case_dir <> "/blocks_#{index}.ssz_snappy", - Types.SignedBeaconBlock + SignedBeaconBlock ) end) diff --git a/test/spec/runners/random.ex b/test/spec/runners/random.ex index af53a07ea..34533a234 100644 --- a/test/spec/runners/random.ex +++ b/test/spec/runners/random.ex @@ -35,6 +35,11 @@ defmodule RandomTestRunner do true end + @impl TestRunner + def skip?(%SpecTestCase{fork: "deneb", case: testcase}) do + Enum.member?(@disabled_cases, testcase) + end + @impl TestRunner def skip?(_), do: true diff --git a/test/spec/runners/sanity.ex b/test/spec/runners/sanity.ex index 7813b89c9..6e74859db 100644 --- a/test/spec/runners/sanity.ex +++ b/test/spec/runners/sanity.ex @@ -105,9 +105,12 @@ defmodule SanityTestRunner do Enum.member?(@disabled_slot_cases, testcase) end - def skip?(%SpecTestCase{fork: "deneb"}) do - # TODO: all of them fail - true + def skip?(%SpecTestCase{fork: "deneb", handler: "blocks", case: testcase}) do + Enum.member?(@disabled_block_cases, testcase) + end + + def skip?(%SpecTestCase{fork: "deneb", handler: "slots", case: testcase}) do + Enum.member?(@disabled_slot_cases, testcase) end def skip?(_), do: true From 3001a1c2f8d45996e7bd73d68432f704138bd80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:05:36 -0300 Subject: [PATCH 10/11] Simplify fork_choice runner a bit --- test/spec/runners/fork_choice.ex | 70 +------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/test/spec/runners/fork_choice.ex b/test/spec/runners/fork_choice.ex index 354e0f6eb..4b3925b01 100644 --- a/test/spec/runners/fork_choice.ex +++ b/test/spec/runners/fork_choice.ex @@ -16,68 +16,6 @@ defmodule ForkChoiceTestRunner do use HardForkAliasInjection - @disabled_on_block_cases [ - # "basic", - # "incompatible_justification_update_end_of_epoch", - # "incompatible_justification_update_start_of_epoch", - # "justification_update_beginning_of_epoch", - # "justification_update_end_of_epoch", - # "justification_withholding", - # "justification_withholding_reverse_order", - # "justified_update_always_if_better", - # "justified_update_monotonic", - # "justified_update_not_realized_finality", - # "new_finalized_slot_is_justified_checkpoint_ancestor", - # "not_pull_up_current_epoch_block", - # "on_block_bad_parent_root", - # "on_block_before_finalized", - # "on_block_checkpoints", - # "on_block_finalized_skip_slots", - # "on_block_finalized_skip_slots_not_in_skip_chain", - # "on_block_future_block", - # "proposer_boost", - # "proposer_boost_root_same_slot_untimely_block", - # "pull_up_on_tick", - # "pull_up_past_epoch_block" - ] - - @disabled_ex_ante_cases [ - # "ex_ante_attestations_is_greater_than_proposer_boost_with_boost", - # "ex_ante_sandwich_with_boost_not_sufficient", - # "ex_ante_sandwich_with_honest_attestation", - # "ex_ante_sandwich_without_attestations", - # "ex_ante_vanilla" - ] - - @disabled_get_head_cases [ - # "chain_no_attestations", - # "discard_equivocations_on_attester_slashing", - # "discard_equivocations_slashed_validator_censoring", - # "filtered_block_tree", - # "genesis", - # "proposer_boost_correct_head", - # "shorter_chain_but_heavier_weight", - # "split_tie_breaker_no_attestations", - # "voting_source_beyond_two_epoch", - # "voting_source_within_two_epoch" - ] - - @disabled_reorg_cases [ - # "delayed_justification_current_epoch", - # "delayed_justification_previous_epoch", - # "include_votes_another_empty_chain_with_enough_ffg_votes_current_epoch", - # "include_votes_another_empty_chain_with_enough_ffg_votes_previous_epoch", - # "include_votes_another_empty_chain_without_enough_ffg_votes_current_epoch", - # "simple_attempted_reorg_delayed_justification_current_epoch", - # "simple_attempted_reorg_delayed_justification_previous_epoch", - # "simple_attempted_reorg_without_enough_ffg_votes" - ] - - @disabled_withholding_cases [ - # "withholding_attack", - # "withholding_attack_unviable_honest_chain" - ] - # TODO: implement blob checks @disabled_deneb [ "invalid_data_unavailable", @@ -87,13 +25,7 @@ defmodule ForkChoiceTestRunner do ] @impl TestRunner - def skip?(%SpecTestCase{fork: "capella", case: testcase}) do - Enum.member?(@disabled_on_block_cases, testcase) or - Enum.member?(@disabled_ex_ante_cases, testcase) or - Enum.member?(@disabled_get_head_cases, testcase) or - Enum.member?(@disabled_reorg_cases, testcase) or - Enum.member?(@disabled_withholding_cases, testcase) - end + def skip?(%SpecTestCase{fork: "capella"}), do: false def skip?(%SpecTestCase{fork: "deneb", case: testcase}) do Enum.member?(@disabled_deneb, testcase) From 53f96ad496ee1821b9ade56d45229a70dbc92cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:07:59 -0300 Subject: [PATCH 11/11] Simplify random runner --- test/spec/runners/random.ex | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/test/spec/runners/random.ex b/test/spec/runners/random.ex index 34533a234..5fd9a957b 100644 --- a/test/spec/runners/random.ex +++ b/test/spec/runners/random.ex @@ -6,41 +6,9 @@ defmodule RandomTestRunner do use ExUnit.CaseTemplate use TestRunner - @disabled_cases [ - # "randomized_0", - # "randomized_1", - # "randomized_2", - # "randomized_3", - # "randomized_4", - # "randomized_5", - # "randomized_6", - # "randomized_7", - # "randomized_8", - # "randomized_9", - # "randomized_10", - # "randomized_11", - # "randomized_12", - # "randomized_13", - # "randomized_14", - # "randomized_15" - ] - - @impl TestRunner - def skip?(%SpecTestCase{fork: "capella", case: testcase}) do - Enum.member?(@disabled_cases, testcase) - end - - def skip?(%SpecTestCase{fork: "deneb", case: _testcase}) do - # TODO: all of them fail - true - end - - @impl TestRunner - def skip?(%SpecTestCase{fork: "deneb", case: testcase}) do - Enum.member?(@disabled_cases, testcase) - end - @impl TestRunner + def skip?(%SpecTestCase{fork: "capella"}), do: false + def skip?(%SpecTestCase{fork: "deneb"}), do: false def skip?(_), do: true @impl TestRunner