Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Release v1.3.0-alpha.1 -- capella and 4844 prelease #3116

Merged
merged 165 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
63ab599
eip4844: update tx_peek_blob_versioned_hashes to match tx type as def…
protolambda Oct 5, 2022
c7d88b7
eip4844: update test type definition
protolambda Oct 5, 2022
2d08dc5
eip-4844: test tx_peek_blob_versioned_hashes
protolambda Oct 6, 2022
242e1b7
Rebase Capella on EIP-4844
Inphi Oct 20, 2022
f6f2474
Update specs/eip4844/beacon-chain.md
Inphi Oct 20, 2022
2ac57c7
Fix py setup
Inphi Oct 24, 2022
0488c0c
remove unchanged epoch processing section
Inphi Oct 24, 2022
459310f
Fix test_process_execution_payload
Inphi Oct 24, 2022
6d270cd
Add CAPELLA_FORK_EPOCH overrides
Inphi Oct 24, 2022
ca538f5
Update specs/eip4844/beacon-chain.md
Inphi Oct 25, 2022
3172095
Make pyspec disable withdrawal-functions in EIP4844
hwwhww Oct 26, 2022
e460005
Add tests for no-op functions
hwwhww Oct 26, 2022
60187e5
Add `test_process_withdrawals` no-op test
hwwhww Oct 26, 2022
14b3463
Consistent variable name in LC test
etan-status Oct 26, 2022
71775c6
EIP4844: Remove signed blobs
terencechain Oct 27, 2022
c399e11
Document how to derive fork context for LC gossip
etan-status Oct 27, 2022
af54c97
Consistently use `compute_sync_committee_period_at_slot`
etan-status Oct 27, 2022
5b6eb80
Clarify where LC proofs are rooted
etan-status Oct 27, 2022
cdaf7e8
Allow extending LC merkle proof tests
etan-status Oct 27, 2022
990866d
Rename LC test check from `root` to `beacon_root`
etan-status Oct 27, 2022
4fc8076
Also update test logic accordingly
etan-status Oct 27, 2022
e025aa9
Merge pull request #3061 from etan-status/lc-finalized
ralexstokes Oct 28, 2022
72b6abd
Merge pull request #3064 from etan-status/lc-periodatepoch
ralexstokes Oct 28, 2022
be3c774
Merge pull request #3065 from etan-status/lc-branchrootdocs
ralexstokes Oct 28, 2022
bab01d6
Merge pull request #3067 from etan-status/lc-synctestroot
ralexstokes Oct 28, 2022
5c66300
Use `suite_name` instead of `meta.yaml` for SSZ type
etan-status Oct 28, 2022
9dc1a17
Update `remerkleable` to 0.1.25
etan-status Oct 28, 2022
e453bfe
README.md: Fix broken links
nalepae Oct 29, 2022
332ad4c
Move `is_post_xxx` functions to new module
etan-status Oct 30, 2022
498a5b0
Merge pull request #3062 from terencechain/rm-signed-blobs
hwwhww Nov 1, 2022
826c20f
Capella: Add Gossip Topic bls_to_execution_change
ethDreamer Nov 1, 2022
87dcb83
Merge pull request #3063 from etan-status/lc-gossipdigests
hwwhww Nov 2, 2022
8788472
Update README.md
ralexstokes Nov 2, 2022
1c30bbb
Merge pull request #3071 from nalepae/patch-1
ralexstokes Nov 2, 2022
32107be
Merge pull request #3069 from etan-status/ci-remerkleable0125
ralexstokes Nov 2, 2022
86e1576
EIP4844: Update cryptography API (#3038)
asn-d6 Nov 3, 2022
7c016f3
Add testing KZG trusted setups generator tool and load the file durin…
hwwhww Sep 27, 2022
5a0d84e
int casting to avoid underflow
hwwhww Sep 27, 2022
3a49d62
Refactor `get_spec`
hwwhww Sep 27, 2022
b598617
Update testing trusted setups files
hwwhww Nov 3, 2022
b2d72a1
Fix type error in the inputs to hash_to_bls_field()
asn-d6 Nov 3, 2022
d958ed7
Implement withdrawals without queues
potuz Oct 28, 2022
88f4938
remove unnecessary constants
potuz Oct 28, 2022
f506087
rebase on top of develop
potuz Oct 31, 2022
7dbd50e
Reviewers' comments
potuz Oct 31, 2022
49a2519
lint
potuz Oct 31, 2022
c156ea6
linting and typo
potuz Oct 31, 2022
0f74ab5
type annotation
potuz Oct 31, 2022
5b92eae
type annotation
potuz Oct 31, 2022
ff1dd90
fix toc
potuz Oct 31, 2022
7e4d169
update minimal preset
potuz Oct 31, 2022
a14479a
g11tech review
potuz Nov 1, 2022
39e6ec5
lint
potuz Nov 1, 2022
ad36548
Fix auto-rebase errors
hwwhww Nov 3, 2022
26695a9
Merge pull request #3077 from asn-d6/type_fix_hash_to_bls_field
asn-d6 Nov 3, 2022
12404d0
fix for loop
potuz Nov 3, 2022
329bafa
dapplion's suggestions
potuz Nov 3, 2022
a09d617
right ret
potuz Nov 3, 2022
0b1f32e
Fix capella/block_processing tests
hwwhww Nov 3, 2022
494cefc
Fix sanity block tests
hwwhww Nov 3, 2022
b530dc0
Move old withdrawal epoch_processing tests to block_processing
hwwhww Nov 3, 2022
6e913ec
rename to latest_withdrawal_validator_index
potuz Nov 3, 2022
22f803a
name change and increment operator
potuz Nov 4, 2022
9973e9f
harden tests and add couple of cases
potuz Nov 4, 2022
e15b02d
lint
potuz Nov 4, 2022
8488fb7
Alex Stokes' review
potuz Nov 4, 2022
cd5567b
Update p2p-interface.md
ralexstokes Nov 4, 2022
1f68c57
Update specs/capella/p2p-interface.md
ethDreamer Nov 4, 2022
6c1fa0a
Update specs/capella/p2p-interface.md
ethDreamer Nov 4, 2022
355ca29
Update specs/capella/p2p-interface.md
ethDreamer Nov 4, 2022
c8d1614
Apply suggestions from code review
ralexstokes Nov 4, 2022
e1e37de
Merge pull request #3075 from ethDreamer/gossip_bls_to_execution_change
ralexstokes Nov 4, 2022
b5ecf44
add note about packing BLS to execution changes into a block
ralexstokes Nov 4, 2022
6f0a7ef
Merge pull request #3080 from ethereum/ralexstokes-patch-1
hwwhww Nov 6, 2022
72544d5
Merge pull request #3081 from ethereum/add-capella-bls-to-exec-change…
hwwhww Nov 6, 2022
3fc1ebc
Move some Capella operation tests to sanity/blocks tests
hwwhww Nov 7, 2022
cfad029
Merge branch 'dev' into lc-prooftest
etan-status Nov 7, 2022
dac756e
Minor clean up
hwwhww Nov 7, 2022
37c30ad
Merge branch 'dev' into sf-ispostfork
etan-status Nov 7, 2022
b7dfd5a
Merge pull request #3027 from ethereum/eip-4844-fee-ssz-fix
hwwhww Nov 7, 2022
544ae28
Merge pull request #3016 from ethereum/gen_kzg_trusted_setups
hwwhww Nov 7, 2022
95ee291
Merge branch 'dev' into pr3052
hwwhww Nov 7, 2022
f010de0
Remove domain blobs sidecar
terencechain Nov 7, 2022
851b9a5
Merge pull request #3083 from terencechain/rm-domain-blobs
hwwhww Nov 7, 2022
2f89f50
Danny's review 1st pass
potuz Nov 7, 2022
ac670e2
add phase0 sentence regarding process slots
potuz Nov 7, 2022
99e2704
make tests pass
potuz Nov 7, 2022
8bb1751
Add note to Capella validator guide about BLS to execution change
ralexstokes Nov 7, 2022
91de8a0
Fix slot checks in light client p2p spec
michaelsproul Nov 8, 2022
e3e73a8
Add Capella fork version
Inphi Nov 8, 2022
cb9159f
EIP4844: Add block and sidecar retrival by root
terencechain Nov 8, 2022
c447662
Fix `BeaconBlocksByRootV2` for pre-4844 support
terencechain Nov 8, 2022
dae1011
Fix typos
michaelsproul Nov 8, 2022
8f42e48
Add extra %
potuz Nov 8, 2022
710b124
fix last commit
potuz Nov 9, 2022
087f785
PR feedback from @djrtwo
hwwhww Nov 9, 2022
579f8fd
EIP4844: Explicitly mention old gossip validations for block
terencechain Nov 9, 2022
7f266bc
Use next_validator_withdrawal_index
potuz Nov 10, 2022
6179085
Merge branch 'withdrawals_without_queues' of github-potuz:potuz/conse…
potuz Nov 10, 2022
3d82a19
whitespace
potuz Nov 10, 2022
c7d7333
lint
potuz Nov 10, 2022
9978573
Merge branch 'dev' into sf-ispostfork
etan-status Nov 10, 2022
76157f9
Rename `phases.py` to `forks.py`; add `ValueError` check
etan-status Nov 10, 2022
be098b6
Update specs/eip4844/p2p-interface.md
ralexstokes Nov 10, 2022
0f93e9a
Update specs/capella/validator.md
ralexstokes Nov 10, 2022
be85e93
Update specs/capella/validator.md
ralexstokes Nov 10, 2022
37996fc
Merge pull request #3068 from potuz/withdrawals_without_queues
djrtwo Nov 10, 2022
0e7d355
minor copy edits
djrtwo Nov 10, 2022
4b573f8
Merge pull request #3091 from terencechain/patch-138
djrtwo Nov 10, 2022
a59dd37
Merge remote-tracking branch 'origin/dev' into inphi/eip4844-rebase
Inphi Nov 10, 2022
a04f06b
Fix merge conflict
Inphi Nov 10, 2022
d4a9b97
Merge pull request #3084 from ethereum/validator-note-for-bls-change
djrtwo Nov 10, 2022
bed1df0
Remove withdrawal_queue from BeaconState upgrade
Inphi Nov 10, 2022
2fbb1ed
fix test_process_withdrawals
Inphi Nov 10, 2022
fcafdc1
remove eip4844 partial/full withdrawwals tests
Inphi Nov 10, 2022
67ba28c
remove eip4844 epoch_processing package
Inphi Nov 10, 2022
104cba0
replace get_blobs_and_kzg_commitments
Inphi Nov 11, 2022
897b979
Further clarify light client slot checks
michaelsproul Nov 11, 2022
e2a2d68
Added a comment to support pre-fork-epoch
terencechain Nov 11, 2022
faf3083
Merge pull request #3086 from michaelsproul/light-client-p2p-fix
ralexstokes Nov 11, 2022
078bba2
clarify deprecation of `beacon_block` gossip topic in 4844
ralexstokes Nov 8, 2022
38669d4
Update specs/eip4844/p2p-interface.md
ralexstokes Nov 11, 2022
a6c4b9a
Merge pull request #3072 from etan-status/sf-ispostfork
hwwhww Nov 11, 2022
6327ffa
rename excess_blobs
Inphi Nov 11, 2022
cd1e113
excess_data_gas uint256
Inphi Nov 11, 2022
3df1371
Merge remote-tracking branch 'origin/dev' into inphi/eip4844-rebase
Inphi Nov 11, 2022
3714446
Fix merge conflict
Inphi Nov 11, 2022
ff34006
Refactor `verify_kzg_proof()` to receive bytes (used in precompile)
asn-d6 Nov 9, 2022
fcac0b5
Clarify which functions are public and provided by the KZG library
asn-d6 Nov 9, 2022
bbc3ec0
Fix typos
terencechain Nov 13, 2022
4cb6fd1
Merge pull request #3101 from terencechain/misc-cleanups
djrtwo Nov 14, 2022
11a037f
Merge pull request #3089 from terencechain/beacon-block-and-blobs-sid…
hwwhww Nov 15, 2022
a5f8a15
Clarify how to transition gossip
ralexstokes Nov 15, 2022
b737e53
fix state upgrade
tbenr Nov 16, 2022
e8e860e
make a gossip condition
realbigsean Nov 16, 2022
620943b
Update specs/eip4844/fork.md
tbenr Nov 16, 2022
f1d4c90
Merge branch 'dev' into pr3052
hwwhww Nov 17, 2022
30dce7f
Apply suggestions from code review
hwwhww Nov 17, 2022
1623c75
Merge pull request #3106 from tbenr/fix-state-upgrade
hwwhww Nov 17, 2022
b6df4b5
Merge pull request #3066 from etan-status/lc-prooftest
hwwhww Nov 17, 2022
ee0e2a0
Merge branch 'dev' into pr3052
hwwhww Nov 17, 2022
de789e2
Merge pull request #3090 from ethereum/4844-topic-dep
djrtwo Nov 17, 2022
78f0e03
Merge pull request #3052 from Inphi/inphi/eip4844-rebase
hwwhww Nov 17, 2022
2a40b51
Add EIP4844 testgen
hwwhww Nov 10, 2022
2f0157a
Fix auto-rebase leftover
hwwhww Nov 10, 2022
0c88855
Add Capella and EIP4844 fork random tests
hwwhww Nov 10, 2022
438a7e5
Conver `roots_of_unity_brp` to integers
hwwhww Nov 11, 2022
5c5639f
fix lint
hwwhww Nov 15, 2022
812618c
Fix fork test verifier
hwwhww Nov 17, 2022
dd8b670
Add note comment
hwwhww Nov 17, 2022
d12c2a3
Add EIP4844 random tests
hwwhww Nov 17, 2022
8824259
Fix --preset-list argument and enhance error output
hwwhww Nov 10, 2022
30e9758
Merge pull request #3108 from realbigsean/validate-blobs-sidecar-in-g…
djrtwo Nov 17, 2022
46c0447
Merge pull request #3110 from ethereum/eip4844-test-vectors
hwwhww Nov 18, 2022
a1d259a
Merge pull request #3111 from ethereum/testgen-fix
hwwhww Nov 18, 2022
aac1af7
Add `test_fail_double_bls_changes_in_same_block`
hwwhww Nov 18, 2022
82007c3
bump VERSION.txt
djrtwo Nov 18, 2022
757d320
Merge pull request #3117 from ethereum/bump-version
djrtwo Nov 18, 2022
b78bd1f
Add other double-operations (attestations, deposits) tests
hwwhww Nov 18, 2022
9f4adfd
Add `test_invalid_two_bls_changes_of_different_addresses_same_validat…
hwwhww Nov 18, 2022
fbb13f0
Apply naming suggestion from @djrtwo
hwwhww Nov 18, 2022
c345f30
Merge pull request #3112 from ethereum/double-bls-changes
hwwhww Nov 18, 2022
b71ad2f
Add EIP4844 sync tests
hwwhww Nov 18, 2022
a456271
Merge pull request #3097 from asn-d6/verify_kzg_proof_bytes_api
asn-d6 Nov 18, 2022
208da34
Merge pull request #3119 from ethereum/eip4844-sync-testgen
hwwhww Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ CURRENT_DIR = ${CURDIR}
LINTER_CONFIG_FILE = $(CURRENT_DIR)/linter.ini
GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.txt

SCRIPTS_DIR = ${CURRENT_DIR}/scripts

export DAPP_SKIP_BUILD:=1
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
Expand Down Expand Up @@ -195,6 +197,14 @@ $(TEST_VECTOR_DIR):
$(TEST_VECTOR_DIR)/:
$(info ignoring duplicate tests dir)

gen_kzg_setups:
cd $(SCRIPTS_DIR); \
if ! test -d venv; then python3 -m venv venv; fi; \
. venv/bin/activate; \
pip3 install -r requirements.txt; \
python3 ./gen_kzg_trusted_setups.py --secret=1337 --length=4 --output-dir ${CURRENT_DIR}/presets/minimal/trusted_setups; \
python3 ./gen_kzg_trusted_setups.py --secret=1337 --length=4096 --output-dir ${CURRENT_DIR}/presets/mainnet/trusted_setups

# For any generator, build it using the run_generator function.
# (creation of output dir is a dependency)
gen_%: $(TEST_VECTOR_DIR)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Join the chat at https://discord.gg/qGpsxSA](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://discord.gg/qGpsxSA) [![Join the chat at https://gitter.im/ethereum/sharding](https://badges.gitter.im/ethereum/sharding.svg)](https://gitter.im/ethereum/sharding?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

To learn more about proof-of-stake and sharding, see the [PoS FAQ](https://eth.wiki/en/concepts/proof-of-stake-faqs), [sharding FAQ](https://eth.wiki/sharding/Sharding-FAQs) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).
To learn more about proof-of-stake and sharding, see the [PoS documentation](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/), [sharding documentation](https://ethereum.org/en/upgrades/sharding/) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).

This repository hosts the current Ethereum proof-of-stake specifications. Discussions about design rationale and proposed changes can be brought up and discussed as issues. Solidified, agreed-upon changes to the spec can be made through pull requests.

Expand Down
12 changes: 0 additions & 12 deletions presets/mainnet/capella.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
# Mainnet preset - Capella

# Misc
# ---------------------------------------------------------------
# 2**8 (= 256) withdrawals
MAX_PARTIAL_WITHDRAWALS_PER_EPOCH: 256


# State list lengths
# ---------------------------------------------------------------
# 2**40 (= 1,099,511,627,776) withdrawals
WITHDRAWAL_QUEUE_LIMIT: 1099511627776


# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16)
MAX_BLS_TO_EXECUTION_CHANGES: 16


# Execution
# ---------------------------------------------------------------
# 2**4 (= 16) withdrawals
Expand Down
1 change: 1 addition & 0 deletions presets/mainnet/trusted_setups/testing_trusted_setups.json

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions presets/minimal/capella.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# Minimal preset - Capella

# Misc
# ---------------------------------------------------------------
# [customized] 16 for more interesting tests at low validator count
MAX_PARTIAL_WITHDRAWALS_PER_EPOCH: 16


# State list lengths
# ---------------------------------------------------------------
# 2**40 (= 1,099,511,627,776) withdrawals
WITHDRAWAL_QUEUE_LIMIT: 1099511627776


# Max operations per block
# ---------------------------------------------------------------
# 2**4 (= 16)
Expand All @@ -20,5 +8,5 @@ MAX_BLS_TO_EXECUTION_CHANGES: 16

# Execution
# ---------------------------------------------------------------
# [customized] Lower than MAX_PARTIAL_WITHDRAWALS_PER_EPOCH so not all processed in one block
MAX_WITHDRAWALS_PER_PAYLOAD: 8
# [customized] 2**2 (= 4)
MAX_WITHDRAWALS_PER_PAYLOAD: 4
1 change: 1 addition & 0 deletions presets/minimal/trusted_setups/testing_trusted_setups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"setup_G1": ["0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb", "0x854262641262cb9e056a8512808ea6864d903dbcad713fd6da8dddfa5ce40d85612c912063ace060ed8c4bf005bab839", "0x86f708eee5ae0cf40be36993e760d9cb3b2371f22db3209947c5d21ea68e55186b30871c50bf11ef29e5248bf42d5678", "0x94f9c0bafb23cbbf34a93a64243e3e0f934b57593651f3464de7dc174468123d9698f1b9dfa22bb5b6eb96eae002f29f"], "setup_G2": ["0x93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8", "0x99aca9fb2f7760cecb892bf7262c176b334824f5727f680bba701a33e322cb6667531410dfc7c8e4321a3f0ea8af48cb1436638a2093123f046f0f504cc2a864825542873edbbc5d7ed17af125a4f2cf6433c6f4f61b81173726981dd989761d", "0x88e2e982982bf8231e747e9dfcd14c05bd02623d1332734d2af26246c6869fb56ee6c994843f593178a040495ba61f4a083b0e18110b1d9f5224783d8f9a895e8ee744e87929430e9ba96bd29251cbf61240b256d1525600f3d562894d93d659", "0xa2d33775e3d9e6af0d1b27d389e6c021a578e617a3d6627686db6288d4b3dffd7a847a00f7ef01828b7f42885b660e4204923402aca18fbae74ccd4e9c50dd8c2281b38dc09c022342ed1ac695d53f7081cb21f05fdfc0a3508c04759196fcd3"], "setup_G1_lagrange": ["0x91131b2e3c1e5f0b51df8970e67080032f411571b66d301436c46f25bbfddf9ca16756430dc470bdb0d85b47fedcdbc1", "0x934d35b2a46e169915718b77127b0d4efbacdad7fdde4593af7d21d37ebcb77fe6c8dde6b8a9537854d70ef1f291a585", "0x9410ca1d0342fe7419f02194281df45e1c1ff42fd8b439de5644cc312815c21ddd2e3eeb63fb807cf837e68b76668bd5", "0xb163df7e9baeb60f69b6ee5faa538c3a564b62eb8cde6a3616083c8cb2171eedd583c9143e7e916df59bf27da5e024e8"], "roots_of_unity": [1, 3465144826073652318776269530687742778270252468765361963008, 52435875175126190479447740508185965837690552500527637822603658699938581184512, 52435875175126190475982595682112313518914282969839895044333406231173219221505]}
36 changes: 36 additions & 0 deletions scripts/gen_kzg_trusted_setups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
from pathlib import Path

from eth2spec.utils.kzg import (
dump_kzg_trusted_setup_files,
)


if __name__ == '__main__':
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
"--secret",
dest="secret",
type=int,
required=True,
help='the secret of trusted setup',
)
parser.add_argument(
"--length",
dest="length",
type=int,
required=True,
help='the length of trusted setup',
)
parser.add_argument(
"-o",
"--output-dir",
dest="output_dir",
required=True,
help='the output directory',
)
args = parser.parse_args()

dump_kzg_trusted_setup_files(args.secret, args.length, args.output_dir)
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../[generator]
96 changes: 71 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import re
import string
import textwrap
from typing import Dict, NamedTuple, List, Sequence, Optional, TypeVar
from typing import Dict, NamedTuple, List, Sequence, Optional, TypeVar, Tuple
from abc import ABC, abstractmethod
import ast
import subprocess
import sys
import copy
from collections import OrderedDict
import json


# NOTE: have to programmatically include third-party dependencies in `setup.py`.
Expand Down Expand Up @@ -121,7 +122,7 @@ def _get_self_type_from_source(source: str) -> Optional[str]:
return args[0].annotation.id


def _get_class_info_from_source(source: str) -> (str, Optional[str]):
def _get_class_info_from_source(source: str) -> Tuple[str, Optional[str]]:
class_def = ast.parse(source).body[0]
base = class_def.bases[0]
if isinstance(base, ast.Name):
Expand All @@ -140,6 +141,28 @@ def _is_constant_id(name: str) -> bool:
return all(map(lambda c: c in string.ascii_uppercase + '_' + string.digits, name[1:]))


def _load_kzg_trusted_setups(preset_name):
"""
[TODO] it's not the final mainnet trusted setup.
We will update it after the KZG ceremony.
"""
file_path = str(Path(__file__).parent) + '/presets/' + preset_name + '/trusted_setups/testing_trusted_setups.json'

with open(file_path, 'r') as f:
json_data = json.load(f)

trusted_setup_G1 = json_data['setup_G1']
trusted_setup_G2 = json_data['setup_G2']
trusted_setup_G1_lagrange = json_data['setup_G1_lagrange']
roots_of_unity = json_data['roots_of_unity']

return trusted_setup_G1, trusted_setup_G2, trusted_setup_G1_lagrange, roots_of_unity

ALL_KZG_SETUPS = {
'minimal': _load_kzg_trusted_setups('minimal'),
'mainnet': _load_kzg_trusted_setups('mainnet')
}

ETH2_SPEC_COMMENT_PREFIX = "eth2spec:"


Expand Down Expand Up @@ -167,7 +190,16 @@ def _parse_value(name: str, typed_value: str, type_hint: Optional[str]=None) ->
return VariableDefinition(type_name=type_name, value=typed_value[i+1:-1], comment=comment, type_hint=type_hint)


def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) -> SpecObject:
def _update_constant_vars_with_kzg_setups(constant_vars, preset_name):
comment = "noqa: E501"
kzg_setups = ALL_KZG_SETUPS[preset_name]
constant_vars['KZG_SETUP_G1'] = VariableDefinition(constant_vars['KZG_SETUP_G1'].value, str(kzg_setups[0]), comment, None)
constant_vars['KZG_SETUP_G2'] = VariableDefinition(constant_vars['KZG_SETUP_G2'].value, str(kzg_setups[1]), comment, None)
constant_vars['KZG_SETUP_LAGRANGE'] = VariableDefinition(constant_vars['KZG_SETUP_LAGRANGE'].value, str(kzg_setups[2]), comment, None)
constant_vars['ROOTS_OF_UNITY'] = VariableDefinition(constant_vars['ROOTS_OF_UNITY'].value, str(kzg_setups[3]), comment, None)


def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], preset_name=str) -> SpecObject:
functions: Dict[str, str] = {}
protocols: Dict[str, ProtocolDefinition] = {}
constant_vars: Dict[str, VariableDefinition] = {}
Expand Down Expand Up @@ -232,7 +264,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) ->

if not _is_constant_id(name):
# Check for short type declarations
if value.startswith(("uint", "Bytes", "ByteList", "Union", "Vector", "List")):
if value.startswith(("uint", "Bytes", "ByteList", "Union", "Vector", "List", "ByteVector")):
custom_types[name] = value
continue

Expand All @@ -256,6 +288,10 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) ->
if comment == "skip":
should_skip = True

# Load KZG trusted setup from files
if any('KZG_SETUP' in name for name in constant_vars):
_update_constant_vars_with_kzg_setups(constant_vars, preset_name)

return SpecObject(
functions=functions,
protocols=protocols,
Expand Down Expand Up @@ -582,15 +618,13 @@ def imports(cls, preset_name: str):
#
# EIP4844SpecBuilder
#
class EIP4844SpecBuilder(BellatrixSpecBuilder):
class EIP4844SpecBuilder(CapellaSpecBuilder):
fork: str = EIP4844

@classmethod
def imports(cls, preset_name: str):
return super().imports(preset_name) + f'''
from eth2spec.utils import kzg
from eth2spec.bellatrix import {preset_name} as bellatrix
from eth2spec.utils.ssz.ssz_impl import serialize as ssz_serialize
from eth2spec.capella import {preset_name} as capella
'''


Expand All @@ -603,33 +637,45 @@ def preparations(cls):
@classmethod
def sundry_functions(cls) -> str:
return super().sundry_functions() + '\n\n' + '''
# TODO: for mainnet, load pre-generated trusted setup file to reduce building time.
# TESTING_FIELD_ELEMENTS_PER_BLOB is hardcoded copy from minimal presets
TESTING_FIELD_ELEMENTS_PER_BLOB = 4
TESTING_SECRET = 1337
TESTING_KZG_SETUP_G1 = kzg.generate_setup(bls.G1, TESTING_SECRET, TESTING_FIELD_ELEMENTS_PER_BLOB)
TESTING_KZG_SETUP_G2 = kzg.generate_setup(bls.G2, TESTING_SECRET, TESTING_FIELD_ELEMENTS_PER_BLOB)
TESTING_KZG_SETUP_LAGRANGE = kzg.get_lagrange(TESTING_KZG_SETUP_G1)
#
# Temporarily disable Withdrawals functions for EIP4844 testnets
#

KZG_SETUP_G1 = [bls.G1_to_bytes48(p) for p in TESTING_KZG_SETUP_G1]
KZG_SETUP_G2 = [bls.G2_to_bytes96(p) for p in TESTING_KZG_SETUP_G2]
KZG_SETUP_LAGRANGE = TESTING_KZG_SETUP_LAGRANGE
ROOTS_OF_UNITY = kzg.compute_roots_of_unity(TESTING_FIELD_ELEMENTS_PER_BLOB)

def no_op(fn): # type: ignore
def wrapper(*args, **kw): # type: ignore
return None
return wrapper


def get_empty_list_result(fn): # type: ignore
def wrapper(*args, **kw): # type: ignore
return []
return wrapper

def retrieve_blobs_sidecar(slot: Slot, beacon_block_root: Root) -> BlobsSidecar:
pass'''

process_withdrawals = no_op(process_withdrawals)
process_bls_to_execution_change = no_op(process_bls_to_execution_change)
get_expected_withdrawals = get_empty_list_result(get_expected_withdrawals)


#
# End
#

def retrieve_blobs_sidecar(slot: Slot, beacon_block_root: Root) -> Optional[BlobsSidecar]:
return "TEST"'''

@classmethod
def hardcoded_custom_type_dep_constants(cls, spec_object) -> str:
constants = {
'BYTES_PER_FIELD_ELEMENT': spec_object.constant_vars['BYTES_PER_FIELD_ELEMENT'].value,
'FIELD_ELEMENTS_PER_BLOB': spec_object.preset_vars['FIELD_ELEMENTS_PER_BLOB'].value,
'MAX_BLOBS_PER_BLOCK': spec_object.preset_vars['MAX_BLOBS_PER_BLOCK'].value,
}
return {**super().hardcoded_custom_type_dep_constants(spec_object), **constants}



spec_builders = {
builder.fork: builder
for builder in (Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, EIP4844SpecBuilder)
Expand Down Expand Up @@ -880,7 +926,7 @@ def _build_spec(preset_name: str, fork: str,
source_files: Sequence[Path], preset_files: Sequence[Path], config_file: Path) -> str:
preset = load_preset(preset_files)
config = load_config(config_file)
all_specs = [get_spec(spec, preset, config) for spec in source_files]
all_specs = [get_spec(spec, preset, config, preset_name) for spec in source_files]

spec_object = all_specs[0]
for value in all_specs[1:]:
Expand Down Expand Up @@ -967,7 +1013,7 @@ def finalize_options(self):
specs/bellatrix/p2p-interface.md
sync/optimistic.md
"""
if self.spec_fork == CAPELLA:
if self.spec_fork in (CAPELLA, EIP4844):
self.md_doc_paths += """
specs/capella/beacon-chain.md
specs/capella/fork.md
Expand Down Expand Up @@ -1131,7 +1177,7 @@ def run(self):
"pycryptodome==3.15.0",
"py_ecc==6.0.0",
"milagro_bls_binding==1.9.0",
"remerkleable==0.1.24",
"remerkleable==0.1.25",
RUAMEL_YAML_VERSION,
"lru-dict==1.1.8",
MARKO_VERSION,
Expand Down
6 changes: 3 additions & 3 deletions specs/altair/light-client/full-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def create_light_client_update(state: BeaconState,
header = state.latest_block_header.copy()
header.state_root = hash_tree_root(state)
assert hash_tree_root(header) == hash_tree_root(block.message)
update_signature_period = compute_sync_committee_period(compute_epoch_at_slot(block.message.slot))
update_signature_period = compute_sync_committee_period_at_slot(block.message.slot)

assert attested_state.slot == attested_state.latest_block_header.slot
attested_header = attested_state.latest_block_header.copy()
attested_header.state_root = hash_tree_root(attested_state)
assert hash_tree_root(attested_header) == block.message.parent_root
update_attested_period = compute_sync_committee_period(compute_epoch_at_slot(attested_header.slot))
update_attested_period = compute_sync_committee_period_at_slot(attested_header.slot)

# `next_sync_committee` is only useful if the message is signed by the current sync committee
if update_attested_period == update_signature_period:
Expand Down Expand Up @@ -133,7 +133,7 @@ def create_light_client_update(state: BeaconState,
Full nodes SHOULD provide the best derivable `LightClientUpdate` (according to `is_better_update`) for each sync committee period covering any epochs in range `[max(ALTAIR_FORK_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOCK_REQUESTS), current_epoch]` where `current_epoch` is defined by the current wall-clock time. Full nodes MAY also provide `LightClientUpdate` for other sync committee periods.

- `LightClientUpdate` are assigned to sync committee periods based on their `attested_header.slot`
- `LightClientUpdate` are only considered if `compute_sync_committee_period(compute_epoch_at_slot(update.attested_header.slot)) == compute_sync_committee_period(compute_epoch_at_slot(update.signature_slot))`
- `LightClientUpdate` are only considered if `compute_sync_committee_period_at_slot(update.attested_header.slot) == compute_sync_committee_period_at_slot(update.signature_slot)`
- Only `LightClientUpdate` with `next_sync_committee` as selected by fork choice are provided, regardless of ranking by `is_better_update`. To uniquely identify a non-finalized sync committee fork, all of `period`, `current_sync_committee` and `next_sync_committee` need to be incorporated, as sync committees may reappear over time.

### `create_light_client_finality_update`
Expand Down
Loading