Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process_execution_payload hash tree root calculation #478

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/lambda_ethereum_consensus/state_transition/operations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
alias LambdaEthereumConsensus.StateTransition.{Accessors, Misc, Mutators, Predicates}
alias LambdaEthereumConsensus.Utils.BitVector
alias SszTypes.BeaconBlockBody
alias LambdaEthereumConsensus.SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Test

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Build project

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (general)

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (general)

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (mainnet)

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (mainnet)

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (minimal)

unused alias SszEx

Check warning on line 10 in lib/lambda_ethereum_consensus/state_transition/operations.ex

View workflow job for this annotation

GitHub Actions / Run spec-tests (minimal)

unused alias SszEx

alias SszTypes.{
Attestation,
Expand Down Expand Up @@ -277,9 +278,10 @@
SszTypes.Transaction
),
{:ok, withdrawals_root} <-
Ssz.hash_list_tree_root(
Ssz.hash_list_tree_root_typed(
payload.withdrawals,
ChainSpec.get("MAX_WITHDRAWALS_PER_PAYLOAD")
ChainSpec.get("MAX_WITHDRAWALS_PER_PAYLOAD"),
SszTypes.Withdrawal
mpaulucci marked this conversation as resolved.
Show resolved Hide resolved
) do
{:ok,
%BeaconState{
Expand Down
32 changes: 22 additions & 10 deletions lib/spec/runners/operations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,28 @@ defmodule OperationsTestRunner do
@disabled_handlers [
# "attester_slashing",
# "attestation",
# "deposit",
# "block_header",
# "deposit",
# "proposer_slashing",
# "voluntary_exit",
# "sync_aggregate",
"execution_payload"
# "execution_payload"
# "withdrawals",
# "bls_to_execution_change"
]

@disabled_cases [
"bad_parent_hash_first_payload"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this case in a follow up since it requires an update to the spec test version and might come with several other changes.

]

@impl TestRunner
def skip?(%SpecTestCase{fork: "capella", handler: handler, case: testcase}) do
Enum.member?(@disabled_handlers, handler) or Enum.member?(@disabled_cases, testcase)
end

@impl TestRunner
def skip?(%SpecTestCase{fork: fork, handler: handler}) do
fork != "capella" or Enum.member?(@disabled_handlers, handler)
def skip?(_testcase) do
true
end

@impl TestRunner
Expand Down Expand Up @@ -89,14 +98,17 @@ defmodule OperationsTestRunner do
YamlElixir.read_from_file!(case_dir <> "/execution.yaml")
|> SpecTestUtils.sanitize_yaml()

new_state = Operations.process_execution_payload(pre, operation, execution_valid)
# dbg(pre.latest_execution_payload_header)
# dbg(operation)
# dbg(post.latest_execution_payload_header)
mpaulucci marked this conversation as resolved.
Show resolved Hide resolved
result = Operations.process_execution_payload(pre, operation, execution_valid)

case post do
nil ->
assert match?({:error, _message}, new_state)
case result do
{:ok, state} ->
assert Diff.diff(state, post) == :unchanged

_ ->
assert new_state == {:ok, post}
{:error, error} ->
assert post == nil, "Execution payload failed, error: #{error}"
end
end

Expand Down
Loading