From e4c3c556d5bd820698896c76325ac5013351102f Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 31 Mar 2019 09:02:10 +0400 Subject: [PATCH 1/3] Rename "transaction" to "operation" Fix #822. --- specs/core/0_beacon-chain.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index d08828692f..5be13cdb57 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -18,7 +18,7 @@ - [Time parameters](#time-parameters) - [State list lengths](#state-list-lengths) - [Reward and penalty quotients](#reward-and-penalty-quotients) - - [Max transactions per block](#max-transactions-per-block) + - [Max operations per block](#max-operations-per-block) - [Signature domains](#signature-domains) - [Data structures](#data-structures) - [Misc dependencies](#misc-dependencies) @@ -34,7 +34,7 @@ - [`Validator`](#validator) - [`PendingAttestation`](#pendingattestation) - [`HistoricalBatch`](#historicalbatch) - - [Beacon transactions](#beacon-transactions) + - [Beacon operations](#beacon-operations) - [`ProposerSlashing`](#proposerslashing) - [`AttesterSlashing`](#attesterslashing) - [`Attestation`](#attestation) @@ -132,7 +132,7 @@ - [Block header](#block-header) - [RANDAO](#randao) - [Eth1 data](#eth1-data-1) - - [Transactions](#transactions) + - [Operations](#operations) - [Proposer slashings](#proposer-slashings) - [Attester slashings](#attester-slashings) - [Attestations](#attestations) @@ -261,8 +261,7 @@ Code snippets appearing in `this style` are to be interpreted as Python code. * The `BASE_REWARD_QUOTIENT` parameter dictates the per-epoch reward. It corresponds to ~2.54% annual interest assuming 10 million participating ETH in every epoch. * The `INACTIVITY_PENALTY_QUOTIENT` equals `INVERSE_SQRT_E_DROP_TIME**2` where `INVERSE_SQRT_E_DROP_TIME := 2**12 epochs` (~18 days) is the time it takes the inactivity penalty to reduce the balance of non-participating [validators](#dfn-validator) to about `1/sqrt(e) ~= 60.6%`. Indeed, the balance retained by offline [validators](#dfn-validator) after `n` epochs is about `(1 - 1/INACTIVITY_PENALTY_QUOTIENT)**(n**2/2)` so after `INVERSE_SQRT_E_DROP_TIME` epochs it is roughly `(1 - 1/INACTIVITY_PENALTY_QUOTIENT)**(INACTIVITY_PENALTY_QUOTIENT/2) ~= 1/sqrt(e)`. - -### Max transactions per block +### Max operations per block | Name | Value | | - | - | @@ -460,7 +459,7 @@ The types are defined topologically to aid in facilitating an executable version } ``` -### Beacon transactions +### Beacon operations #### `ProposerSlashing` @@ -2234,7 +2233,7 @@ def process_eth1_data(state: BeaconState, block: BeaconBlock) -> None: state.eth1_data_votes.append(Eth1DataVote(eth1_data=block.body.eth1_data, vote_count=1)) ``` -#### Transactions +#### Operations ##### Proposer slashings @@ -2246,7 +2245,7 @@ For each `proposer_slashing` in `block.body.proposer_slashings`, run the followi def process_proposer_slashing(state: BeaconState, proposer_slashing: ProposerSlashing) -> None: """ - Process ``ProposerSlashing`` transaction. + Process ``ProposerSlashing`` operation. Note that this function mutates ``state``. """ proposer = state.validator_registry[proposer_slashing.proposer_index] @@ -2277,7 +2276,7 @@ For each `attester_slashing` in `block.body.attester_slashings`, run the followi def process_attester_slashing(state: BeaconState, attester_slashing: AttesterSlashing) -> None: """ - Process ``AttesterSlashing`` transaction. + Process ``AttesterSlashing`` operation. Note that this function mutates ``state``. """ attestation1 = attester_slashing.attestation_1 @@ -2312,7 +2311,7 @@ For each `attestation` in `block.body.attestations`, run the following function: ```python def process_attestation(state: BeaconState, attestation: Attestation) -> None: """ - Process ``Attestation`` transaction. + Process ``Attestation`` operation. Note that this function mutates ``state``. """ assert max(GENESIS_SLOT, state.slot - SLOTS_PER_EPOCH) <= attestation.data.slot @@ -2367,7 +2366,7 @@ For each `exit` in `block.body.voluntary_exits`, run the following function: ```python def process_voluntary_exit(state: BeaconState, exit: VoluntaryExit) -> None: """ - Process ``VoluntaryExit`` transaction. + Process ``VoluntaryExit`` operation. Note that this function mutates ``state``. """ validator = state.validator_registry[exit.validator_index] @@ -2403,7 +2402,7 @@ For each `transfer` in `block.body.transfers`, run the following function: ```python def process_transfer(state: BeaconState, transfer: Transfer) -> None: """ - Process ``Transfer`` transaction. + Process ``Transfer`` operation. Note that this function mutates ``state``. """ # Verify the amount and fee aren't individually too big (for anti-overflow purposes) From 77b0a4188bf573c3174db26d36a0e2348a33b5a2 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sun, 31 Mar 2019 22:54:46 +0800 Subject: [PATCH 2/3] Update `1_custody-game.md` as well --- specs/core/1_custody-game.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/specs/core/1_custody-game.md b/specs/core/1_custody-game.md index fd754634e3..e28536d34c 100644 --- a/specs/core/1_custody-game.md +++ b/specs/core/1_custody-game.md @@ -13,7 +13,7 @@ - [Constants](#constants) - [Misc](#misc) - [Time parameters](#time-parameters) - - [Max transactions per block](#max-transactions-per-block) + - [Max operations per block](#max-operations-per-block) - [Signature domains](#signature-domains) - [Data structures](#data-structures) - [Custody objects](#custody-objects) @@ -33,7 +33,7 @@ - [`epoch_to_custody_period`](#epoch_to_custody_period) - [`verify_custody_key`](#verify_custody_key) - [Per-block processing](#per-block-processing) - - [Transactions](#transactions) + - [Operations](#operations) - [Custody reveals](#custody-reveals) - [Chunk challenges](#chunk-challenges) - [Bit challenges](#bit-challenges) @@ -79,7 +79,7 @@ This document details the beacon chain additions and changes in Phase 1 of Ether | `EPOCHS_PER_CUSTODY_PERIOD` | `2**11` (= 2,048) | epochs | ~9 days | | `CUSTODY_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days | -### Max transactions per block +### Max operations per block | Name | Value | | - | - | @@ -259,9 +259,9 @@ def verify_custody_key(state: BeaconState, reveal: CustodyKeyReveal) -> bool: ## Per-block processing -### Transactions +### Operations -Add the following transactions to the per-block processing, in order the given below and after all other transactions in phase 0. +Add the following operations to the per-block processing, in order the given below and after all other operations in phase 0. #### Custody reveals From 93540f9662a94d23bb993765adf8df1b24ad3346 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Sun, 31 Mar 2019 23:00:21 +0800 Subject: [PATCH 3/3] Rename transaction to operation in tests --- utils/phase0/state_transition.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/utils/phase0/state_transition.py b/utils/phase0/state_transition.py index cfd941c420..2c420014f8 100644 --- a/utils/phase0/state_transition.py +++ b/utils/phase0/state_transition.py @@ -22,31 +22,31 @@ def expected_deposit_count(state: BeaconState) -> int: ) -def process_transaction_type(state: BeaconState, - transactions: List[Any], - max_transactions: int, - tx_fn: Callable[[BeaconState, Any], None]) -> None: - assert len(transactions) <= max_transactions - for transaction in transactions: - tx_fn(state, transaction) +def process_operation_type(state: BeaconState, + operations: List[Any], + max_operations: int, + tx_fn: Callable[[BeaconState, Any], None]) -> None: + assert len(operations) <= max_operations + for operation in operations: + tx_fn(state, operation) -def process_transactions(state: BeaconState, block: BeaconBlock) -> None: - process_transaction_type( +def process_operations(state: BeaconState, block: BeaconBlock) -> None: + process_operation_type( state, block.body.proposer_slashings, spec.MAX_PROPOSER_SLASHINGS, spec.process_proposer_slashing, ) - process_transaction_type( + process_operation_type( state, block.body.attester_slashings, spec.MAX_ATTESTER_SLASHINGS, spec.process_attester_slashing, ) - process_transaction_type( + process_operation_type( state, block.body.attestations, spec.MAX_ATTESTATIONS, @@ -54,14 +54,14 @@ def process_transactions(state: BeaconState, block: BeaconBlock) -> None: ) assert len(block.body.deposits) == expected_deposit_count(state) - process_transaction_type( + process_operation_type( state, block.body.deposits, spec.MAX_DEPOSITS, spec.process_deposit, ) - process_transaction_type( + process_operation_type( state, block.body.voluntary_exits, spec.MAX_VOLUNTARY_EXITS, @@ -69,7 +69,7 @@ def process_transactions(state: BeaconState, block: BeaconBlock) -> None: ) assert len(block.body.transfers) == len(set(block.body.transfers)) - process_transaction_type( + process_operation_type( state, block.body.transfers, spec.MAX_TRANSFERS, @@ -84,7 +84,7 @@ def process_block(state: BeaconState, spec.process_randao(state, block) spec.process_eth1_data(state, block) - process_transactions(state, block) + process_operations(state, block) if verify_state_root: spec.verify_block_state_root(state, block)