From 83823d56e660ab917824aac46bdd7a7afb31a249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:56:07 -0300 Subject: [PATCH 1/2] chore: modify credo to use parentheses on 0-arity --- .credo.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.credo.exs b/.credo.exs index 6f2a66601..5efc123ed 100644 --- a/.credo.exs +++ b/.credo.exs @@ -93,7 +93,7 @@ {Credo.Check.Readability.ModuleDoc, []}, {Credo.Check.Readability.ModuleNames, []}, {Credo.Check.Readability.ParenthesesInCondition, []}, - {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, [parens: true]}, {Credo.Check.Readability.PipeIntoAnonymousFunctions, []}, {Credo.Check.Readability.PredicateFunctionNames, []}, {Credo.Check.Readability.PreferImplicitTry, []}, From c30135f40e9221e5420d0dd4a87152e2b35ea51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:59:20 -0300 Subject: [PATCH 2/2] Reformat --- lib/beacon_api/api_spec.ex | 2 +- lib/beacon_api/beacon_api.ex | 4 +- lib/chain_spec/chain_spec.ex | 6 +- lib/chain_spec/configs/custom.ex | 2 +- lib/chain_spec/configs/gen_config.ex | 2 +- lib/chain_spec/configs/gnosis.ex | 2 +- lib/chain_spec/configs/holesky.ex | 2 +- lib/chain_spec/configs/mainnet.ex | 2 +- lib/chain_spec/configs/minimal.ex | 2 +- lib/chain_spec/configs/sepolia.ex | 2 +- lib/chain_spec/presets/gen_preset.ex | 2 +- lib/constants.ex | 74 +++++++++---------- lib/lambda_ethereum_consensus/application.ex | 2 +- .../beacon/beacon_chain.ex | 18 ++--- .../beacon/pending_blocks.ex | 6 +- .../beacon/store_setup.ex | 8 +- .../execution/auth.ex | 2 +- .../execution/engine_api.ex | 4 +- .../execution/engine_api/api.ex | 2 +- .../execution/engine_api/mocked.ex | 2 +- .../execution/execution_chain.ex | 2 +- .../fork_choice/old_tree.ex | 2 +- .../hard_fork_alias_injection.ex | 2 +- .../p2p/blob_downloader.ex | 2 +- .../p2p/block_downloader.ex | 2 +- .../p2p/gossip/attestation.ex | 4 +- lib/lambda_ethereum_consensus/p2p/metadata.ex | 4 +- lib/lambda_ethereum_consensus/p2p/peerbook.ex | 2 +- .../state_transition/cache.ex | 4 +- .../store/block_db.ex | 4 +- lib/lambda_ethereum_consensus/store/db.ex | 6 +- .../store/state_db.ex | 2 +- .../store/store_db.ex | 2 +- lib/lambda_ethereum_consensus/telemetry.ex | 6 +- .../validator/block_builder.ex | 4 +- .../validator/validator.ex | 2 +- lib/libp2p/libp2p.ex | 4 +- lib/libp2p_port.ex | 6 +- lib/ssz.ex | 2 +- lib/ssz_ex/hash.ex | 2 +- lib/types/beacon_chain/attestation.ex | 2 +- lib/types/beacon_chain/attestation_data.ex | 2 +- lib/types/beacon_chain/attester_slashing.ex | 2 +- lib/types/beacon_chain/beacon_block.ex | 2 +- lib/types/beacon_chain/beacon_block_body.ex | 2 +- lib/types/beacon_chain/beacon_block_header.ex | 2 +- lib/types/beacon_chain/beacon_state.ex | 2 +- lib/types/beacon_chain/blob_identifier.ex | 2 +- lib/types/beacon_chain/blob_sidecar.ex | 2 +- .../beacon_chain/bls_to_execution_change.ex | 2 +- lib/types/beacon_chain/checkpoint.ex | 2 +- lib/types/beacon_chain/deposit.ex | 2 +- lib/types/beacon_chain/deposit_data.ex | 2 +- lib/types/beacon_chain/deposit_message.ex | 2 +- lib/types/beacon_chain/eth1_block.ex | 2 +- lib/types/beacon_chain/eth1_data.ex | 2 +- lib/types/beacon_chain/execution_payload.ex | 2 +- .../beacon_chain/execution_payload_header.ex | 4 +- lib/types/beacon_chain/fork.ex | 2 +- lib/types/beacon_chain/fork_data.ex | 2 +- lib/types/beacon_chain/historical_batch.ex | 2 +- lib/types/beacon_chain/historical_summary.ex | 2 +- lib/types/beacon_chain/indexed_attestation.ex | 2 +- lib/types/beacon_chain/pending_attestation.ex | 2 +- lib/types/beacon_chain/proposer_slashing.ex | 2 +- lib/types/beacon_chain/signed_beacon_block.ex | 2 +- .../signed_beacon_block_header.ex | 2 +- .../signed_bls_to_execution_change.ex | 2 +- .../beacon_chain/signed_voluntary_exit.ex | 2 +- lib/types/beacon_chain/signing_data.ex | 2 +- lib/types/beacon_chain/sync_aggregate.ex | 2 +- .../sync_aggregator_selection_data.ex | 2 +- lib/types/beacon_chain/sync_committee.ex | 2 +- lib/types/beacon_chain/validator.ex | 2 +- lib/types/beacon_chain/voluntary_exit.ex | 2 +- lib/types/beacon_chain/withdrawal.ex | 2 +- lib/types/blobdata.ex | 2 +- lib/types/deposit_tree.ex | 2 +- .../p2p/beacon_blocks_by_range_request.ex | 2 +- lib/types/p2p/enr_fork_id.ex | 2 +- lib/types/p2p/metadata.ex | 4 +- lib/types/p2p/status_message.ex | 2 +- lib/types/type_aliases.ex | 56 +++++++------- lib/types/validator/aggregate_and_proof.ex | 2 +- lib/types/validator/contribution_and_proof.ex | 2 +- .../validator/signed_aggregate_and_proof.ex | 2 +- .../signed_contribution_and_proof.ex | 2 +- .../validator/sync_committee_contribution.ex | 2 +- lib/types/validator/sync_committee_message.ex | 2 +- lib/utils/bit_list.ex | 2 +- lib/utils/profile.ex | 2 +- mix.exs | 8 +- test/fixtures/block.ex | 26 +++---- test/fixtures/utils.ex | 14 ++-- test/spec/meta_utils.ex | 8 +- .../ssz_static_containers/bits_struct.ex | 2 +- .../complex_test_struct.ex | 2 +- .../fixed_test_struct.ex | 2 +- .../single_field_test_struct.ex | 2 +- .../small_test_struct.ex | 2 +- .../ssz_static_containers/var_test_struct.ex | 2 +- test/spec/runners/rewards.ex | 2 +- test/spec/runners/sync.ex | 2 +- test/spec/utils.ex | 2 +- test/unit/libp2p_port_test.exs | 2 +- 105 files changed, 223 insertions(+), 223 deletions(-) diff --git a/lib/beacon_api/api_spec.ex b/lib/beacon_api/api_spec.ex index 7e39cb5c6..d75ebe0ed 100644 --- a/lib/beacon_api/api_spec.ex +++ b/lib/beacon_api/api_spec.ex @@ -10,5 +10,5 @@ defmodule BeaconApi.ApiSpec do |> OpenApiSpex.OpenApi.Decode.decode() @impl OpenApi - def spec, do: @ethspec + def spec(), do: @ethspec end diff --git a/lib/beacon_api/beacon_api.ex b/lib/beacon_api/beacon_api.ex index e762a21e4..f7f7e8f5c 100644 --- a/lib/beacon_api/beacon_api.ex +++ b/lib/beacon_api/beacon_api.ex @@ -17,7 +17,7 @@ defmodule BeaconApi do those modules here. """ - def router do + def router() do quote do use Phoenix.Router, helpers: false @@ -27,7 +27,7 @@ defmodule BeaconApi do end end - def controller do + def controller() do quote do use Phoenix.Controller, formats: [:json] diff --git a/lib/chain_spec/chain_spec.ex b/lib/chain_spec/chain_spec.ex index 91a6386bd..30fc3682e 100644 --- a/lib/chain_spec/chain_spec.ex +++ b/lib/chain_spec/chain_spec.ex @@ -3,10 +3,10 @@ defmodule ChainSpec do Single entrypoint for fetching chain-specific constants. """ - def get_config, + def get_config(), do: Application.fetch_env!(:lambda_ethereum_consensus, __MODULE__) |> Keyword.fetch!(:config) - def get_preset, do: get_config().get("PRESET_BASE") |> String.to_atom() + def get_preset(), do: get_config().get("PRESET_BASE") |> String.to_atom() def get_fork_version_for_epoch(epoch) do if epoch >= get("DENEB_FORK_EPOCH") do @@ -19,7 +19,7 @@ defmodule ChainSpec do # NOTE: this only works correctly for Capella def get(name), do: get_config().get(name) - def get_genesis_validators_root do + def get_genesis_validators_root() do Application.fetch_env!(:lambda_ethereum_consensus, __MODULE__) |> Keyword.fetch!(:genesis_validators_root) end diff --git a/lib/chain_spec/configs/custom.ex b/lib/chain_spec/configs/custom.ex index 75c9a5070..f16e1311b 100644 --- a/lib/chain_spec/configs/custom.ex +++ b/lib/chain_spec/configs/custom.ex @@ -19,7 +19,7 @@ defmodule CustomConfig do end @impl GenConfig - def get_all do + def get_all() do Application.get_env(:lambda_ethereum_consensus, __MODULE__) |> Keyword.fetch!(:merged) |> Map.new(fn {k, v} -> {k, parse_int(v)} end) diff --git a/lib/chain_spec/configs/gen_config.ex b/lib/chain_spec/configs/gen_config.ex index e1459defd..e85d49f8d 100644 --- a/lib/chain_spec/configs/gen_config.ex +++ b/lib/chain_spec/configs/gen_config.ex @@ -23,7 +23,7 @@ defmodule ChainSpec.GenConfig do def get(key), do: Map.fetch!(@__unified, key) @impl unquote(__MODULE__) - def get_all, do: @__unified + def get_all(), do: @__unified end end diff --git a/lib/chain_spec/configs/gnosis.ex b/lib/chain_spec/configs/gnosis.ex index db3e4bb20..37295a632 100644 --- a/lib/chain_spec/configs/gnosis.ex +++ b/lib/chain_spec/configs/gnosis.ex @@ -7,5 +7,5 @@ defmodule GnosisConfig do genesis_validators_root = Base.decode16!("F5DCB5564E829AAB27264B9BECD5DFAA017085611224CB3036F573368DBB9D47") - def genesis_validators_root, do: unquote(genesis_validators_root) + def genesis_validators_root(), do: unquote(genesis_validators_root) end diff --git a/lib/chain_spec/configs/holesky.ex b/lib/chain_spec/configs/holesky.ex index 07ae659be..23cbc62f5 100644 --- a/lib/chain_spec/configs/holesky.ex +++ b/lib/chain_spec/configs/holesky.ex @@ -7,5 +7,5 @@ defmodule HoleskyConfig do genesis_validators_root = Base.decode16!("9143AA7C615A7F7115E2B6AAC319C03529DF8242AE705FBA9DF39B79C59FA8B1") - def genesis_validators_root, do: unquote(genesis_validators_root) + def genesis_validators_root(), do: unquote(genesis_validators_root) end diff --git a/lib/chain_spec/configs/mainnet.ex b/lib/chain_spec/configs/mainnet.ex index f6872ebce..bf3fe17dd 100644 --- a/lib/chain_spec/configs/mainnet.ex +++ b/lib/chain_spec/configs/mainnet.ex @@ -7,5 +7,5 @@ defmodule MainnetConfig do genesis_validators_root = Base.decode16!("4B363DB94E286120D76EB905340FDD4E54BFE9F06BF33FF6CF5AD27F511BFE95") - def genesis_validators_root, do: unquote(genesis_validators_root) + def genesis_validators_root(), do: unquote(genesis_validators_root) end diff --git a/lib/chain_spec/configs/minimal.ex b/lib/chain_spec/configs/minimal.ex index dc61b20ad..710e61e0d 100644 --- a/lib/chain_spec/configs/minimal.ex +++ b/lib/chain_spec/configs/minimal.ex @@ -4,5 +4,5 @@ defmodule MinimalConfig do """ use ChainSpec.GenConfig, file: "config/networks/minimal/config.yaml" - def genesis_validators_root, do: <<0::256>> + def genesis_validators_root(), do: <<0::256>> end diff --git a/lib/chain_spec/configs/sepolia.ex b/lib/chain_spec/configs/sepolia.ex index 9aeb72478..72eaacf96 100644 --- a/lib/chain_spec/configs/sepolia.ex +++ b/lib/chain_spec/configs/sepolia.ex @@ -7,5 +7,5 @@ defmodule SepoliaConfig do genesis_validators_root = Base.decode16!("D8EA171F3C94AEA21EBC42A1ED61052ACF3F9209C00E4EFBAADDAC09ED9B8078") - def genesis_validators_root, do: unquote(genesis_validators_root) + def genesis_validators_root(), do: unquote(genesis_validators_root) end diff --git a/lib/chain_spec/presets/gen_preset.ex b/lib/chain_spec/presets/gen_preset.ex index 22abb16eb..d8c37ad65 100644 --- a/lib/chain_spec/presets/gen_preset.ex +++ b/lib/chain_spec/presets/gen_preset.ex @@ -16,7 +16,7 @@ defmodule ChainSpec.GenPreset do @behaviour unquote(__MODULE__) @impl unquote(__MODULE__) - def get_preset, do: @__parsed_preset + def get_preset(), do: @__parsed_preset end end diff --git a/lib/constants.ex b/lib/constants.ex index 45236f3ca..1beccc676 100644 --- a/lib/constants.ex +++ b/lib/constants.ex @@ -7,126 +7,126 @@ defmodule Constants do ### Misc @spec genesis_epoch() :: Types.slot() - def genesis_epoch, do: 0 + def genesis_epoch(), do: 0 @spec genesis_slot() :: Types.slot() - def genesis_slot, do: 0 + def genesis_slot(), do: 0 @far_future_epoch 2 ** 64 - 1 @spec far_future_epoch() :: non_neg_integer() - def far_future_epoch, do: @far_future_epoch + def far_future_epoch(), do: @far_future_epoch @spec base_rewards_per_epoch() :: non_neg_integer() - def base_rewards_per_epoch, do: 4 + def base_rewards_per_epoch(), do: 4 @spec deposit_contract_tree_depth() :: non_neg_integer() - def deposit_contract_tree_depth, do: 32 + def deposit_contract_tree_depth(), do: 32 @spec justification_bits_length() :: non_neg_integer() - def justification_bits_length, do: 4 + def justification_bits_length(), do: 4 @spec endianness() :: atom() - def endianness, do: :little + def endianness(), do: :little @spec participation_flag_weights() :: list(non_neg_integer()) - def participation_flag_weights, + def participation_flag_weights(), do: [timely_source_weight(), timely_target_weight(), timely_head_weight()] @spec target_aggregators_per_committee() :: non_neg_integer() - def target_aggregators_per_committee, do: 16 + def target_aggregators_per_committee(), do: 16 ### Withdrawal prefixes @spec bls_withdrawal_prefix() :: Types.bytes1() - def bls_withdrawal_prefix, do: <<0>> + def bls_withdrawal_prefix(), do: <<0>> @spec eth1_address_withdrawal_prefix() :: Types.bytes1() - def eth1_address_withdrawal_prefix, do: <<1>> + def eth1_address_withdrawal_prefix(), do: <<1>> ### Domain types @spec domain_beacon_proposer() :: Types.domain_type() - def domain_beacon_proposer, do: <<0, 0, 0, 0>> + def domain_beacon_proposer(), do: <<0, 0, 0, 0>> @spec domain_beacon_attester() :: Types.domain_type() - def domain_beacon_attester, do: <<1, 0, 0, 0>> + def domain_beacon_attester(), do: <<1, 0, 0, 0>> @spec domain_randao() :: Types.domain_type() - def domain_randao, do: <<2, 0, 0, 0>> + def domain_randao(), do: <<2, 0, 0, 0>> @spec domain_deposit() :: Types.domain_type() - def domain_deposit, do: <<3, 0, 0, 0>> + def domain_deposit(), do: <<3, 0, 0, 0>> @spec domain_voluntary_exit() :: Types.domain_type() - def domain_voluntary_exit, do: <<4, 0, 0, 0>> + def domain_voluntary_exit(), do: <<4, 0, 0, 0>> @spec domain_selection_proof() :: Types.domain_type() - def domain_selection_proof, do: <<5, 0, 0, 0>> + def domain_selection_proof(), do: <<5, 0, 0, 0>> @spec domain_aggregate_and_proof() :: Types.domain_type() - def domain_aggregate_and_proof, do: <<6, 0, 0, 0>> + def domain_aggregate_and_proof(), do: <<6, 0, 0, 0>> @spec domain_application_mask() :: Types.domain_type() - def domain_application_mask, do: <<0, 0, 0, 1>> + def domain_application_mask(), do: <<0, 0, 0, 1>> @spec domain_sync_committee() :: Types.domain_type() - def domain_sync_committee, do: <<7, 0, 0, 0>> + def domain_sync_committee(), do: <<7, 0, 0, 0>> @spec domain_sync_committee_selection_proof() :: Types.domain_type() - def domain_sync_committee_selection_proof, do: <<8, 0, 0, 0>> + def domain_sync_committee_selection_proof(), do: <<8, 0, 0, 0>> @spec domain_contribution_and_proof() :: Types.domain_type() - def domain_contribution_and_proof, do: <<9, 0, 0, 0>> + def domain_contribution_and_proof(), do: <<9, 0, 0, 0>> @spec domain_bls_to_execution_change() :: Types.domain_type() - def domain_bls_to_execution_change, do: <<10, 0, 0, 0>> + def domain_bls_to_execution_change(), do: <<10, 0, 0, 0>> ### Participation flag indices @spec timely_source_flag_index() :: non_neg_integer() - def timely_source_flag_index, do: 0 + def timely_source_flag_index(), do: 0 @spec timely_target_flag_index() :: non_neg_integer() - def timely_target_flag_index, do: 1 + def timely_target_flag_index(), do: 1 @spec timely_head_flag_index() :: non_neg_integer() - def timely_head_flag_index, do: 2 + def timely_head_flag_index(), do: 2 ### Incentivization weights @spec timely_source_weight() :: non_neg_integer() - def timely_source_weight, do: 14 + def timely_source_weight(), do: 14 @spec timely_target_weight() :: non_neg_integer() - def timely_target_weight, do: 26 + def timely_target_weight(), do: 26 @spec timely_head_weight() :: non_neg_integer() - def timely_head_weight, do: 14 + def timely_head_weight(), do: 14 @spec sync_reward_weight() :: non_neg_integer() - def sync_reward_weight, do: 2 + def sync_reward_weight(), do: 2 @spec proposer_weight() :: non_neg_integer() - def proposer_weight, do: 8 + def proposer_weight(), do: 8 @spec weight_denominator() :: non_neg_integer() - def weight_denominator, do: 64 + def weight_denominator(), do: 64 ## Fork choice @spec intervals_per_slot() :: non_neg_integer() - def intervals_per_slot, do: 3 + def intervals_per_slot(), do: 3 @spec proposer_score_boost() :: non_neg_integer() - def proposer_score_boost, do: 3 + def proposer_score_boost(), do: 3 @spec sync_committee_subnet_count() :: non_neg_integer() - def sync_committee_subnet_count, do: 4 + def sync_committee_subnet_count(), do: 4 @spec bytes_per_field_element() :: Types.uint64() - def bytes_per_field_element, do: 32 + def bytes_per_field_element(), do: 32 @spec versioned_hash_version_kzg() :: <<_::8>> - def versioned_hash_version_kzg, do: <<1>> + def versioned_hash_version_kzg(), do: <<1>> end diff --git a/lib/lambda_ethereum_consensus/application.ex b/lib/lambda_ethereum_consensus/application.ex index 7635f1c2f..3d11c1995 100644 --- a/lib/lambda_ethereum_consensus/application.ex +++ b/lib/lambda_ethereum_consensus/application.ex @@ -50,7 +50,7 @@ defmodule LambdaEthereumConsensus.Application do ] end - defp get_operation_mode do + defp get_operation_mode() do Application.fetch_env!(:lambda_ethereum_consensus, LambdaEthereumConsensus) |> Keyword.fetch!(:mode) end diff --git a/lib/lambda_ethereum_consensus/beacon/beacon_chain.ex b/lib/lambda_ethereum_consensus/beacon/beacon_chain.ex index fc3329be5..51a413ac8 100644 --- a/lib/lambda_ethereum_consensus/beacon/beacon_chain.ex +++ b/lib/lambda_ethereum_consensus/beacon/beacon_chain.ex @@ -44,10 +44,10 @@ defmodule LambdaEthereumConsensus.Beacon.BeaconChain do end @spec get_current_slot() :: Types.slot() - def get_current_slot, do: GenServer.call(__MODULE__, :get_current_slot) + def get_current_slot(), do: GenServer.call(__MODULE__, :get_current_slot) @spec get_genesis_time() :: Types.uint64() - def get_genesis_time, do: GenServer.call(__MODULE__, :get_genesis_time) + def get_genesis_time(), do: GenServer.call(__MODULE__, :get_genesis_time) @spec update_fork_choice_cache(Types.root(), Types.slot(), Checkpoint.t(), Checkpoint.t()) :: :ok @@ -59,24 +59,24 @@ defmodule LambdaEthereumConsensus.Beacon.BeaconChain do end @spec get_finalized_checkpoint() :: Types.Checkpoint.t() - def get_finalized_checkpoint do + def get_finalized_checkpoint() do %{finalized: finalized} = GenServer.call(__MODULE__, :get_fork_choice_cache) finalized end @spec get_justified_checkpoint() :: Types.Checkpoint.t() - def get_justified_checkpoint do + def get_justified_checkpoint() do %{justified: justified} = GenServer.call(__MODULE__, :get_fork_choice_cache) justified end @spec get_current_epoch() :: integer() - def get_current_epoch do + def get_current_epoch() do Misc.compute_epoch_at_slot(get_current_slot()) end @spec get_fork_digest() :: Types.fork_digest() - def get_fork_digest do + def get_fork_digest() do GenServer.call(__MODULE__, :get_fork_digest) end @@ -86,10 +86,10 @@ defmodule LambdaEthereumConsensus.Beacon.BeaconChain do end @spec get_fork_version() :: Types.version() - def get_fork_version, do: GenServer.call(__MODULE__, :get_fork_version) + def get_fork_version(), do: GenServer.call(__MODULE__, :get_fork_version) @spec get_current_status_message() :: {:ok, Types.StatusMessage.t()} | {:error, any} - def get_current_status_message, do: GenServer.call(__MODULE__, :get_current_status_message) + def get_current_status_message(), do: GenServer.call(__MODULE__, :get_current_status_message) ########################## ### GenServer Callbacks @@ -202,7 +202,7 @@ defmodule LambdaEthereumConsensus.Beacon.BeaconChain do end end - def schedule_next_tick do + def schedule_next_tick() do # For millisecond precision time_to_next_tick = 1000 - rem(:os.system_time(:millisecond), 1000) Process.send_after(__MODULE__, :on_tick, time_to_next_tick) diff --git a/lib/lambda_ethereum_consensus/beacon/pending_blocks.ex b/lib/lambda_ethereum_consensus/beacon/pending_blocks.ex index c0fb52ece..78d0abad7 100644 --- a/lib/lambda_ethereum_consensus/beacon/pending_blocks.ex +++ b/lib/lambda_ethereum_consensus/beacon/pending_blocks.ex @@ -215,15 +215,15 @@ defmodule LambdaEthereumConsensus.Beacon.PendingBlocks do end end - def schedule_blocks_processing do + def schedule_blocks_processing() do Process.send_after(__MODULE__, :process_blocks, 500) end - def schedule_blobs_download do + def schedule_blobs_download() do Process.send_after(__MODULE__, :download_blobs, 500) end - def schedule_blocks_download do + def schedule_blocks_download() do Process.send_after(__MODULE__, :download_blocks, 1000) end end diff --git a/lib/lambda_ethereum_consensus/beacon/store_setup.ex b/lib/lambda_ethereum_consensus/beacon/store_setup.ex index b1efa3461..9d8411c94 100644 --- a/lib/lambda_ethereum_consensus/beacon/store_setup.ex +++ b/lib/lambda_ethereum_consensus/beacon/store_setup.ex @@ -40,7 +40,7 @@ defmodule LambdaEthereumConsensus.Beacon.StoreSetup do Gets a {store, genesis_validators_root} tuple with the configured strategy. """ @spec setup!() :: {Store.t(), binary} - def setup!, do: setup!(get_strategy!()) + def setup!(), do: setup!(get_strategy!()) @spec setup!(store_setup_strategy()) :: {Store.t(), binary} def setup!({:file, anchor_state}) do @@ -83,7 +83,7 @@ defmodule LambdaEthereumConsensus.Beacon.StoreSetup do Gets the deposit tree snapshot. Will return nil unless the strategy is checkpoint sync. """ @spec get_deposit_snapshot!() :: DepositTreeSnapshot.t() | nil - def get_deposit_snapshot!, do: get_deposit_snapshot!(get_strategy!()) + def get_deposit_snapshot!(), do: get_deposit_snapshot!(get_strategy!()) @spec get_deposit_snapshot!(store_setup_strategy()) :: DepositTreeSnapshot.t() | nil def get_deposit_snapshot!({:file, _}), do: nil @@ -91,12 +91,12 @@ defmodule LambdaEthereumConsensus.Beacon.StoreSetup do def get_deposit_snapshot!(:db), do: nil @spec get_strategy!() :: store_setup_strategy - defp get_strategy! do + defp get_strategy!() do Application.get_env(:lambda_ethereum_consensus, __MODULE__) |> Keyword.fetch!(:strategy) end - defp restore_state_from_db do + defp restore_state_from_db() do # Try to fetch the old store from the database case StoreDb.fetch_store() do {:ok, %Store{finalized_checkpoint: %{epoch: finalized_epoch}} = store} -> diff --git a/lib/lambda_ethereum_consensus/execution/auth.ex b/lib/lambda_ethereum_consensus/execution/auth.ex index 9d88c30b3..73ff88e75 100644 --- a/lib/lambda_ethereum_consensus/execution/auth.ex +++ b/lib/lambda_ethereum_consensus/execution/auth.ex @@ -5,7 +5,7 @@ defmodule LambdaEthereumConsensus.Execution.Auth do use Joken.Config # Set default expiry to 60s - def token_config, do: default_claims(default_exp: 60) + def token_config(), do: default_claims(default_exp: 60) # JWT Authentication is necessary for the EL <> CL communication through Engine API # Following the specs here: https://github.com/ethereum/execution-apis/blob/main/src/engine/authentication.md diff --git a/lib/lambda_ethereum_consensus/execution/engine_api.ex b/lib/lambda_ethereum_consensus/execution/engine_api.ex index b26c19a64..85214a8aa 100644 --- a/lib/lambda_ethereum_consensus/execution/engine_api.ex +++ b/lib/lambda_ethereum_consensus/execution/engine_api.ex @@ -4,7 +4,7 @@ defmodule LambdaEthereumConsensus.Execution.EngineApi do """ @behaviour LambdaEthereumConsensus.Execution.EngineApi.Behaviour - def exchange_capabilities, do: impl().exchange_capabilities() + def exchange_capabilities(), do: impl().exchange_capabilities() def new_payload(execution_payload, versioned_hashes, parent_beacon_block_root), do: impl().new_payload(execution_payload, versioned_hashes, parent_beacon_block_root) @@ -18,5 +18,5 @@ defmodule LambdaEthereumConsensus.Execution.EngineApi do def get_deposit_logs(block_number_range), do: impl().get_deposit_logs(block_number_range) - defp impl, do: Application.fetch_env!(:lambda_ethereum_consensus, __MODULE__)[:implementation] + defp impl(), do: Application.fetch_env!(:lambda_ethereum_consensus, __MODULE__)[:implementation] end diff --git a/lib/lambda_ethereum_consensus/execution/engine_api/api.ex b/lib/lambda_ethereum_consensus/execution/engine_api/api.ex index 275cc67e7..4b57c654d 100644 --- a/lib/lambda_ethereum_consensus/execution/engine_api/api.ex +++ b/lib/lambda_ethereum_consensus/execution/engine_api/api.ex @@ -14,7 +14,7 @@ defmodule LambdaEthereumConsensus.Execution.EngineApi.Api do Using this method Execution and consensus layer client software may exchange with a list of supported Engine API methods. """ - def exchange_capabilities do + def exchange_capabilities() do call("engine_exchangeCapabilities", [@supported_methods]) end diff --git a/lib/lambda_ethereum_consensus/execution/engine_api/mocked.ex b/lib/lambda_ethereum_consensus/execution/engine_api/mocked.ex index 06e4f39e2..c689fc17e 100644 --- a/lib/lambda_ethereum_consensus/execution/engine_api/mocked.ex +++ b/lib/lambda_ethereum_consensus/execution/engine_api/mocked.ex @@ -8,7 +8,7 @@ defmodule LambdaEthereumConsensus.Execution.EngineApi.Mocked do Using this method Execution and consensus layer client software may exchange with a list of supported Engine API methods. """ - def exchange_capabilities do + def exchange_capabilities() do {:ok, ["engine_newPayloadV2", "engine_newPayloadV3"]} end diff --git a/lib/lambda_ethereum_consensus/execution/execution_chain.ex b/lib/lambda_ethereum_consensus/execution/execution_chain.ex index 35283ac56..02c1a6d39 100644 --- a/lib/lambda_ethereum_consensus/execution/execution_chain.ex +++ b/lib/lambda_ethereum_consensus/execution/execution_chain.ex @@ -251,6 +251,6 @@ defmodule LambdaEthereumConsensus.Execution.ExecutionChain do defp compute_period(slot), do: slot |> div(slots_per_eth1_voting_period()) - defp slots_per_eth1_voting_period, + defp slots_per_eth1_voting_period(), do: ChainSpec.get("EPOCHS_PER_ETH1_VOTING_PERIOD") * ChainSpec.get("SLOTS_PER_EPOCH") end diff --git a/lib/lambda_ethereum_consensus/fork_choice/old_tree.ex b/lib/lambda_ethereum_consensus/fork_choice/old_tree.ex index b31ecd38a..2a065b386 100644 --- a/lib/lambda_ethereum_consensus/fork_choice/old_tree.ex +++ b/lib/lambda_ethereum_consensus/fork_choice/old_tree.ex @@ -60,7 +60,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Tree do so this operation is O(1). """ @spec get_head() :: Node.t() - def get_head, do: GenServer.call(__MODULE__, :get_head) + def get_head(), do: GenServer.call(__MODULE__, :get_head) ########################## ### GenServer Callbacks diff --git a/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex b/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex index e2975d25b..7b5a355aa 100644 --- a/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex +++ b/lib/lambda_ethereum_consensus/hard_fork_alias_injection.ex @@ -3,7 +3,7 @@ defmodule HardForkAliasInjection do is_deneb = Application.compile_env!(:lambda_ethereum_consensus, :fork) == :deneb @compile {:inline, deneb?: 0} - def deneb?, do: unquote(is_deneb) + def deneb?(), do: unquote(is_deneb) @doc """ Compiles to the first argument if on deneb, otherwise to the second argument. diff --git a/lib/lambda_ethereum_consensus/p2p/blob_downloader.ex b/lib/lambda_ethereum_consensus/p2p/blob_downloader.ex index 62d55adb0..86d8a610e 100644 --- a/lib/lambda_ethereum_consensus/p2p/blob_downloader.ex +++ b/lib/lambda_ethereum_consensus/p2p/blob_downloader.ex @@ -90,7 +90,7 @@ defmodule LambdaEthereumConsensus.P2P.BlobDownloader do end end - defp get_some_peer do + defp get_some_peer() do case P2P.Peerbook.get_some_peer() do nil -> Process.sleep(100) diff --git a/lib/lambda_ethereum_consensus/p2p/block_downloader.ex b/lib/lambda_ethereum_consensus/p2p/block_downloader.ex index e23b22163..fcb044e64 100644 --- a/lib/lambda_ethereum_consensus/p2p/block_downloader.ex +++ b/lib/lambda_ethereum_consensus/p2p/block_downloader.ex @@ -100,7 +100,7 @@ defmodule LambdaEthereumConsensus.P2P.BlockDownloader do end end - defp get_some_peer do + defp get_some_peer() do case P2P.Peerbook.get_some_peer() do nil -> Process.sleep(100) diff --git a/lib/lambda_ethereum_consensus/p2p/gossip/attestation.ex b/lib/lambda_ethereum_consensus/p2p/gossip/attestation.ex index b8366567a..ce7d0393f 100644 --- a/lib/lambda_ethereum_consensus/p2p/gossip/attestation.ex +++ b/lib/lambda_ethereum_consensus/p2p/gossip/attestation.ex @@ -69,13 +69,13 @@ defmodule LambdaEthereumConsensus.P2P.Gossip.Attestation do "/eth2/#{fork_context}/beacon_attestation_#{subnet_id}/ssz_snappy" end - defp update_enr do + defp update_enr() do enr_fork_id = compute_enr_fork_id() %{attnets: attnets, syncnets: syncnets} = P2P.Metadata.get_metadata() Libp2pPort.update_enr(enr_fork_id, attnets, syncnets) end - defp compute_enr_fork_id do + defp compute_enr_fork_id() do current_version = BeaconChain.get_fork_version() fork_digest = diff --git a/lib/lambda_ethereum_consensus/p2p/metadata.ex b/lib/lambda_ethereum_consensus/p2p/metadata.ex index dfb181187..d50464262 100644 --- a/lib/lambda_ethereum_consensus/p2p/metadata.ex +++ b/lib/lambda_ethereum_consensus/p2p/metadata.ex @@ -17,12 +17,12 @@ defmodule LambdaEthereumConsensus.P2P.Metadata do end @spec get_seq_number() :: Types.uint64() - def get_seq_number do + def get_seq_number() do GenServer.call(__MODULE__, :get_seq_number) end @spec get_metadata() :: Metadata.t() - def get_metadata do + def get_metadata() do GenServer.call(__MODULE__, :get_metadata) end diff --git a/lib/lambda_ethereum_consensus/p2p/peerbook.ex b/lib/lambda_ethereum_consensus/p2p/peerbook.ex index 54090017b..2b88809b6 100644 --- a/lib/lambda_ethereum_consensus/p2p/peerbook.ex +++ b/lib/lambda_ethereum_consensus/p2p/peerbook.ex @@ -20,7 +20,7 @@ defmodule LambdaEthereumConsensus.P2P.Peerbook do @doc """ Get some peer from the peerbook. """ - def get_some_peer do + def get_some_peer() do GenServer.call(__MODULE__, :get_some_peer) end diff --git a/lib/lambda_ethereum_consensus/state_transition/cache.ex b/lib/lambda_ethereum_consensus/state_transition/cache.ex index e6d52f327..75d3fa280 100644 --- a/lib/lambda_ethereum_consensus/state_transition/cache.ex +++ b/lib/lambda_ethereum_consensus/state_transition/cache.ex @@ -44,10 +44,10 @@ defmodule LambdaEthereumConsensus.StateTransition.Cache do defp generate_cleanup_spec(:active_validator_indices, key), do: cleanup_epoch_ms(key) @spec initialize_cache() :: :ok - def initialize_cache, do: @tables |> Enum.each(&init_table/1) + def initialize_cache(), do: @tables |> Enum.each(&init_table/1) @spec clear_cache() :: :ok - def clear_cache, do: @tables |> Enum.each(&:ets.delete_all_objects/1) + def clear_cache(), do: @tables |> Enum.each(&:ets.delete_all_objects/1) @spec init_table(:ets.table()) :: :ok def init_table(table) do diff --git a/lib/lambda_ethereum_consensus/store/block_db.ex b/lib/lambda_ethereum_consensus/store/block_db.ex index b084c66aa..ece13b4dc 100644 --- a/lib/lambda_ethereum_consensus/store/block_db.ex +++ b/lib/lambda_ethereum_consensus/store/block_db.ex @@ -58,7 +58,7 @@ defmodule LambdaEthereumConsensus.Store.BlockDb do end end - def stream_missing_blocks_desc do + def stream_missing_blocks_desc() do Stream.resource( fn -> 0xFFFFFFFFFFFFFFFF |> block_root_by_slot_key() |> init_keycursor() end, &next_slot(&1, :prev), @@ -119,7 +119,7 @@ defmodule LambdaEthereumConsensus.Store.BlockDb do defp block_key(root), do: Utils.get_key(@block_prefix, root) defp block_root_by_slot_key(slot), do: Utils.get_key(@blockslot_prefix, slot) - def stream_blocks do + def stream_blocks() do Stream.resource( fn -> <<0::256>> |> block_key() |> init_cursor() end, &next_block/1, diff --git a/lib/lambda_ethereum_consensus/store/db.ex b/lib/lambda_ethereum_consensus/store/db.ex index 086b8cc87..a56f227e1 100644 --- a/lib/lambda_ethereum_consensus/store/db.ex +++ b/lib/lambda_ethereum_consensus/store/db.ex @@ -25,14 +25,14 @@ defmodule LambdaEthereumConsensus.Store.Db do end @spec iterate() :: {:ok, :eleveldb.itr_ref()} | {:error, any()} - def iterate do + def iterate() do ref = GenServer.call(@registered_name, :get_ref) # TODO: wrap cursor to make it DB-agnostic Exleveldb.iterator(ref, []) end @spec iterate_keys() :: {:ok, :eleveldb.itr_ref()} | {:error, any()} - def iterate_keys do + def iterate_keys() do ref = GenServer.call(@registered_name, :get_ref) # TODO: wrap cursor to make it DB-agnostic Exleveldb.iterator(ref, [], :keys_only) @@ -57,7 +57,7 @@ defmodule LambdaEthereumConsensus.Store.Db do @impl true def handle_call(:get_ref, _from, %{ref: ref} = state), do: {:reply, ref, state} - defp get_dir do + defp get_dir() do Application.fetch_env!(:lambda_ethereum_consensus, __MODULE__) |> Keyword.fetch!(:dir) end diff --git a/lib/lambda_ethereum_consensus/store/state_db.ex b/lib/lambda_ethereum_consensus/store/state_db.ex index afbaec151..af43e865d 100644 --- a/lib/lambda_ethereum_consensus/store/state_db.ex +++ b/lib/lambda_ethereum_consensus/store/state_db.ex @@ -52,7 +52,7 @@ defmodule LambdaEthereumConsensus.Store.StateDb do @spec get_latest_state() :: {:ok, BeaconState.t()} | {:error, String.t()} | :not_found - def get_latest_state do + def get_latest_state() do last_key = root_by_slot_key(0xFFFFFFFFFFFFFFFF) with {:ok, it} <- Db.iterate(), diff --git a/lib/lambda_ethereum_consensus/store/store_db.ex b/lib/lambda_ethereum_consensus/store/store_db.ex index 21af64f78..be10e1ade 100644 --- a/lib/lambda_ethereum_consensus/store/store_db.ex +++ b/lib/lambda_ethereum_consensus/store/store_db.ex @@ -7,7 +7,7 @@ defmodule LambdaEthereumConsensus.Store.StoreDb do @store_prefix "store" @spec fetch_store() :: {:ok, Types.Store.t()} | :not_found - def fetch_store do + def fetch_store() do with {:ok, encoded_store} <- Db.get(@store_prefix) do {:ok, :erlang.binary_to_term(encoded_store)} end diff --git a/lib/lambda_ethereum_consensus/telemetry.ex b/lib/lambda_ethereum_consensus/telemetry.ex index e1cb5111c..24509f66f 100644 --- a/lib/lambda_ethereum_consensus/telemetry.ex +++ b/lib/lambda_ethereum_consensus/telemetry.ex @@ -122,7 +122,7 @@ defmodule LambdaEthereumConsensus.Telemetry do ] end - defp periodic_measurements do + defp periodic_measurements() do [ # A module, function and arguments to be invoked periodically. # This function must call :telemetry.execute/3 and a metric must be added above. @@ -131,7 +131,7 @@ defmodule LambdaEthereumConsensus.Telemetry do ] end - def uptime do + def uptime() do {uptime, _} = :erlang.statistics(:wall_clock) :telemetry.execute([:vm, :uptime], %{total: uptime}) end @@ -140,7 +140,7 @@ defmodule LambdaEthereumConsensus.Telemetry do :telemetry.execute([:vm, :message_queue], %{length: len}, %{process: inspect(name)}) end - def message_queue_lengths do + def message_queue_lengths() do Process.list() |> Enum.each(fn pid -> case Process.info(pid, [:message_queue_len, :registered_name]) do diff --git a/lib/lambda_ethereum_consensus/validator/block_builder.ex b/lib/lambda_ethereum_consensus/validator/block_builder.ex index 89af5b415..2fcbd5cda 100644 --- a/lib/lambda_ethereum_consensus/validator/block_builder.ex +++ b/lib/lambda_ethereum_consensus/validator/block_builder.ex @@ -146,7 +146,7 @@ defmodule LambdaEthereumConsensus.Validator.BlockBuilder do voluntary_exits: [Types.VoluntaryExit.t()], bls_to_execution_changes: [Types.SignedBLSToExecutionChange.t()] } - defp fetch_operations_for_block do + defp fetch_operations_for_block() do %{ proposer_slashings: ChainSpec.get("MAX_PROPOSER_SLASHINGS") |> OperationsCollector.get_proposer_slashings(), @@ -194,7 +194,7 @@ defmodule LambdaEthereumConsensus.Validator.BlockBuilder do signature end - defp get_sync_aggregate do + defp get_sync_aggregate() do %Types.SyncAggregate{ sync_committee_bits: ChainSpec.get("SYNC_COMMITTEE_SIZE") |> BitVector.new(), sync_committee_signature: <<192, 0::760>> diff --git a/lib/lambda_ethereum_consensus/validator/validator.ex b/lib/lambda_ethereum_consensus/validator/validator.ex index ac87a9ad1..1944b016a 100644 --- a/lib/lambda_ethereum_consensus/validator/validator.ex +++ b/lib/lambda_ethereum_consensus/validator/validator.ex @@ -113,7 +113,7 @@ defmodule LambdaEthereumConsensus.Validator do ### Private Functions ########################## - defp empty_duties do + defp empty_duties() do %{ # Order is: previous epoch, current epoch, next epoch attester: [:not_computed, :not_computed, :not_computed], diff --git a/lib/libp2p/libp2p.ex b/lib/libp2p/libp2p.ex index 6c02e5cb7..e23bf2e7f 100644 --- a/lib/libp2p/libp2p.ex +++ b/lib/libp2p/libp2p.ex @@ -5,7 +5,7 @@ defmodule Libp2p do @on_load :load_nifs - def load_nifs do + def load_nifs() do dir = :code.priv_dir(:lambda_ethereum_consensus) :erlang.load_nif(dir ++ ~c"/native/libp2p_nif", 0) end @@ -89,7 +89,7 @@ defmodule Libp2p do The ttl for a "permanent address" (e.g. bootstrap nodes). """ @spec ttl_permanent_addr :: integer - def ttl_permanent_addr, do: 2 ** 63 - 1 + def ttl_permanent_addr(), do: 2 ** 63 - 1 @doc """ Gets next subscription message. diff --git a/lib/libp2p_port.ex b/lib/libp2p_port.ex index 5a9e96b38..05e299d35 100644 --- a/lib/libp2p_port.ex +++ b/lib/libp2p_port.ex @@ -130,7 +130,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do on the current process. If there are no requests, it waits for one. """ @spec handle_request() :: {String.t(), String.t(), binary()} - def handle_request do + def handle_request() do receive do {:request, {_protocol_id, _message_id, _message} = request} -> request end @@ -189,7 +189,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do on the current process. If there are none, it waits for one. """ @spec receive_gossip() :: {String.t(), binary(), binary()} - def receive_gossip do + def receive_gossip() do receive do {:gossipsub, {_topic_name, _msg_id, _message} = m} -> m end @@ -427,7 +427,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do receive_response() end - defp receive_response do + defp receive_response() do receive do {:response, {res, %ResultMessage{message: []}}} -> res {:response, {res, %ResultMessage{message: message}}} -> [res | message] |> List.to_tuple() diff --git a/lib/ssz.ex b/lib/ssz.ex index 144c62336..c94b5b858 100644 --- a/lib/ssz.ex +++ b/lib/ssz.ex @@ -123,7 +123,7 @@ defmodule Ssz do do: error() ##### Utils - defp error, do: :erlang.nif_error(:nif_not_loaded) + defp error(), do: :erlang.nif_error(:nif_not_loaded) # Ssz types can have special decoding rules defined in their optional encode/1 function, defp encode(%name{} = struct) do diff --git a/lib/ssz_ex/hash.ex b/lib/ssz_ex/hash.ex index e8a9f81fc..fcb5b33c4 100644 --- a/lib/ssz_ex/hash.ex +++ b/lib/ssz_ex/hash.ex @@ -10,7 +10,7 @@ defmodule SszEx.Hash do @doc """ Compute the roots of Merkle trees with all zero leaves and lengths from 0 to 64. """ - def compute_zero_hashes do + def compute_zero_hashes() do Stream.iterate(<<0::size(8 * @bytes_per_chunk)>>, &hash_nodes(&1, &1)) |> Stream.take(@max_merkle_tree_depth + 1) |> Enum.join() diff --git a/lib/types/beacon_chain/attestation.ex b/lib/types/beacon_chain/attestation.ex index 5770a3479..9f9ce26e3 100644 --- a/lib/types/beacon_chain/attestation.ex +++ b/lib/types/beacon_chain/attestation.ex @@ -24,7 +24,7 @@ defmodule Types.Attestation do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:aggregation_bits, {:bitlist, ChainSpec.get("MAX_VALIDATORS_PER_COMMITTEE")}}, {:data, Types.AttestationData}, diff --git a/lib/types/beacon_chain/attestation_data.ex b/lib/types/beacon_chain/attestation_data.ex index a02155df3..d557af65b 100644 --- a/lib/types/beacon_chain/attestation_data.ex +++ b/lib/types/beacon_chain/attestation_data.ex @@ -26,7 +26,7 @@ defmodule Types.AttestationData do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:slot, TypeAliases.slot()}, {:index, TypeAliases.commitee_index()}, diff --git a/lib/types/beacon_chain/attester_slashing.ex b/lib/types/beacon_chain/attester_slashing.ex index edb01457a..5a8d61bde 100644 --- a/lib/types/beacon_chain/attester_slashing.ex +++ b/lib/types/beacon_chain/attester_slashing.ex @@ -19,7 +19,7 @@ defmodule Types.AttesterSlashing do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:attestation_1, Types.IndexedAttestation}, {:attestation_2, Types.IndexedAttestation} diff --git a/lib/types/beacon_chain/beacon_block.ex b/lib/types/beacon_chain/beacon_block.ex index aafc0a70a..d92146e51 100644 --- a/lib/types/beacon_chain/beacon_block.ex +++ b/lib/types/beacon_chain/beacon_block.ex @@ -25,7 +25,7 @@ defmodule Types.BeaconBlock do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:slot, TypeAliases.slot()}, {:proposer_index, TypeAliases.validator_index()}, diff --git a/lib/types/beacon_chain/beacon_block_body.ex b/lib/types/beacon_chain/beacon_block_body.ex index 957fc0351..fa4456aca 100644 --- a/lib/types/beacon_chain/beacon_block_body.ex +++ b/lib/types/beacon_chain/beacon_block_body.ex @@ -46,7 +46,7 @@ defmodule Types.BeaconBlockBody do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ randao_reveal: TypeAliases.bls_signature(), eth1_data: Types.Eth1Data, diff --git a/lib/types/beacon_chain/beacon_block_header.ex b/lib/types/beacon_chain/beacon_block_header.ex index 65b1197f9..3813b100d 100644 --- a/lib/types/beacon_chain/beacon_block_header.ex +++ b/lib/types/beacon_chain/beacon_block_header.ex @@ -25,7 +25,7 @@ defmodule Types.BeaconBlockHeader do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:slot, TypeAliases.slot()}, {:proposer_index, TypeAliases.validator_index()}, diff --git a/lib/types/beacon_chain/beacon_state.ex b/lib/types/beacon_chain/beacon_state.ex index 6e4c7094e..c540b3f52 100644 --- a/lib/types/beacon_chain/beacon_state.ex +++ b/lib/types/beacon_chain/beacon_state.ex @@ -109,7 +109,7 @@ defmodule Types.BeaconState do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:genesis_time, TypeAliases.uint64()}, {:genesis_validators_root, TypeAliases.root()}, diff --git a/lib/types/beacon_chain/blob_identifier.ex b/lib/types/beacon_chain/blob_identifier.ex index 47fbea7cd..324162766 100644 --- a/lib/types/beacon_chain/blob_identifier.ex +++ b/lib/types/beacon_chain/blob_identifier.ex @@ -19,7 +19,7 @@ defmodule Types.BlobIdentifier do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:block_root, TypeAliases.root()}, {:index, TypeAliases.blob_index()} diff --git a/lib/types/beacon_chain/blob_sidecar.ex b/lib/types/beacon_chain/blob_sidecar.ex index 36dca2eca..69452271d 100644 --- a/lib/types/beacon_chain/blob_sidecar.ex +++ b/lib/types/beacon_chain/blob_sidecar.ex @@ -28,7 +28,7 @@ defmodule Types.BlobSidecar do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ index: TypeAliases.blob_index(), blob: TypeAliases.blob(), diff --git a/lib/types/beacon_chain/bls_to_execution_change.ex b/lib/types/beacon_chain/bls_to_execution_change.ex index aa2a4dcd1..621aaf7b6 100644 --- a/lib/types/beacon_chain/bls_to_execution_change.ex +++ b/lib/types/beacon_chain/bls_to_execution_change.ex @@ -21,7 +21,7 @@ defmodule Types.BLSToExecutionChange do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:validator_index, TypeAliases.validator_index()}, {:from_bls_pubkey, TypeAliases.bls_pubkey()}, diff --git a/lib/types/beacon_chain/checkpoint.ex b/lib/types/beacon_chain/checkpoint.ex index 9f11819f8..45fa13c4b 100644 --- a/lib/types/beacon_chain/checkpoint.ex +++ b/lib/types/beacon_chain/checkpoint.ex @@ -20,7 +20,7 @@ defmodule Types.Checkpoint do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:epoch, TypeAliases.epoch()}, {:root, TypeAliases.root()} diff --git a/lib/types/beacon_chain/deposit.ex b/lib/types/beacon_chain/deposit.ex index 8e53c7097..22808ac15 100644 --- a/lib/types/beacon_chain/deposit.ex +++ b/lib/types/beacon_chain/deposit.ex @@ -43,7 +43,7 @@ defmodule Types.Deposit do end @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:proof, {:vector, TypeAliases.bytes32(), 33}}, {:data, Types.DepositData} diff --git a/lib/types/beacon_chain/deposit_data.ex b/lib/types/beacon_chain/deposit_data.ex index 2b875f7b8..8f66b1771 100644 --- a/lib/types/beacon_chain/deposit_data.ex +++ b/lib/types/beacon_chain/deposit_data.ex @@ -24,7 +24,7 @@ defmodule Types.DepositData do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:pubkey, TypeAliases.bls_pubkey()}, {:withdrawal_credentials, TypeAliases.bytes32()}, diff --git a/lib/types/beacon_chain/deposit_message.ex b/lib/types/beacon_chain/deposit_message.ex index 641aea62d..3ec9b904d 100644 --- a/lib/types/beacon_chain/deposit_message.ex +++ b/lib/types/beacon_chain/deposit_message.ex @@ -21,7 +21,7 @@ defmodule Types.DepositMessage do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:pubkey, TypeAliases.bls_pubkey()}, {:withdrawal_credentials, TypeAliases.bytes32()}, diff --git a/lib/types/beacon_chain/eth1_block.ex b/lib/types/beacon_chain/eth1_block.ex index 07ff0431a..179ec784b 100644 --- a/lib/types/beacon_chain/eth1_block.ex +++ b/lib/types/beacon_chain/eth1_block.ex @@ -20,7 +20,7 @@ defmodule Types.Eth1Block do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ timestamp: TypeAliases.uint64(), deposit_root: TypeAliases.root(), diff --git a/lib/types/beacon_chain/eth1_data.ex b/lib/types/beacon_chain/eth1_data.ex index 271356c47..455d5d56a 100644 --- a/lib/types/beacon_chain/eth1_data.ex +++ b/lib/types/beacon_chain/eth1_data.ex @@ -21,7 +21,7 @@ defmodule Types.Eth1Data do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ deposit_root: TypeAliases.root(), deposit_count: TypeAliases.uint64(), diff --git a/lib/types/beacon_chain/execution_payload.ex b/lib/types/beacon_chain/execution_payload.ex index 4445f0382..5ebc89bb2 100644 --- a/lib/types/beacon_chain/execution_payload.ex +++ b/lib/types/beacon_chain/execution_payload.ex @@ -61,7 +61,7 @@ defmodule Types.ExecutionPayload do end @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:parent_hash, TypeAliases.hash32()}, {:fee_recipient, TypeAliases.execution_address()}, diff --git a/lib/types/beacon_chain/execution_payload_header.ex b/lib/types/beacon_chain/execution_payload_header.ex index c69d8c124..ece7cb139 100644 --- a/lib/types/beacon_chain/execution_payload_header.ex +++ b/lib/types/beacon_chain/execution_payload_header.ex @@ -78,10 +78,10 @@ defmodule Types.ExecutionPayloadHeader do Map.update!(map, :base_fee_per_gas, &Ssz.decode_u256/1) end - def default, do: @default_execution_payload_header + def default(), do: @default_execution_payload_header @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:parent_hash, TypeAliases.hash32()}, {:fee_recipient, TypeAliases.execution_address()}, diff --git a/lib/types/beacon_chain/fork.ex b/lib/types/beacon_chain/fork.ex index addb3b265..b95bd1ef8 100644 --- a/lib/types/beacon_chain/fork.ex +++ b/lib/types/beacon_chain/fork.ex @@ -22,7 +22,7 @@ defmodule Types.Fork do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:previous_version, TypeAliases.version()}, {:current_version, TypeAliases.version()}, diff --git a/lib/types/beacon_chain/fork_data.ex b/lib/types/beacon_chain/fork_data.ex index e6e710c6e..3c031e314 100644 --- a/lib/types/beacon_chain/fork_data.ex +++ b/lib/types/beacon_chain/fork_data.ex @@ -20,7 +20,7 @@ defmodule Types.ForkData do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:current_version, TypeAliases.version()}, {:genesis_validators_root, TypeAliases.root()} diff --git a/lib/types/beacon_chain/historical_batch.ex b/lib/types/beacon_chain/historical_batch.ex index 74ee471c2..e63575d76 100644 --- a/lib/types/beacon_chain/historical_batch.ex +++ b/lib/types/beacon_chain/historical_batch.ex @@ -20,7 +20,7 @@ defmodule Types.HistoricalBatch do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:block_roots, {:vector, TypeAliases.root(), ChainSpec.get("SLOTS_PER_HISTORICAL_ROOT")}}, {:state_roots, {:vector, TypeAliases.root(), ChainSpec.get("SLOTS_PER_HISTORICAL_ROOT")}} diff --git a/lib/types/beacon_chain/historical_summary.ex b/lib/types/beacon_chain/historical_summary.ex index 236d9ae7f..c72cb54e1 100644 --- a/lib/types/beacon_chain/historical_summary.ex +++ b/lib/types/beacon_chain/historical_summary.ex @@ -21,7 +21,7 @@ defmodule Types.HistoricalSummary do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:block_summary_root, TypeAliases.root()}, {:state_summary_root, TypeAliases.root()} diff --git a/lib/types/beacon_chain/indexed_attestation.ex b/lib/types/beacon_chain/indexed_attestation.ex index db0733eb3..ee94d7511 100644 --- a/lib/types/beacon_chain/indexed_attestation.ex +++ b/lib/types/beacon_chain/indexed_attestation.ex @@ -22,7 +22,7 @@ defmodule Types.IndexedAttestation do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:attesting_indices, {:list, TypeAliases.validator_index(), ChainSpec.get("MAX_VALIDATORS_PER_COMMITTEE")}}, diff --git a/lib/types/beacon_chain/pending_attestation.ex b/lib/types/beacon_chain/pending_attestation.ex index 1fbac0647..4cd84a6db 100644 --- a/lib/types/beacon_chain/pending_attestation.ex +++ b/lib/types/beacon_chain/pending_attestation.ex @@ -26,7 +26,7 @@ defmodule Types.PendingAttestation do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:aggregation_bits, {:bitlist, ChainSpec.get("MAX_VALIDATORS_PER_COMMITTEE")}}, {:data, Types.AttestationData}, diff --git a/lib/types/beacon_chain/proposer_slashing.ex b/lib/types/beacon_chain/proposer_slashing.ex index d213ed6a5..75ee58d32 100644 --- a/lib/types/beacon_chain/proposer_slashing.ex +++ b/lib/types/beacon_chain/proposer_slashing.ex @@ -19,7 +19,7 @@ defmodule Types.ProposerSlashing do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:signed_header_1, Types.SignedBeaconBlockHeader}, {:signed_header_2, Types.SignedBeaconBlockHeader} diff --git a/lib/types/beacon_chain/signed_beacon_block.ex b/lib/types/beacon_chain/signed_beacon_block.ex index b37791403..faff23df8 100644 --- a/lib/types/beacon_chain/signed_beacon_block.ex +++ b/lib/types/beacon_chain/signed_beacon_block.ex @@ -19,7 +19,7 @@ defmodule Types.SignedBeaconBlock do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.BeaconBlock}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/beacon_chain/signed_beacon_block_header.ex b/lib/types/beacon_chain/signed_beacon_block_header.ex index f4838915f..e82106228 100644 --- a/lib/types/beacon_chain/signed_beacon_block_header.ex +++ b/lib/types/beacon_chain/signed_beacon_block_header.ex @@ -19,7 +19,7 @@ defmodule Types.SignedBeaconBlockHeader do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.BeaconBlockHeader}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/beacon_chain/signed_bls_to_execution_change.ex b/lib/types/beacon_chain/signed_bls_to_execution_change.ex index 554612ee3..dcca27b80 100644 --- a/lib/types/beacon_chain/signed_bls_to_execution_change.ex +++ b/lib/types/beacon_chain/signed_bls_to_execution_change.ex @@ -19,7 +19,7 @@ defmodule Types.SignedBLSToExecutionChange do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.BLSToExecutionChange}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/beacon_chain/signed_voluntary_exit.ex b/lib/types/beacon_chain/signed_voluntary_exit.ex index 5e88bf37f..32cc0aa71 100644 --- a/lib/types/beacon_chain/signed_voluntary_exit.ex +++ b/lib/types/beacon_chain/signed_voluntary_exit.ex @@ -19,7 +19,7 @@ defmodule Types.SignedVoluntaryExit do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.VoluntaryExit}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/beacon_chain/signing_data.ex b/lib/types/beacon_chain/signing_data.ex index 06b153b56..094d14001 100644 --- a/lib/types/beacon_chain/signing_data.ex +++ b/lib/types/beacon_chain/signing_data.ex @@ -19,7 +19,7 @@ defmodule Types.SigningData do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:object_root, TypeAliases.root()}, {:domain, TypeAliases.domain()} diff --git a/lib/types/beacon_chain/sync_aggregate.ex b/lib/types/beacon_chain/sync_aggregate.ex index d7d94f463..d572e2aa5 100644 --- a/lib/types/beacon_chain/sync_aggregate.ex +++ b/lib/types/beacon_chain/sync_aggregate.ex @@ -31,7 +31,7 @@ defmodule Types.SyncAggregate do end @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:sync_committee_bits, {:bitvector, ChainSpec.get("SYNC_COMMITTEE_SIZE")}}, {:sync_committee_signature, TypeAliases.bls_signature()} diff --git a/lib/types/beacon_chain/sync_aggregator_selection_data.ex b/lib/types/beacon_chain/sync_aggregator_selection_data.ex index 54ca61c1f..c9642e455 100644 --- a/lib/types/beacon_chain/sync_aggregator_selection_data.ex +++ b/lib/types/beacon_chain/sync_aggregator_selection_data.ex @@ -15,7 +15,7 @@ defmodule Types.SyncAggregatorSelectionData do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ slot: TypeAliases.slot(), subcommittee_index: TypeAliases.uint64() diff --git a/lib/types/beacon_chain/sync_committee.ex b/lib/types/beacon_chain/sync_committee.ex index bbdfb0e3c..1c6ffc4eb 100644 --- a/lib/types/beacon_chain/sync_committee.ex +++ b/lib/types/beacon_chain/sync_committee.ex @@ -21,7 +21,7 @@ defmodule Types.SyncCommittee do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:pubkeys, {:vector, TypeAliases.bls_pubkey(), ChainSpec.get("SYNC_COMMITTEE_SIZE")}}, {:aggregate_pubkey, TypeAliases.bls_pubkey()} diff --git a/lib/types/beacon_chain/validator.ex b/lib/types/beacon_chain/validator.ex index 75f89e21b..96e536020 100644 --- a/lib/types/beacon_chain/validator.ex +++ b/lib/types/beacon_chain/validator.ex @@ -69,7 +69,7 @@ defmodule Types.Validator do end @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:pubkey, TypeAliases.bls_pubkey()}, {:withdrawal_credentials, TypeAliases.bytes32()}, diff --git a/lib/types/beacon_chain/voluntary_exit.ex b/lib/types/beacon_chain/voluntary_exit.ex index fe6c98f3c..5da73185d 100644 --- a/lib/types/beacon_chain/voluntary_exit.ex +++ b/lib/types/beacon_chain/voluntary_exit.ex @@ -19,7 +19,7 @@ defmodule Types.VoluntaryExit do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:epoch, TypeAliases.epoch()}, {:validator_index, TypeAliases.validator_index()} diff --git a/lib/types/beacon_chain/withdrawal.ex b/lib/types/beacon_chain/withdrawal.ex index ffe74c2a3..d20f3eda3 100644 --- a/lib/types/beacon_chain/withdrawal.ex +++ b/lib/types/beacon_chain/withdrawal.ex @@ -23,7 +23,7 @@ defmodule Types.Withdrawal do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:index, TypeAliases.withdrawal_index()}, {:validator_index, TypeAliases.validator_index()}, diff --git a/lib/types/blobdata.ex b/lib/types/blobdata.ex index f20e60a0c..61ea31372 100644 --- a/lib/types/blobdata.ex +++ b/lib/types/blobdata.ex @@ -13,7 +13,7 @@ defmodule Types.Blobdata do @type t :: %__MODULE__{blob: Types.blob(), proof: Types.kzg_proof()} @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ blob: TypeAliases.blob(), proof: TypeAliases.kzg_proof() diff --git a/lib/types/deposit_tree.ex b/lib/types/deposit_tree.ex index a25994be3..e321319d4 100644 --- a/lib/types/deposit_tree.ex +++ b/lib/types/deposit_tree.ex @@ -31,7 +31,7 @@ defmodule Types.DepositTree do ################ @spec new() :: t() - def new, do: %__MODULE__{} + def new(), do: %__MODULE__{} @spec from_snapshot(DepositTreeSnapshot.t()) :: t() def from_snapshot(%DepositTreeSnapshot{} = snapshot) do diff --git a/lib/types/p2p/beacon_blocks_by_range_request.ex b/lib/types/p2p/beacon_blocks_by_range_request.ex index b5eb5ea35..f70f79b8c 100644 --- a/lib/types/p2p/beacon_blocks_by_range_request.ex +++ b/lib/types/p2p/beacon_blocks_by_range_request.ex @@ -20,7 +20,7 @@ defmodule Types.BeaconBlocksByRangeRequest do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ start_slot: TypeAliases.slot(), count: TypeAliases.uint64(), diff --git a/lib/types/p2p/enr_fork_id.ex b/lib/types/p2p/enr_fork_id.ex index 006406524..cab217571 100644 --- a/lib/types/p2p/enr_fork_id.ex +++ b/lib/types/p2p/enr_fork_id.ex @@ -21,7 +21,7 @@ defmodule Types.EnrForkId do } @impl Container - def schema do + def schema() do [ fork_digest: TypeAliases.fork_digest(), next_fork_version: TypeAliases.version(), diff --git a/lib/types/p2p/metadata.ex b/lib/types/p2p/metadata.ex index 72c3a5176..7d42a0a36 100644 --- a/lib/types/p2p/metadata.ex +++ b/lib/types/p2p/metadata.ex @@ -20,14 +20,14 @@ defmodule Types.Metadata do syncnets: Types.bitvector() } - def schema, + def schema(), do: [ seq_number: TypeAliases.uint64(), attnets: {:bitvector, ChainSpec.get("ATTESTATION_SUBNET_COUNT")}, syncnets: {:bitvector, Constants.sync_committee_subnet_count()} ] - def empty do + def empty() do attnets = ChainSpec.get("ATTESTATION_SUBNET_COUNT") |> BitVector.new() syncnets = Constants.sync_committee_subnet_count() |> BitVector.new() %__MODULE__{seq_number: 0, attnets: attnets, syncnets: syncnets} diff --git a/lib/types/p2p/status_message.ex b/lib/types/p2p/status_message.ex index 71844fb3f..9a83b5538 100644 --- a/lib/types/p2p/status_message.ex +++ b/lib/types/p2p/status_message.ex @@ -25,7 +25,7 @@ defmodule Types.StatusMessage do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ fork_digest: TypeAliases.fork_digest(), finalized_root: TypeAliases.root(), diff --git a/lib/types/type_aliases.ex b/lib/types/type_aliases.ex index b79bb45c2..c051753a8 100644 --- a/lib/types/type_aliases.ex +++ b/lib/types/type_aliases.ex @@ -3,46 +3,46 @@ defmodule TypeAliases do Type aliases for ssz schemas """ - def root, do: {:byte_vector, 32} - def epoch, do: {:int, 64} - def bls_signature, do: {:byte_vector, 96} - def slot, do: {:int, 64} - def commitee_index, do: {:int, 64} - def validator_index, do: {:int, 64} - def gwei, do: {:int, 64} - def participation_flags, do: {:int, 8} - def withdrawal_index, do: {:int, 64} - def bls_pubkey, do: {:byte_vector, 48} - def execution_address, do: {:byte_vector, 20} - def version, do: {:byte_vector, 4} - def domain, do: {:byte_vector, 32} - def domain_type, do: {:byte_vector, 4} - def fork_digest, do: {:byte_vector, 4} - def blob_index, do: uint64() - - def blob, + def root(), do: {:byte_vector, 32} + def epoch(), do: {:int, 64} + def bls_signature(), do: {:byte_vector, 96} + def slot(), do: {:int, 64} + def commitee_index(), do: {:int, 64} + def validator_index(), do: {:int, 64} + def gwei(), do: {:int, 64} + def participation_flags(), do: {:int, 8} + def withdrawal_index(), do: {:int, 64} + def bls_pubkey(), do: {:byte_vector, 48} + def execution_address(), do: {:byte_vector, 20} + def version(), do: {:byte_vector, 4} + def domain(), do: {:byte_vector, 32} + def domain_type(), do: {:byte_vector, 4} + def fork_digest(), do: {:byte_vector, 4} + def blob_index(), do: uint64() + + def blob(), do: {:byte_vector, Constants.bytes_per_field_element() * ChainSpec.get("FIELD_ELEMENTS_PER_BLOB")} - def kzg_commitment, do: {:byte_vector, 48} - def kzg_proof, do: {:byte_vector, 48} + def kzg_commitment(), do: {:byte_vector, 48} + def kzg_proof(), do: {:byte_vector, 48} - def bytes32, do: {:byte_vector, 32} - def uint64, do: {:int, 64} - def hash32, do: {:byte_vector, 32} - def uint256, do: {:int, 256} + def bytes32(), do: {:byte_vector, 32} + def uint64(), do: {:int, 64} + def hash32(), do: {:byte_vector, 32} + def uint256(), do: {:int, 256} - def transactions do + def transactions() do transaction = {:byte_list, ChainSpec.get("MAX_BYTES_PER_TRANSACTION")} {:list, transaction, ChainSpec.get("MAX_TRANSACTIONS_PER_PAYLOAD")} end - def beacon_blocks_by_root_request, + def beacon_blocks_by_root_request(), do: {:list, TypeAliases.root(), ChainSpec.get("MAX_REQUEST_BLOCKS")} - def blob_sidecars_by_root_request, + def blob_sidecars_by_root_request(), do: {:list, Types.BlobIdentifier, ChainSpec.get("MAX_REQUEST_BLOB_SIDECARS")} - def error_message, do: {:byte_list, 256} + def error_message(), do: {:byte_list, 256} end diff --git a/lib/types/validator/aggregate_and_proof.ex b/lib/types/validator/aggregate_and_proof.ex index 7d7b5be33..226157688 100644 --- a/lib/types/validator/aggregate_and_proof.ex +++ b/lib/types/validator/aggregate_and_proof.ex @@ -21,7 +21,7 @@ defmodule Types.AggregateAndProof do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:aggregator_index, TypeAliases.validator_index()}, {:aggregate, Types.Attestation}, diff --git a/lib/types/validator/contribution_and_proof.ex b/lib/types/validator/contribution_and_proof.ex index db4d14b46..78c6da97d 100644 --- a/lib/types/validator/contribution_and_proof.ex +++ b/lib/types/validator/contribution_and_proof.ex @@ -21,7 +21,7 @@ defmodule Types.ContributionAndProof do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:aggregator_index, TypeAliases.validator_index()}, {:contribution, Types.SyncCommitteeContribution}, diff --git a/lib/types/validator/signed_aggregate_and_proof.ex b/lib/types/validator/signed_aggregate_and_proof.ex index 15e4cbfe4..a42c10da5 100644 --- a/lib/types/validator/signed_aggregate_and_proof.ex +++ b/lib/types/validator/signed_aggregate_and_proof.ex @@ -19,7 +19,7 @@ defmodule Types.SignedAggregateAndProof do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.AggregateAndProof}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/validator/signed_contribution_and_proof.ex b/lib/types/validator/signed_contribution_and_proof.ex index 5d1e6adc8..6db8bc057 100644 --- a/lib/types/validator/signed_contribution_and_proof.ex +++ b/lib/types/validator/signed_contribution_and_proof.ex @@ -19,7 +19,7 @@ defmodule Types.SignedContributionAndProof do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:message, Types.ContributionAndProof}, {:signature, TypeAliases.bls_signature()} diff --git a/lib/types/validator/sync_committee_contribution.ex b/lib/types/validator/sync_committee_contribution.ex index 752a4b08d..30874ddfe 100644 --- a/lib/types/validator/sync_committee_contribution.ex +++ b/lib/types/validator/sync_committee_contribution.ex @@ -26,7 +26,7 @@ defmodule Types.SyncCommitteeContribution do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:slot, TypeAliases.slot()}, {:beacon_block_root, TypeAliases.root()}, diff --git a/lib/types/validator/sync_committee_message.ex b/lib/types/validator/sync_committee_message.ex index 3c4790785..73c891a4e 100644 --- a/lib/types/validator/sync_committee_message.ex +++ b/lib/types/validator/sync_committee_message.ex @@ -23,7 +23,7 @@ defmodule Types.SyncCommitteeMessage do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:slot, TypeAliases.slot()}, {:beacon_block_root, TypeAliases.root()}, diff --git a/lib/utils/bit_list.ex b/lib/utils/bit_list.ex index 6cad2d86c..076b2eeba 100644 --- a/lib/utils/bit_list.ex +++ b/lib/utils/bit_list.ex @@ -18,7 +18,7 @@ defmodule LambdaEthereumConsensus.Utils.BitList do Creates a default (empty/size 0) bit list. """ @spec default :: t - def default, do: <<>> + def default(), do: <<>> @doc """ Creates a new bit_list from bitstring. diff --git a/lib/utils/profile.ex b/lib/utils/profile.ex index d8b4acfa8..c38f31e6a 100644 --- a/lib/utils/profile.ex +++ b/lib/utils/profile.ex @@ -31,7 +31,7 @@ defmodule LambdaEthereumConsensus.Profile do :ok end - defp now_str do + defp now_str() do DateTime.utc_now() |> Formatter.format!("{YYYY}_{0M}_{0D}__{h24}_{m}_{s}_{ss}") |> String.replace(".", "") diff --git a/mix.exs b/mix.exs index 7fb74bb2b..2d1fca0dd 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule LambdaEthereumConsensus.MixProject do use Mix.Project - def project do + def project() do [ app: :lambda_ethereum_consensus, version: "0.1.0", @@ -20,7 +20,7 @@ defmodule LambdaEthereumConsensus.MixProject do end # Run "mix help compile.app" to learn about applications. - def application do + def application() do [ extra_applications: [:logger, :observer, :prometheus_ex], mod: {LambdaEthereumConsensus.Application, []} @@ -28,7 +28,7 @@ defmodule LambdaEthereumConsensus.MixProject do end # Run "mix help deps" to learn about dependencies. - defp deps do + defp deps() do [ {:phoenix, "~> 1.7.7"}, {:plug_cowboy, "~> 2.5"}, @@ -71,7 +71,7 @@ defmodule LambdaEthereumConsensus.MixProject do ] end - defp dialyzer do + defp dialyzer() do [ # https://elixirforum.com/t/help-with-dialyzer-output/15202/5 plt_add_apps: [:ex_unit, :mix], diff --git a/test/fixtures/block.ex b/test/fixtures/block.ex index 0e60a9698..030e8fb7a 100644 --- a/test/fixtures/block.ex +++ b/test/fixtures/block.ex @@ -14,7 +14,7 @@ defmodule Fixtures.Block do alias Types.SignedBeaconBlock @spec signed_beacon_block :: SignedBeaconBlock.t() - def signed_beacon_block do + def signed_beacon_block() do %SignedBeaconBlock{ message: beacon_block(), signature: Random.bls_signature() @@ -22,7 +22,7 @@ defmodule Fixtures.Block do end @spec beacon_block :: BeaconBlock.t() - def beacon_block do + def beacon_block() do %BeaconBlock{ parent_root: Random.root(), slot: Random.uint64(), @@ -33,7 +33,7 @@ defmodule Fixtures.Block do end @spec beacon_block_body :: BeaconBlockBody.t() - def beacon_block_body do + def beacon_block_body() do fields = [ randao_reveal: Random.bls_signature(), @@ -54,7 +54,7 @@ defmodule Fixtures.Block do end @spec eth1_data :: Types.Eth1Data.t() - def eth1_data do + def eth1_data() do %Types.Eth1Data{ deposit_root: Random.root(), deposit_count: Random.uint64(), @@ -63,7 +63,7 @@ defmodule Fixtures.Block do end @spec sync_aggregate :: Types.SyncAggregate.t() - def sync_aggregate do + def sync_aggregate() do %Types.SyncAggregate{ sync_committee_bits: Random.sync_committee_bits(), sync_committee_signature: Random.bls_signature() @@ -71,7 +71,7 @@ defmodule Fixtures.Block do end @spec execution_payload :: ExecutionPayload.t() - def execution_payload do + def execution_payload() do fields = [ parent_hash: Random.hash32(), @@ -97,7 +97,7 @@ defmodule Fixtures.Block do end @spec fork :: Types.Fork.t() - def fork do + def fork() do %Types.Fork{ previous_version: Random.binary(4), current_version: Random.binary(4), @@ -106,7 +106,7 @@ defmodule Fixtures.Block do end @spec beacon_block_header :: Types.BeaconBlockHeader.t() - def signed_beacon_block_header do + def signed_beacon_block_header() do %Types.SignedBeaconBlockHeader{ message: beacon_block_header(), signature: Random.bls_signature() @@ -114,7 +114,7 @@ defmodule Fixtures.Block do end @spec beacon_block_header :: Types.BeaconBlockHeader.t() - def beacon_block_header do + def beacon_block_header() do %Types.BeaconBlockHeader{ slot: Random.uint64(), proposer_index: Random.uint64(), @@ -125,7 +125,7 @@ defmodule Fixtures.Block do end @spec checkpoint :: Types.Checkpoint.t() - def checkpoint do + def checkpoint() do %Types.Checkpoint{ epoch: Random.uint64(), root: Random.root() @@ -133,7 +133,7 @@ defmodule Fixtures.Block do end @spec sync_committee :: Types.SyncCommittee.t() - def sync_committee do + def sync_committee() do %Types.SyncCommittee{ pubkeys: [], aggregate_pubkey: Random.binary(48) @@ -141,7 +141,7 @@ defmodule Fixtures.Block do end @spec execution_payload_header :: ExecutionPayloadHeader.t() - def execution_payload_header do + def execution_payload_header() do fields = [ parent_hash: Random.binary(32), @@ -167,7 +167,7 @@ defmodule Fixtures.Block do end @spec beacon_state :: BeaconState.t() - def beacon_state do + def beacon_state() do %BeaconState{ genesis_time: Random.uint64(), genesis_validators_root: Random.root(), diff --git a/test/fixtures/utils.ex b/test/fixtures/utils.ex index dd727ffcf..a98d17bab 100644 --- a/test/fixtures/utils.ex +++ b/test/fixtures/utils.ex @@ -9,37 +9,37 @@ defmodule Fixtures.Random do end @spec hash32 :: binary - def hash32 do + def hash32() do binary(32) end @spec root :: binary - def root do + def root() do binary(32) end @spec bls_signature :: binary - def bls_signature do + def bls_signature() do binary(96) end @spec sync_committee_bits :: binary - def sync_committee_bits do + def sync_committee_bits() do binary(64) end @spec execution_address :: binary - def execution_address do + def execution_address() do binary(20) end @spec uint64 :: pos_integer - def uint64 do + def uint64() do :rand.uniform(2 ** 64 - 1) end @spec uint256 :: pos_integer - def uint256 do + def uint256() do :rand.uniform(2 ** 256 - 1) end end diff --git a/test/spec/meta_utils.ex b/test/spec/meta_utils.ex index f39cd8a45..9d19cb8b7 100644 --- a/test/spec/meta_utils.ex +++ b/test/spec/meta_utils.ex @@ -9,9 +9,9 @@ defmodule Spec.MetaUtils do @vector_sub_dirs ["config", "fork", "runner", "handler", "suite", "case"] @vector_dir_keys Enum.map(@vector_sub_dirs, &String.to_atom/1) - def vectors_dir, do: @vectors_dir - def runners_dir, do: @runners_dir - def generated_dir, do: @generated_dir + def vectors_dir(), do: @vectors_dir + def runners_dir(), do: @runners_dir + def generated_dir(), do: @generated_dir @doc """ All SpecTestCases for a filter. The filter might have either of the following keys: @@ -58,7 +58,7 @@ defmodule Spec.MetaUtils do details, only the number of tests that are run or skipped. Partial directories are more interesting, as they might have unimplemented cases by oversight. """ - def check_enabled do + def check_enabled() do {_status, "tests", res} = check_enabled(@vectors_dir, ["root" | @vector_sub_dirs]) res end diff --git a/test/spec/runners/helpers/ssz_static_containers/bits_struct.ex b/test/spec/runners/helpers/ssz_static_containers/bits_struct.ex index ecae1c7f0..68e75b610 100644 --- a/test/spec/runners/helpers/ssz_static_containers/bits_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/bits_struct.ex @@ -24,7 +24,7 @@ defmodule Helpers.SszStaticContainers.BitsStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:bitlist, 5}}, {:B, {:bitvector, 2}}, diff --git a/test/spec/runners/helpers/ssz_static_containers/complex_test_struct.ex b/test/spec/runners/helpers/ssz_static_containers/complex_test_struct.ex index a2210797c..b7d818f85 100644 --- a/test/spec/runners/helpers/ssz_static_containers/complex_test_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/complex_test_struct.ex @@ -30,7 +30,7 @@ defmodule Helpers.SszStaticContainers.ComplexTestStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:int, 16}}, {:B, {:list, {:int, 16}, 128}}, diff --git a/test/spec/runners/helpers/ssz_static_containers/fixed_test_struct.ex b/test/spec/runners/helpers/ssz_static_containers/fixed_test_struct.ex index e54942203..1f8c5b3a0 100644 --- a/test/spec/runners/helpers/ssz_static_containers/fixed_test_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/fixed_test_struct.ex @@ -22,7 +22,7 @@ defmodule Helpers.SszStaticContainers.FixedTestStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:int, 8}}, {:B, {:int, 64}}, diff --git a/test/spec/runners/helpers/ssz_static_containers/single_field_test_struct.ex b/test/spec/runners/helpers/ssz_static_containers/single_field_test_struct.ex index c5f8781dc..c99d0b686 100644 --- a/test/spec/runners/helpers/ssz_static_containers/single_field_test_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/single_field_test_struct.ex @@ -16,7 +16,7 @@ defmodule Helpers.SszStaticContainers.SingleFieldTestStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:int, 8}} ] diff --git a/test/spec/runners/helpers/ssz_static_containers/small_test_struct.ex b/test/spec/runners/helpers/ssz_static_containers/small_test_struct.ex index 69d2a1434..8cba6c437 100644 --- a/test/spec/runners/helpers/ssz_static_containers/small_test_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/small_test_struct.ex @@ -18,7 +18,7 @@ defmodule Helpers.SszStaticContainers.SmallTestStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:int, 16}}, {:B, {:int, 16}} diff --git a/test/spec/runners/helpers/ssz_static_containers/var_test_struct.ex b/test/spec/runners/helpers/ssz_static_containers/var_test_struct.ex index 90f39c4be..16ef81262 100644 --- a/test/spec/runners/helpers/ssz_static_containers/var_test_struct.ex +++ b/test/spec/runners/helpers/ssz_static_containers/var_test_struct.ex @@ -20,7 +20,7 @@ defmodule Helpers.SszStaticContainers.VarTestStruct do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:A, {:int, 16}}, {:B, {:list, {:int, 16}, 1024}}, diff --git a/test/spec/runners/rewards.ex b/test/spec/runners/rewards.ex index 390f8acb8..df90674c9 100644 --- a/test/spec/runners/rewards.ex +++ b/test/spec/runners/rewards.ex @@ -101,7 +101,7 @@ defmodule Deltas do } @impl LambdaEthereumConsensus.Container - def schema do + def schema() do [ {:rewards, {:list, {:int, 64}, 1_099_511_627_776}}, {:penalties, {:list, {:int, 64}, 1_099_511_627_776}} diff --git a/test/spec/runners/sync.ex b/test/spec/runners/sync.ex index f4e230fb9..7637ace77 100644 --- a/test/spec/runners/sync.ex +++ b/test/spec/runners/sync.ex @@ -100,7 +100,7 @@ defmodule SyncTestRunner.EngineApiMock do end def get_payload(_payload_id), do: raise("Not implemented") - def exchange_capabilities, do: raise("Not implemented") + def exchange_capabilities(), do: raise("Not implemented") def get_block_header(_block_id), do: raise("Not implemented") def get_deposit_logs(_range), do: raise("Not implemented") end diff --git a/test/spec/utils.ex b/test/spec/utils.ex index 2af5b4b37..d0a5c6909 100644 --- a/test/spec/utils.ex +++ b/test/spec/utils.ex @@ -15,7 +15,7 @@ defmodule SpecTestUtils do "current_epoch_participation" ] - def vectors_dir, do: @vectors_dir + def vectors_dir(), do: @vectors_dir @spec sanitize_yaml(any()) :: any() def sanitize_yaml(map) when is_map(map) do diff --git a/test/unit/libp2p_port_test.exs b/test/unit/libp2p_port_test.exs index 33cb3ef9b..0ca212e48 100644 --- a/test/unit/libp2p_port_test.exs +++ b/test/unit/libp2p_port_test.exs @@ -81,7 +81,7 @@ defmodule Unit.Libp2pPortTest do assert_receive {:new_peer, _peer_id}, 10_000 end - defp two_hosts_gossip do + defp two_hosts_gossip() do gossiper_addr = ["/ip4/127.0.0.1/tcp/48766"] start_port(:publisher) start_port(:gossiper, listen_addr: gossiper_addr)