Merge pull request #863 from ethereum/JustinDrake-patch-8

Rename "transaction" to "operation"
This commit is contained in:
Danny Ryan 2019-04-02 05:06:30 -06:00 committed by GitHub
commit 226e33b364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 32 deletions

View File

@ -18,7 +18,7 @@
- [Time parameters](#time-parameters) - [Time parameters](#time-parameters)
- [State list lengths](#state-list-lengths) - [State list lengths](#state-list-lengths)
- [Reward and penalty quotients](#reward-and-penalty-quotients) - [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) - [Signature domains](#signature-domains)
- [Data structures](#data-structures) - [Data structures](#data-structures)
- [Misc dependencies](#misc-dependencies) - [Misc dependencies](#misc-dependencies)
@ -34,7 +34,7 @@
- [`Validator`](#validator) - [`Validator`](#validator)
- [`PendingAttestation`](#pendingattestation) - [`PendingAttestation`](#pendingattestation)
- [`HistoricalBatch`](#historicalbatch) - [`HistoricalBatch`](#historicalbatch)
- [Beacon transactions](#beacon-transactions) - [Beacon operations](#beacon-operations)
- [`ProposerSlashing`](#proposerslashing) - [`ProposerSlashing`](#proposerslashing)
- [`AttesterSlashing`](#attesterslashing) - [`AttesterSlashing`](#attesterslashing)
- [`Attestation`](#attestation) - [`Attestation`](#attestation)
@ -132,7 +132,7 @@
- [Block header](#block-header) - [Block header](#block-header)
- [RANDAO](#randao) - [RANDAO](#randao)
- [Eth1 data](#eth1-data-1) - [Eth1 data](#eth1-data-1)
- [Transactions](#transactions) - [Operations](#operations)
- [Proposer slashings](#proposer-slashings) - [Proposer slashings](#proposer-slashings)
- [Attester slashings](#attester-slashings) - [Attester slashings](#attester-slashings)
- [Attestations](#attestations) - [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 `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)`. * 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 operations per block
### Max transactions per block
| Name | Value | | Name | Value |
| - | - | | - | - |
@ -460,7 +459,7 @@ The types are defined topologically to aid in facilitating an executable version
} }
``` ```
### Beacon transactions ### Beacon operations
#### `ProposerSlashing` #### `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)) state.eth1_data_votes.append(Eth1DataVote(eth1_data=block.body.eth1_data, vote_count=1))
``` ```
#### Transactions #### Operations
##### Proposer slashings ##### Proposer slashings
@ -2246,7 +2245,7 @@ For each `proposer_slashing` in `block.body.proposer_slashings`, run the followi
def process_proposer_slashing(state: BeaconState, def process_proposer_slashing(state: BeaconState,
proposer_slashing: ProposerSlashing) -> None: proposer_slashing: ProposerSlashing) -> None:
""" """
Process ``ProposerSlashing`` transaction. Process ``ProposerSlashing`` operation.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
proposer = state.validator_registry[proposer_slashing.proposer_index] 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, def process_attester_slashing(state: BeaconState,
attester_slashing: AttesterSlashing) -> None: attester_slashing: AttesterSlashing) -> None:
""" """
Process ``AttesterSlashing`` transaction. Process ``AttesterSlashing`` operation.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
attestation1 = attester_slashing.attestation_1 attestation1 = attester_slashing.attestation_1
@ -2312,7 +2311,7 @@ For each `attestation` in `block.body.attestations`, run the following function:
```python ```python
def process_attestation(state: BeaconState, attestation: Attestation) -> None: def process_attestation(state: BeaconState, attestation: Attestation) -> None:
""" """
Process ``Attestation`` transaction. Process ``Attestation`` operation.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
assert max(GENESIS_SLOT, state.slot - SLOTS_PER_EPOCH) <= attestation.data.slot 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 ```python
def process_voluntary_exit(state: BeaconState, exit: VoluntaryExit) -> None: def process_voluntary_exit(state: BeaconState, exit: VoluntaryExit) -> None:
""" """
Process ``VoluntaryExit`` transaction. Process ``VoluntaryExit`` operation.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
validator = state.validator_registry[exit.validator_index] validator = state.validator_registry[exit.validator_index]
@ -2403,7 +2402,7 @@ For each `transfer` in `block.body.transfers`, run the following function:
```python ```python
def process_transfer(state: BeaconState, transfer: Transfer) -> None: def process_transfer(state: BeaconState, transfer: Transfer) -> None:
""" """
Process ``Transfer`` transaction. Process ``Transfer`` operation.
Note that this function mutates ``state``. Note that this function mutates ``state``.
""" """
# Verify the amount and fee aren't individually too big (for anti-overflow purposes) # Verify the amount and fee aren't individually too big (for anti-overflow purposes)

View File

@ -13,7 +13,7 @@
- [Constants](#constants) - [Constants](#constants)
- [Misc](#misc) - [Misc](#misc)
- [Time parameters](#time-parameters) - [Time parameters](#time-parameters)
- [Max transactions per block](#max-transactions-per-block) - [Max operations per block](#max-operations-per-block)
- [Signature domains](#signature-domains) - [Signature domains](#signature-domains)
- [Data structures](#data-structures) - [Data structures](#data-structures)
- [Custody objects](#custody-objects) - [Custody objects](#custody-objects)
@ -33,7 +33,7 @@
- [`epoch_to_custody_period`](#epoch_to_custody_period) - [`epoch_to_custody_period`](#epoch_to_custody_period)
- [`verify_custody_key`](#verify_custody_key) - [`verify_custody_key`](#verify_custody_key)
- [Per-block processing](#per-block-processing) - [Per-block processing](#per-block-processing)
- [Transactions](#transactions) - [Operations](#operations)
- [Custody reveals](#custody-reveals) - [Custody reveals](#custody-reveals)
- [Chunk challenges](#chunk-challenges) - [Chunk challenges](#chunk-challenges)
- [Bit challenges](#bit-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 | | `EPOCHS_PER_CUSTODY_PERIOD` | `2**11` (= 2,048) | epochs | ~9 days |
| `CUSTODY_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days | | `CUSTODY_RESPONSE_DEADLINE` | `2**14` (= 16,384) | epochs | ~73 days |
### Max transactions per block ### Max operations per block
| Name | Value | | Name | Value |
| - | - | | - | - |
@ -259,9 +259,9 @@ def verify_custody_key(state: BeaconState, reveal: CustodyKeyReveal) -> bool:
## Per-block processing ## 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 #### Custody reveals

View File

@ -22,31 +22,31 @@ def expected_deposit_count(state: BeaconState) -> int:
) )
def process_transaction_type(state: BeaconState, def process_operation_type(state: BeaconState,
transactions: List[Any], operations: List[Any],
max_transactions: int, max_operations: int,
tx_fn: Callable[[BeaconState, Any], None]) -> None: tx_fn: Callable[[BeaconState, Any], None]) -> None:
assert len(transactions) <= max_transactions assert len(operations) <= max_operations
for transaction in transactions: for operation in operations:
tx_fn(state, transaction) tx_fn(state, operation)
def process_transactions(state: BeaconState, block: BeaconBlock) -> None: def process_operations(state: BeaconState, block: BeaconBlock) -> None:
process_transaction_type( process_operation_type(
state, state,
block.body.proposer_slashings, block.body.proposer_slashings,
spec.MAX_PROPOSER_SLASHINGS, spec.MAX_PROPOSER_SLASHINGS,
spec.process_proposer_slashing, spec.process_proposer_slashing,
) )
process_transaction_type( process_operation_type(
state, state,
block.body.attester_slashings, block.body.attester_slashings,
spec.MAX_ATTESTER_SLASHINGS, spec.MAX_ATTESTER_SLASHINGS,
spec.process_attester_slashing, spec.process_attester_slashing,
) )
process_transaction_type( process_operation_type(
state, state,
block.body.attestations, block.body.attestations,
spec.MAX_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) assert len(block.body.deposits) == expected_deposit_count(state)
process_transaction_type( process_operation_type(
state, state,
block.body.deposits, block.body.deposits,
spec.MAX_DEPOSITS, spec.MAX_DEPOSITS,
spec.process_deposit, spec.process_deposit,
) )
process_transaction_type( process_operation_type(
state, state,
block.body.voluntary_exits, block.body.voluntary_exits,
spec.MAX_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)) assert len(block.body.transfers) == len(set(block.body.transfers))
process_transaction_type( process_operation_type(
state, state,
block.body.transfers, block.body.transfers,
spec.MAX_TRANSFERS, spec.MAX_TRANSFERS,
@ -84,7 +84,7 @@ def process_block(state: BeaconState,
spec.process_randao(state, block) spec.process_randao(state, block)
spec.process_eth1_data(state, block) spec.process_eth1_data(state, block)
process_transactions(state, block) process_operations(state, block)
if verify_state_root: if verify_state_root:
spec.verify_block_state_root(state, block) spec.verify_block_state_root(state, block)