Commit Graph

1663 Commits

Author SHA1 Message Date
Justin Drake f0a8e39243 WIP 2019-06-29 17:29:21 +01:00
Hsiao-Wei Wang 7fdf59d012
`active_validator_count >= GENESIS_ACTIVE_VALIDATOR_COUNT`: per Eth1 block 2019-06-29 18:09:05 +08:00
dankrad fa84c49659
Update specs/core/0_beacon-chain.md
Co-Authored-By: Danny Ryan <dannyjryan@gmail.com>
2019-06-28 20:23:34 +01:00
Hsiao-Wei Wang cb2bfd67dc
Apply Proto's feedback of list(map(...)) 2019-06-29 02:27:48 +08:00
Hsiao-Wei Wang 4dc526fbb7
In the end, `get_merkle_root` is back 2019-06-29 02:16:49 +08:00
Danny Ryan b88ab250fa
Merge branch 'dev' into committee-roots 2019-06-28 12:07:50 -06:00
Danny Ryan 9993a28796
lint 2019-06-28 11:26:05 -06:00
Danny Ryan b40e2284a0
use active index root for generate seed mix in 2019-06-28 11:20:24 -06:00
Danny Ryan 5a8f3e495a
set committees root for next epoch rather tahn ACTIVaTION_EXIT_DELAY in the future 2019-06-28 11:10:17 -06:00
protolambda 5f0e58364f
resolved merge conflicts, take attesters seq->set change from dev, take bits rework from bitlistvector PR 2019-06-28 18:17:13 +02:00
protolambda 25db397550
fix line length lint problem in checkpoint 2019-06-28 17:34:31 +02:00
protolambda 128bbbc665
fix slicing, and support partial slice bounds 2019-06-28 17:27:59 +02:00
Danny Ryan dcb0244a4f get_attesting_indices set instead of sorted (#1225) 2019-06-28 16:19:59 +01:00
Justin 05842f8371
Update 0_beacon-chain.md 2019-06-28 15:26:02 +01:00
vbuterin c764202a57 Slashing penalty calculation change (#1217)
If the exit queue is very long, then a validator may take many months to exit. With the code as currently written, however, self-slashing is a potentially lucrative route to get one's money out faster, because one can exit in 36 days.

This PR changes it so that slashing can only extend your withdrawal time, not contract it. Also, instead of the slashed balances used to calculate one's slashing penalty being those in `[withdrawal - 54 days ... withdrawal - 18 days]`, we now run the penalization algorithm once every 36 days that a validator is slashed but not withdrawn, so that it covers the 36-day period where the validator was actually slashed.  It also moves the minimum slashing penalty to the `slash_validator` function so that it is only applied once.

We also simplify the `slashed_balances` logic to be per-epoch.
2019-06-28 14:35:26 +01:00
Justin Drake e36593b155 Add comment 2019-06-28 12:35:50 +01:00
Justin Drake 6f9d37485d Cleanups 2019-06-28 12:34:01 +01:00
Justin Drake 196ac42025 Cleanup naming 2019-06-28 12:23:22 +01:00
Dankrad Feist 2622548ba7
Merge remote-tracking branch 'origin/dev' into dankrad-patch-8
# Conflicts:
#	specs/core/0_beacon-chain.md
2019-06-28 08:36:45 +01:00
Danny Ryan 140c69f2ec
Merge branch 'dev' into checkpoints 2019-06-27 21:02:48 -06:00
Dankrad Feist 237b41df5b
Slice notation for justification_bitfield shift 2019-06-28 00:18:54 +01:00
Danny Ryan 990cc55db7
fix committee typing error 2019-06-27 16:32:10 -06:00
Justin Drake 853f5fc3f0 Apply Danny's suggestions 2019-06-27 19:05:27 +01:00
Dankrad Feist 93ce168862
More linting fixes 2019-06-27 16:47:48 +01:00
Dankrad Feist f57387cc83
Justification bitvector length to constant 2019-06-27 13:09:48 +01:00
Dankrad Feist becb7a032a
justification_bitfield -> Bitvector[4] 2019-06-27 12:15:31 +01:00
Dankrad Feist 67c50cb197
Changed attestation and custody bitfields 2019-06-27 12:15:29 +01:00
Justin Drake ee712ecdde Make HW happy :) 2019-06-27 11:21:45 +01:00
Dankrad Feist 02f6ba36f0
Add Bitvector and Bitlist
Bool, Bit -> boolean, bit
Fix simple-serialize.md
2019-06-27 09:51:06 +01:00
Justin Drake bcfe383e25 WIP 2019-06-27 08:44:44 +01:00
protolambda a0c2f5c6b5
fix genesis testing code, add missing constant temporarily, fix py Generator/map/list problems 2019-06-27 01:57:30 +02:00
protolambda a62d0261ca
merge with dev, fixed now 2019-06-27 01:31:10 +02:00
Alex Stokes 23909ca727
Fix line lengths 2019-06-26 17:06:34 -06:00
Alex Stokes 10e257490f
Clarify `get_randao_mix` accessor
We avoid a genesis underflow by taking the randao epoch in `generate_seed` to be `+ EPOCHS_PER_HISTORICAL_VECTOR`.

This conflicts with the expected epoch bounds noted  in `get_randao_mix` and this PR attempts to clarify the situation by leaving a note.
2019-06-26 16:33:23 -06:00
Diederik Loerakker d587c4fe61 Critical fix: introduce back total-value check (#1220)
This was dropped in a376b6607f, as improvement in dust checking.
Now that dust-checking is done, we still need to check if the sender has the minimum value, as decrease balance just clips to 0.
See be86f966f8 for older dust-creation problem work around, which was dropped in the above.

The bug enabled you to transfer your full balance to someone else, and pay the same amount in fee, possibly to a puppet proposer to collect back funds.
Effectively enabling printing of money. Silly bug, good to fix and introduce tests for.
2019-06-26 20:21:17 +01:00
Justin Drake ccda508254 Fix deposit root, add min_genesis_time, per-block processing 2019-06-26 15:34:54 +01:00
Justin Drake 8c34aa8c5f Initial draft 2019-06-26 13:20:04 +01:00
Alex Stokes 4986311d5b
Update 0_beacon-chain.md
fix typo w/ refactor
2019-06-25 10:24:14 -06:00
Danny Ryan df2a9e1b54
Merge pull request #1180 from ethereum/list-rework
pyspec-SSZ: lists-rework (enable static generalized indices) + fully python class based now.
2019-06-25 07:38:50 -06:00
JSON 20602bc92b phase 0 doc standardization b4 spec freeze (#1212) 2019-06-25 14:32:56 +01:00
Alex Stokes 37b1872634 Remove duplicate custom type definitions (#1214)
Seems to be an accidental duplication of the type defs
2019-06-25 14:30:59 +01:00
Danny Ryan b8c0985e60
merge in fork choice. tests pass 2019-06-24 22:12:55 -06:00
Danny Ryan bacd4b1e89
Merge branch 'fork-choice-epoch' into checkpoints 2019-06-24 21:26:28 -06:00
Diederik Loerakker 45dbf5a107
Remove old Deltas reference
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
2019-06-25 02:41:02 +02:00
Alex Stokes 82167ff0a3
Clarify comment on phase 0 transfers
The comment seems to imply conjunction over each case, but the code implies disjunction; at the very least it is ambiguous.

This PR makes the comment less ambiguous.
2019-06-24 15:40:37 -07:00
protolambda 9fb5806764
be explicit about input for balance sum 2019-06-25 00:24:13 +02:00
protolambda 8b88c3f43c
Merge remote-tracking branch 'origin' into list-rework 2019-06-24 23:58:00 +02:00
protolambda 5989e5cd23
use Bool as base name, make Bit an alias 2019-06-24 23:56:26 +02:00
protolambda 82ae180490
clean up list limit constants 2019-06-24 23:38:36 +02:00
Justin bb0a492fea
Cleanups 2019-06-23 11:18:24 +02:00
Justin 1e2bb08a74
Cosmetic fix for consistency 2019-06-23 11:09:09 +02:00
Justin Drake a3f8f50bee Initialise deposit root properly 2019-06-22 23:34:09 +02:00
Justin Drake 2342c787c9 Cleanup 2019-06-22 22:54:07 +02:00
Justin Drake 98692bf9d6 Fix ToC 2019-06-22 22:52:37 +02:00
Justin Drake e6e90c7736 Minor reorg 2019-06-22 22:51:04 +02:00
Justin Drake 181a2a876a Cleanups 2019-06-22 22:49:53 +02:00
Danny Ryan 8a732fbbcf
pass on checkpoints working in testing 2019-06-22 12:00:26 -06:00
protolambda f95e7315b4
fix get_active_validator_indices typing usage 2019-06-22 18:34:33 +02:00
protolambda 00aae07d46
type annotation clean up 2019-06-22 18:12:42 +02:00
Diederik Loerakker b007d5aa92 Add note on default zero-values, and be explicit with state-root (#1208)
* Add note on default zero-values, and be explicit with state-root
2019-06-22 17:38:30 +02:00
protolambda 16093eb8ce
Merge branch 'dev' into list-rework 2019-06-22 17:11:59 +02:00
Diederik Loerakker c86108de00
Merge pull request #1207 from ethereum/fix_make_lint
Fix `make lint`
2019-06-22 17:07:00 +02:00
Justin Drake 1e1a3e5311 Avoid substraction in comparison 2019-06-22 07:34:02 +02:00
Justin Drake 613380bff4 Shorter in-line comments 2019-06-22 07:29:25 +02:00
Hsiao-Wei Wang 183fa3c776
Make linter happy 2019-06-21 23:09:11 -06:00
Hsiao-Wei Wang 6aef6c5634
Clean up 2019-06-21 22:26:15 -06:00
Hsiao-Wei Wang b51011568a
Merge branch 'dev' into test_genesis 2019-06-21 22:13:46 -06:00
Hsiao-Wei Wang 5f09212777
yield for `is_genesis_trigger` 2019-06-21 22:09:09 -06:00
Hsiao-Wei Wang 47b29c8456
Loose condition of effective genesis deposit 2019-06-21 21:49:13 -06:00
Hsiao-Wei Wang 8828dad786
minor updates 2019-06-21 17:07:44 -06:00
Danny Ryan de5b9cc823
convert _root/_epoch tuples to Checkpoint obj in beacon spec 2019-06-21 16:33:43 -06:00
Hsiao-Wei Wang ac34221f55
Fix `is_genesis_trigger` and add test case 2019-06-21 16:30:31 -06:00
Hsiao-Wei Wang b36ffd5c41
default value of `deposit_index` 2019-06-21 16:10:19 -06:00
Hsiao-Wei Wang 7a16db144c
Add test_genesis 2019-06-21 15:59:18 -06:00
protolambda 0b0e9a51d7
Merge branch 'dev' into list-rework 2019-06-21 23:44:01 +02:00
Hsiao-Wei Wang f55499c0ba Fix Gwei value table (#1203) 2019-06-21 14:30:22 -06:00
Hsiao-Wei Wang e99c864ed1
Deltas = NewType('Deltas', TypingList[Gwei]) 2019-06-20 17:17:12 -06:00
protolambda 3d8466fd6e
make Bit check not use "is", and remove duplicate line 2019-06-20 23:04:19 +02:00
protolambda 2d67717079
fix linting issues + make spec builder remove comments in container re-initialization part 2019-06-20 21:42:55 +02:00
protolambda f157745248
resolve some remaining list-rework rebase details 2019-06-20 20:42:19 +02:00
protolambda 4e747fb887
fixes for class based ssz typing 2019-06-20 20:25:22 +02:00
protolambda 8344d50ae5
update beacon chain doc, use new types, avoid List 2019-06-20 20:15:48 +02:00
protolambda 4aefc078e9
list-rework type fixes 2019-06-20 20:11:39 +02:00
vbuterin 4c2adcc5e6 Update 0_beacon-chain.md 2019-06-20 20:05:57 +02:00
protolambda b89183ae69
Update spec for new SSZ with list max length 2019-06-20 20:05:34 +02:00
protolambda 97025c51ac
start updating virtual sizes of lists 2019-06-20 20:03:11 +02:00
Danny Ryan 29dbe1b880 Increase historical length and cleanups (#1196)
* increase historical length and a few cleanups
2019-06-19 20:59:44 +01:00
protolambda 060041945c
remove unnecessary cast 2019-06-18 22:00:22 +02:00
protolambda 346e61dfeb
make epoch pattern similar to exit-epoch loop 2019-06-18 21:59:16 +02:00
Hsiao-Wei Wang dd79a0edb5
Merge branch 'dev' into mypy 2019-06-18 08:24:23 -06:00
Danny Ryan 02954e84fe
Merge branch 'dev' into JustinDrake-patch-14 2019-06-17 16:33:59 -06:00
Danny Ryan e80d363eed
Merge pull request #1157 from ethereum/JustinDrake-patch-13
Set MIN_ATTESTATION_INCLUSION_DELAY to 1
2019-06-17 16:29:55 -06:00
Danny Ryan 89d9d80b1c
move BASE_REWARDS_PER_EPOCH to constants 2019-06-17 16:12:47 -06:00
Hsiao-Wei Wang 9af9bbf42b
Merge branch 'dev' into mypy 2019-06-17 17:51:00 -04:00
Hsiao-Wei Wang 18ebd2aa90
Bytes32 -> Hash 2019-06-17 17:21:45 -04:00
Danny Ryan 207eb808a0
split constants vs configuration 2019-06-17 15:19:44 -06:00
Hsiao-Wei Wang 9b77ec11f8
Version: Bytes4 2019-06-15 17:32:52 -04:00
Hsiao-Wei Wang b772b03847
Handle `BLSPubkey` and `BLSSignature` 2019-06-15 17:23:44 -04:00
Hsiao-Wei Wang 00a68e28b5
Define Custom Types via function_puller 2019-06-15 16:57:50 -04:00
protolambda 75b469281e
fix linting issue 2019-06-15 18:05:01 +02:00
Justin Drake 7cd7659a4b Add comments to non-obvious container fields 2019-06-15 15:51:17 +01:00
Justin Drake ed748a7d76 Address Danny's comments 2019-06-15 15:09:50 +01:00
Danny Ryan a6230425b8
Merge branch 'dev' into container-cleanup 2019-06-14 10:36:41 -06:00
Justin 67d2585ec0
Fix #1173
The bug is that it's possible to include a participating validator which has custody bit one *without* specifying that validator in `attestation.aggregation_bitfield`. In other words, we want to check that every bit in `custody_bitfield` is zero whenever the corresponding bit in `aggregation_bitfield` is zero. Well spotted @protolambda
2019-06-13 21:01:10 +01:00
protolambda aabd2b08ad
attestations: check shard, and check epoch earlier 2019-06-13 15:51:22 +02:00
Alex Stokes f095ab43bb Update 0_beacon-chain.md (#1170)
minor typo fix
2019-06-13 10:40:02 +01:00
Hsiao-Wei Wang 7a366828ba
Make phase0 pass 2019-06-12 14:54:00 -04:00
Justin Drake 6a83205420 Minor copy edit 2019-06-11 15:29:34 +01:00
Hsiao-Wei Wang 6f526add79
flake8 length 2019-06-11 00:45:00 -04:00
Hsiao-Wei Wang 9f454185f8
WIP!
1. Use custom types in SSZ declaration
2. Casting
2019-06-11 00:44:54 -04:00
Justin Drake dc56d87eef Revert a couple of renamings 2019-06-10 21:16:51 +01:00
Justin Drake b60314e892 Merge branch 'deposit-contract-justin' of github.com:ethereum/eth2.0-specs into deposit-contract-justin 2019-06-10 16:03:08 +01:00
Justin Drake ef91ee5698 Address Danny's comments 2019-06-10 15:55:08 +01:00
Justin 05a35c7228
Tweak inclusion delay rewards and set BASE_REWARD_FACTOR
Substantive changes:

1) Split the inclusion delay reward between attester and proposer to add up to at most one base reward. This is analogous to the reward logic in `slash_validator`, and makes the `BASE_REWARDS_PER_EPOCH` constant include proposer rewards.
2) Double `BASE_REWARD_FACTOR` to 2^6 (addressing item 4 in #1054). When the total effective balance is 2^17 ETH then maximum annual issuance is a bit below 2^21 ETH. Maximum annual issuance happens when a) all validators make perfect attestations (matching source, target, head, as well as consistent crosslink data), b) all attestations are included as fast as possible (in particular, no skip blocks), and c) there are no slashings.

```python
BASE_REWARD_FACTOR = 2**6
SLOTS_PER_EPOCH = 2**6
SECONDS_PER_SLOT = 6
BASE_REWARDS_PER_EPOCH = 5
GWEI_PER_ETH = 10**9
MAX_TOTAL_EFFECTIVE_BALANCE = 2**27 * GWEI_PER_ETH
TARGET_MAX_ISSUANCE = 2**21 * GWEI_PER_ETH

def integer_squareroot(n: int) -> int:
    """
    The largest integer ``x`` such that ``x**2`` is less than or equal to ``n``.
    """
    assert n >= 0
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

MAX_REWARDS_PER_EPOCH = MAX_TOTAL_EFFECTIVE_BALANCE * BASE_REWARD_FACTOR // integer_squareroot(MAX_TOTAL_EFFECTIVE_BALANCE) // BASE_REWARDS_PER_EPOCH
EPOCHS_PER_YEAR = 365.25*24*60*60 / (SECONDS_PER_SLOT * SLOTS_PER_EPOCH)
MAX_REWARDS_PER_YEAR = EPOCHS_PER_YEAR * MAX_REWARDS_PER_EPOCH * BASE_REWARDS_PER_EPOCH

print(MAX_REWARDS_PER_YEAR / TARGET_MAX_ISSUANCE)
```
2019-06-10 15:14:32 +01:00
Justin 9bb0f25f18
Update specs/core/0_beacon-chain.md
Co-Authored-By: NIC Lin <twedusuck@gmail.com>
2019-06-10 13:41:28 +01:00
Justin 36a6c1bf1f
Set MIN_ATTESTATION_INCLUSION_DELAY to 1
See item 7 of #1054. We should consider increasing the slot duration as well.
2019-06-09 21:30:42 +01:00
Justin Drake 565f61dfaa Cleanup containers 2019-06-09 20:41:21 +01:00
Justin Drake 4ee00c9cbd Address HW's comments 2019-06-09 11:03:38 +01:00
Justin Drake d1e589f11f Remove eth2 genesis in favour of genesis trigger 2019-06-08 19:00:50 +01:00
Carl Beekhuizen 60d9dc68c4
Apply suggestions from @djrtwo's code review 2019-06-05 21:49:30 +02:00
Carl Beekhuizen 38414c2e4e
Merge branch 'dev' into dankrad-patch-7
* dev:
  add  beaconblockheader back to toc
  Move crosslink above attestation data
  Change data structure to match beacon state order
  Reorganize data structures to mirror beacon state order
  Update 0_beacon-chain.md
2019-06-05 20:28:14 +02:00
Danny Ryan 1daff359ba
Merge pull request #1139 from terencechain/patch-76
Use get_total_balance for get_attestation_deltas
2019-06-05 10:14:28 -06:00
Danny Ryan 853c34eb60
add beaconblockheader back to toc 2019-06-05 09:50:15 -06:00
Carl Beekhuizen d761b6f041
Implements new SSZ types 2019-06-05 15:29:26 +02:00
Ivan Martinez c250296d8a
Move crosslink above attestation data 2019-06-05 15:07:50 +09:00
Ivan Martinez 65d2a50219
Change data structure to match beacon state order 2019-06-05 14:57:54 +09:00
Ivan Martinez e83500cef8
Reorganize data structures to mirror beacon state order 2019-06-05 14:52:09 +09:00
protolambda 9bdb18245e
remove tautological type definition 2019-06-04 18:22:42 +02:00
Diederik Loerakker fe9c708d83
Fix whitespace
Co-Authored-By: Danny Ryan <dannyjryan@gmail.com>
2019-06-04 15:31:20 +02:00
terence tsao 2246f1b934
Update 0_beacon-chain.md 2019-06-02 13:13:52 -07:00
protolambda e044305457
Merge branch 'dev' into ssz-impl-rework 2019-06-01 01:34:49 +02:00
Carl Beekhuizen 5155bc6c4f
Makes everything pass around 2019-05-30 22:57:18 +02:00
Danny Ryan f0314bec52
Merge branch 'dev' into JustinDrake-patch-13 2019-05-29 20:15:17 -06:00
Danny Ryan 2aea4b93d0
Merge pull request #1123 from ethereum/JustinDrake-patch-14
Avoid divisions by zero
2019-05-29 20:14:23 -06:00
Hsiao-Wei Wang 6ec59867ef
Fix linter errors 2019-05-30 09:53:46 +08:00
Justin 1c416541e1
Update 0_beacon-chain.md 2019-05-29 23:40:46 +03:00
Danny Ryan 6286fb3fb5
Merge branch 'dev' into JustinDrake-patch-13 2019-05-28 18:15:33 -06:00
protolambda 8737984e19
introduce back assert, modified to allow valid but non-effective calls 2019-05-28 16:05:25 +02:00
Carl Beekhuizen bfa45e06f0
merge dev -> d-p-7 2019-05-28 11:15:17 +02:00
protolambda 0e9a047b1d
Merge branch 'dev' into ssz-impl-rework 2019-05-28 00:42:35 +02:00
protolambda f3088884b3
Minor adjustments + getting the beacon spec doc ready 2019-05-27 20:29:53 +02:00
Danny Ryan d3d8b36365
Merge branch 'dev' into v06x-to-dev 2019-05-27 11:09:52 -06:00
Michael Sproul a82a6f9a1a
Sort attester slashing indices to avoid arbitrary ordering
Closes #1125
2019-05-27 17:36:20 +10:00
Justin cdfb886c22
Avoid divisions by zero
Possible fix to avoid four cases of divisions by zero:

* `return state.validator_registry[index].effective_balance // adjusted_quotient // BASE_REWARDS_PER_EPOCH`
* `rewards[index] += get_base_reward(state, index) * attesting_balance // total_balance`
* `validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance`
* `rewards[index] += base_reward * attesting_balance // committee_balance`

See also #1107.
2019-05-26 18:42:37 +03:00
vbuterin 3b4d9b7a85
Class-ified the type definitions 2019-05-25 16:14:52 -04:00
protolambda 81cb4a23b3
update some common usage of SSZ types, as a start 2019-05-25 00:10:06 +02:00
Justin d805fb5084
Simplify deposits 2019-05-25 00:35:17 +03:00
Carl Beekhuizen ac9564c2b7
Adds Insert-into-label functionality 2019-05-24 16:51:21 +02:00
Danny Ryan c13421a9a7
type hinting for fork version
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
2019-05-22 16:52:44 -04:00
protolambda 6b5f4b44ea
avoid zero constant for deposits fork-version, just default to it 2019-05-22 01:39:20 +02:00