|
8 | 8 | {.push raises: [], gcsafe.}
|
9 | 9 |
|
10 | 10 | import
|
11 |
| - std/[strutils, parseutils, tables, typetraits], |
| 11 | + std/[parseutils, tables, typetraits], |
12 | 12 | chronos/timer,
|
13 | 13 | stew/[byteutils], stint, eth/common/addresses as eth,
|
14 | 14 | ./datatypes/constants
|
15 | 15 |
|
16 | 16 | from std/algorithm import sort
|
| 17 | +from std/strutils import split, splitLines, startsWith, strip, `%` |
17 | 18 |
|
18 | 19 | export constants
|
19 |
| - |
20 | 20 | export stint, eth
|
21 | 21 |
|
22 | 22 | const
|
|
40 | 40 | MAX_SUPPORTED_BLOBS_PER_BLOCK*: uint64 = 9 # revisit getShortMap(Blobs) if >9
|
41 | 41 | MAX_SUPPORTED_REQUEST_BLOB_SIDECARS*: uint64 = 1152
|
42 | 42 |
|
| 43 | + # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/phase0/validator.md#time-parameters |
| 44 | + ATTESTATION_DUE_BPS: uint64 = 3333 |
| 45 | + AGGREGATE_DUE_BPS: uint64 = 6667 |
| 46 | + |
| 47 | + # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/altair/validator.md#time-parameters |
| 48 | + SYNC_MESSAGE_DUE_BPS: uint64 = 3333 |
| 49 | + CONTRIBUTION_DUE_BPS: uint64 = 6667 |
| 50 | + |
| 51 | + # https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/phase0/fork-choice.md#time-parameters |
| 52 | + PROPOSER_REORG_CUTOFF_BPS: uint64 = 1667 |
| 53 | + |
43 | 54 | type
|
44 | 55 | TimeConfig* = object
|
45 | 56 | SECONDS_PER_SLOT*: uint64
|
@@ -164,11 +175,13 @@ type
|
164 | 175 | const
|
165 | 176 | const_preset* {.strdefine.} = "mainnet"
|
166 | 177 |
|
167 |
| - # No-longer used values from legacy config files |
| 178 | + # No-longer used values from legacy config files, or quirks of BPO parsing |
168 | 179 | ignoredValues = [
|
169 | 180 | "TRANSITION_TOTAL_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
|
170 | 181 | "MIN_ANCHOR_POW_BLOCK_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
|
171 | 182 | "RANDOM_SUBNETS_PER_VALIDATOR", # Removed in consensus-specs v1.4.0
|
| 183 | + " MAX_BLOBS_PER_BLOCK", # parsed separately |
| 184 | + " - EPOCH", # parsed separately |
172 | 185 | ]
|
173 | 186 |
|
174 | 187 | when const_preset == "mainnet":
|
@@ -719,6 +732,7 @@ else:
|
719 | 732 | const
|
720 | 733 | MIN_SECONDS_PER_SLOT* = 1'u64
|
721 | 734 | MAX_SECONDS_PER_SLOT* = int64.high.uint64 div 1_000_000_000'u64
|
| 735 | + SLOT_DURATION_MS = SECONDS_PER_SLOT * 1000 |
722 | 736 |
|
723 | 737 | const SLOTS_PER_SYNC_COMMITTEE_PERIOD* =
|
724 | 738 | SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD
|
@@ -809,6 +823,7 @@ proc readRuntimeConfig*(
|
809 | 823 | if lineParts[0] in ignoredValues: continue
|
810 | 824 |
|
811 | 825 | values[lineParts[0]] = lineParts[1].strip
|
| 826 | + |
812 | 827 | # Accumulate BLOB_SCHEDULE entries
|
813 | 828 | var
|
814 | 829 | blobScheduleEntries: seq[BlobParameters]
|
@@ -992,6 +1007,13 @@ proc readRuntimeConfig*(
|
992 | 1007 | checkCompatibility REORG_PARENT_WEIGHT_THRESHOLD
|
993 | 1008 | checkCompatibility REORG_MAX_EPOCHS_SINCE_FINALIZATION
|
994 | 1009 |
|
| 1010 | + checkCompatibility SLOT_DURATION_MS |
| 1011 | + checkCompatibility ATTESTATION_DUE_BPS |
| 1012 | + checkCompatibility AGGREGATE_DUE_BPS |
| 1013 | + checkCompatibility SYNC_MESSAGE_DUE_BPS |
| 1014 | + checkCompatibility CONTRIBUTION_DUE_BPS |
| 1015 | + checkCompatibility PROPOSER_REORG_CUTOFF_BPS |
| 1016 | + |
995 | 1017 | template assignValue(name: static string, field: untyped): untyped =
|
996 | 1018 | if values.hasKey(name):
|
997 | 1019 | when field is seq[BlobParameters]:
|
|
0 commit comments