From af0d302398589d35f4ba2180946ada9cb5e763cd Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 22 Mar 2021 18:37:32 +0200 Subject: [PATCH 1/3] Use the latest bootstrap nodes for Prater --- vendor/eth2-testnets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/eth2-testnets b/vendor/eth2-testnets index 192c1b48e..463d414cd 160000 --- a/vendor/eth2-testnets +++ b/vendor/eth2-testnets @@ -1 +1 @@ -Subproject commit 192c1b48ea5ff4adb4e6ef7d2a9e5f82fb5ffd72 +Subproject commit 463d414cd7d2de6c7985a1ab38f932b02e390187 From 85289269d160c5b89735df8eacc26540e07afce7 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 17 Mar 2021 13:35:59 +0000 Subject: [PATCH 2/3] increase block proposal speed with many validators (#2423) * increase block proposal speed with many validators * document CookedSig rationale --- Makefile | 4 ++-- beacon_chain/beacon_node_types.nim | 2 +- .../attestation_pool.nim | 11 ++++++----- beacon_chain/spec/crypto.nim | 18 +++++++++++++++++- research/block_sim.nim | 4 ++-- research/state_sim.nim | 4 ++-- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index aad09665a..c3993a6b3 100644 --- a/Makefile +++ b/Makefile @@ -269,8 +269,8 @@ ifeq ($(DISABLE_TEST_FIXTURES_SCRIPT), 0) endif for TEST_BINARY in $(TEST_BINARIES); do \ PARAMS=""; \ - if [[ "$${TEST_BINARY}" == "state_sim" ]]; then PARAMS="--validators=3000 --slots=128"; \ - elif [[ "$${TEST_BINARY}" == "block_sim" ]]; then PARAMS="--validators=3000 --slots=128"; \ + if [[ "$${TEST_BINARY}" == "state_sim" ]]; then PARAMS="--validators=6000 --slots=128"; \ + elif [[ "$${TEST_BINARY}" == "block_sim" ]]; then PARAMS="--validators=6000 --slots=128"; \ fi; \ echo -e "\nRunning $${TEST_BINARY} $${PARAMS}\n"; \ build/$${TEST_BINARY} $${PARAMS} || { echo -e "\n$${TEST_BINARY} $${PARAMS} failed; Aborting."; exit 1; }; \ diff --git a/beacon_chain/beacon_node_types.nim b/beacon_chain/beacon_node_types.nim index 2afe7b465..83711e2de 100644 --- a/beacon_chain/beacon_node_types.nim +++ b/beacon_chain/beacon_node_types.nim @@ -30,7 +30,7 @@ type ## added to the aggregate meaning that only non-overlapping aggregates may ## be further combined. aggregation_bits*: CommitteeValidatorsBits - aggregate_signature*: ValidatorSig + aggregate_signature*: CookedSig AttestationEntry* = object ## Each entry holds the known signatures for a particular, distinct vote diff --git a/beacon_chain/consensus_object_pools/attestation_pool.nim b/beacon_chain/consensus_object_pools/attestation_pool.nim index 2f1bcd97a..689c527da 100644 --- a/beacon_chain/consensus_object_pools/attestation_pool.nim +++ b/beacon_chain/consensus_object_pools/attestation_pool.nim @@ -11,7 +11,7 @@ import # Standard libraries std/[options, tables, sequtils], # Status libraries - chronicles, stew/[byteutils], json_serialization/std/sets as jsonSets, + chronicles, stew/byteutils, json_serialization/std/sets as jsonSets, # Internal ../spec/[beaconstate, datatypes, crypto, digest], ../ssz/merkleization, @@ -176,9 +176,10 @@ proc addAttestation*(pool: var AttestationPool, let attestationsSeen = addr pool.candidates[candidateIdx.get] + # Only attestestions with valid signatures get here validation = Validation( aggregation_bits: attestation.aggregation_bits, - aggregate_signature: attestation.signature) + aggregate_signature: load(attestation.signature).get.CookedSig) var found = false for a in attestationsSeen.attestations.mitems(): @@ -281,7 +282,7 @@ iterator attestations*(pool: AttestationPool, slot: Option[Slot], yield Attestation( aggregation_bits: validation.aggregation_bits, data: entry.data, - signature: validation.aggregate_signature + signature: validation.aggregate_signature.exportRaw ) func getAttestationDataKey(ad: AttestationData): AttestationDataKey = @@ -377,7 +378,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool, attestation = Attestation( aggregation_bits: a.validations[0].aggregation_bits, data: a.data, - signature: a.validations[0].aggregate_signature + signature: a.validations[0].aggregate_signature.exportRaw ) agg {.noInit.}: AggregateSignature @@ -448,7 +449,7 @@ proc getAggregatedAttestation*(pool: AttestationPool, attestation = Attestation( aggregation_bits: a.validations[0].aggregation_bits, data: a.data, - signature: a.validations[0].aggregate_signature + signature: a.validations[0].aggregate_signature.exportRaw ) agg {.noInit.}: AggregateSignature diff --git a/beacon_chain/spec/crypto.nim b/beacon_chain/spec/crypto.nim index 9761122c9..f2cee59cc 100644 --- a/beacon_chain/spec/crypto.nim +++ b/beacon_chain/spec/crypto.nim @@ -68,6 +68,11 @@ type SomeSig* = TrustedSig | ValidatorSig + CookedSig* = distinct blscurve.Signature ## \ + ## Allows loading in an atttestation or other message's signature once across + ## all its computations, rather than repeatedly re-loading it each time it is + ## referenced. This primarily currently serves the attestation pool. + export AggregateSignature # API @@ -116,11 +121,19 @@ func init*(agg: var AggregateSignature, sig: ValidatorSig) {.inline.}= ## This assumes that the signature is valid agg.init(sig.load().get()) -func aggregate*(agg: var AggregateSignature, sig: ValidatorSig) {.inline.}= +func init*(agg: var AggregateSignature, sig: CookedSig) {.inline.}= + ## Initializes an aggregate signature context + agg.init(blscurve.Signature(sig)) + +proc aggregate*(agg: var AggregateSignature, sig: ValidatorSig) {.inline.}= ## Aggregate two Validator Signatures ## Both signatures must be valid agg.aggregate(sig.load.get()) +proc aggregate*(agg: var AggregateSignature, sig: CookedSig) {.inline.}= + ## Aggregate two Validator Signatures + agg.aggregate(blscurve.Signature(sig)) + func finish*(agg: AggregateSignature): ValidatorSig {.inline.}= ## Canonicalize an AggregateSignature into a signature var sig: blscurve.Signature @@ -226,6 +239,9 @@ template toRaw*(x: TrustedSig): auto = func toHex*(x: BlsCurveType): string = toHex(toRaw(x)) +func exportRaw*(x: CookedSig): ValidatorSig = + ValidatorSig(blob: blscurve.Signature(x).exportRaw()) + func fromRaw*(T: type ValidatorPrivKey, bytes: openArray[byte]): BlsResult[T] = var val: SecretKey if val.fromBytes(bytes): diff --git a/research/block_sim.nim b/research/block_sim.nim index 54bed8176..4af95c68f 100644 --- a/research/block_sim.nim +++ b/research/block_sim.nim @@ -50,8 +50,8 @@ proc gauss(r: var Rand; mu = 0.0; sigma = 1.0): float = result = mu + sigma * (b / a) # TODO confutils is an impenetrable black box. how can a help text be added here? -cli do(slots = SLOTS_PER_EPOCH * 6, - validators = SLOTS_PER_EPOCH * 200, # One per shard is minimum +cli do(slots = SLOTS_PER_EPOCH * 5, + validators = SLOTS_PER_EPOCH * 400, # One per shard is minimum attesterRatio {.desc: "ratio of validators that attest in each round"} = 0.82, blockRatio {.desc: "ratio of slots with blocks"} = 1.0, replay = true): diff --git a/research/state_sim.nim b/research/state_sim.nim index cbe6a3d92..92a731ae9 100644 --- a/research/state_sim.nim +++ b/research/state_sim.nim @@ -33,8 +33,8 @@ proc writeJson*(fn, v: auto) = defer: close(f) Json.saveFile(fn, v, pretty = true) -cli do(slots = SLOTS_PER_EPOCH * 6, - validators = SLOTS_PER_EPOCH * 200, # One per shard is minimum +cli do(slots = SLOTS_PER_EPOCH * 5, + validators = SLOTS_PER_EPOCH * 400, # One per shard is minimum json_interval = SLOTS_PER_EPOCH, write_last_json = false, prefix: int = 0, From 25695d1e4fb8e0b7ce017586ea82cc0a62dd0919 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 22 Mar 2021 19:25:34 +0200 Subject: [PATCH 3/3] v1.0.11 --- CHANGELOG.md | 6 ++++++ beacon_chain/version.nim | 2 +- docker/dist/README.md | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d71277c16..ee103df1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +2021-03-10 v1.0.11 +================== + +This is a minor release adding support for connecting to the Prater testnet. + + 2021-03-10 v1.0.10 ================== diff --git a/beacon_chain/version.nim b/beacon_chain/version.nim index 78a0042e2..c3f21da94 100644 --- a/beacon_chain/version.nim +++ b/beacon_chain/version.nim @@ -9,7 +9,7 @@ when not defined(nimscript): const versionMajor* = 1 versionMinor* = 0 - versionBuild* = 10 + versionBuild* = 11 versionBlob* = "stateofus" # Single word - ends up in the default graffitti diff --git a/docker/dist/README.md b/docker/dist/README.md index 30cf3e82e..c9763aaad 100644 --- a/docker/dist/README.md +++ b/docker/dist/README.md @@ -67,3 +67,13 @@ All the same conventions apply: WEB3_URL="ws://localhost:8545" ./run-mainnet-node.sh --max-peers=150 ``` +## Running a Prater node + +`run-prater-beacon-node.sh` is a similar script intended for connecting to the Prater +testnet. All the same conventions apply: + +```bash +# using a local Geth instance +WEB3_URL="ws://localhost:8545" ./run-prater-node.sh --max-peers=150 +``` +