2020-07-29 21:19:36 +00:00
|
|
|
import
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
std/[os, strutils, stats],
|
|
|
|
confutils, chronicles, json_serialization,
|
2022-05-31 07:07:09 +00:00
|
|
|
stew/[byteutils, io2],
|
|
|
|
snappy,
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
../research/simutils,
|
2021-11-10 11:39:08 +00:00
|
|
|
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
2022-01-18 13:36:52 +00:00
|
|
|
../beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
|
2021-08-18 18:57:58 +00:00
|
|
|
../beacon_chain/spec/[
|
|
|
|
eth2_ssz_serialization, forks, helpers, state_transition],
|
|
|
|
../beacon_chain/networking/network_metadata
|
2020-07-29 21:19:36 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
Cmd* = enum
|
|
|
|
hashTreeRoot = "Compute hash tree root of SSZ object"
|
|
|
|
pretty = "Pretty-print SSZ object"
|
|
|
|
transition = "Run state transition function"
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
slots = "Apply empty slots"
|
2020-07-29 21:19:36 +00:00
|
|
|
|
|
|
|
NcliConf* = object
|
2020-09-01 09:01:57 +00:00
|
|
|
eth2Network* {.
|
|
|
|
desc: "The Eth2 network preset to use"
|
|
|
|
name: "network" }: Option[string]
|
|
|
|
|
2022-08-16 22:17:22 +00:00
|
|
|
printTimes* {.
|
|
|
|
defaultValue: false # false to avoid polluting minimal output
|
|
|
|
name: "print-times"
|
|
|
|
desc: "Print timing information".}: bool
|
|
|
|
|
2020-07-29 21:19:36 +00:00
|
|
|
# TODO confutils argument pragma doesn't seem to do much; also, the cases
|
|
|
|
# are largely equivalent, but this helps create command line usage text
|
|
|
|
case cmd* {.command}: Cmd
|
|
|
|
of hashTreeRoot:
|
|
|
|
htrKind* {.
|
|
|
|
argument
|
|
|
|
desc: "kind of SSZ object: attester_slashing, attestation, signed_block, block, block_body, block_header, deposit, deposit_data, eth1_data, state, proposer_slashing, or voluntary_exit"}: string
|
|
|
|
|
|
|
|
htrFile* {.
|
|
|
|
argument
|
|
|
|
desc: "filename of SSZ or JSON-encoded object of which to compute hash tree root"}: string
|
|
|
|
|
|
|
|
of pretty:
|
|
|
|
prettyKind* {.
|
|
|
|
argument
|
|
|
|
desc: "kind of SSZ object: attester_slashing, attestation, signed_block, block, block_body, block_header, deposit, deposit_data, eth1_data, state, proposer_slashing, or voluntary_exit"}: string
|
|
|
|
|
|
|
|
prettyFile* {.
|
|
|
|
argument
|
|
|
|
desc: "filename of SSZ or JSON-encoded object to pretty-print"}: string
|
|
|
|
|
|
|
|
of transition:
|
|
|
|
preState* {.
|
|
|
|
argument
|
|
|
|
desc: "State to which to apply specified block"}: string
|
|
|
|
|
|
|
|
blck* {.
|
|
|
|
argument
|
|
|
|
desc: "Block to apply to preState"}: string
|
|
|
|
|
|
|
|
postState* {.
|
|
|
|
argument
|
|
|
|
desc: "Filename of state resulting from applying blck to preState"}: string
|
|
|
|
|
|
|
|
verifyStateRoot* {.
|
|
|
|
argument
|
|
|
|
desc: "Verify state root (default true)"
|
|
|
|
defaultValue: true}: bool
|
|
|
|
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
of slots:
|
|
|
|
preState2* {.
|
|
|
|
argument
|
|
|
|
desc: "State to which to apply specified block"}: string
|
|
|
|
|
|
|
|
slot* {.
|
|
|
|
argument
|
|
|
|
desc: "Block to apply to preState"}: uint64
|
|
|
|
|
|
|
|
postState2* {.
|
|
|
|
argument
|
|
|
|
desc: "Filename of state resulting from applying blck to preState"}: string
|
|
|
|
|
2021-06-24 18:34:08 +00:00
|
|
|
template saveSSZFile(filename: string, value: ForkedHashedBeaconState) =
|
2021-10-18 16:37:27 +00:00
|
|
|
case value.kind:
|
2022-01-04 09:45:38 +00:00
|
|
|
of BeaconStateFork.Phase0: SSZ.saveFile(filename, value.phase0Data.data)
|
|
|
|
of BeaconStateFork.Altair: SSZ.saveFile(filename, value.altairData.data)
|
2022-01-24 16:23:13 +00:00
|
|
|
of BeaconStateFork.Bellatrix: SSZ.saveFile(filename, value.bellatrixData.data)
|
2022-11-02 16:23:30 +00:00
|
|
|
of BeaconStateFork.Capella: SSZ.saveFile(filename, value.capellaData.data)
|
2021-06-24 18:34:08 +00:00
|
|
|
|
2022-05-31 07:07:09 +00:00
|
|
|
proc loadFile(filename: string, T: type): T =
|
|
|
|
let
|
|
|
|
ext = splitFile(filename).ext
|
|
|
|
bytes = readAllBytes(filename).expect("file exists")
|
|
|
|
if cmpIgnoreCase(ext, ".ssz") == 0:
|
|
|
|
SSZ.decode(bytes, T)
|
|
|
|
elif cmpIgnoreCase(ext, ".ssz_snappy") == 0:
|
|
|
|
SSZ.decode(snappy.decode(bytes), T)
|
|
|
|
elif cmpIgnoreCase(ext, ".json") == 0:
|
|
|
|
# JSON.loadFile(file, t)
|
|
|
|
echo "TODO needs porting to RestJson"
|
|
|
|
quit 1
|
|
|
|
else:
|
|
|
|
echo "Unknown file type: ", ext
|
|
|
|
quit 1
|
|
|
|
|
2020-07-29 21:19:36 +00:00
|
|
|
proc doTransition(conf: NcliConf) =
|
2022-08-16 22:17:22 +00:00
|
|
|
type
|
|
|
|
Timers = enum
|
|
|
|
tLoadState = "Load state from file"
|
|
|
|
tTransition = "Apply slot"
|
|
|
|
tSaveState = "Save state to file"
|
|
|
|
var timers: array[Timers, RunningStat]
|
|
|
|
|
2020-07-29 21:19:36 +00:00
|
|
|
let
|
2022-06-09 12:57:33 +00:00
|
|
|
cfg = getRuntimeConfig(conf.eth2Network)
|
2022-08-16 22:17:22 +00:00
|
|
|
stateY = withTimerRet(timers[tLoadState]):
|
|
|
|
newClone(readSszForkedHashedBeaconState(
|
|
|
|
cfg, readAllBytes(conf.preState).tryGet()))
|
2022-06-09 12:57:33 +00:00
|
|
|
blckX = readSszForkedSignedBeaconBlock(
|
|
|
|
cfg, readAllBytes(conf.blck).tryGet())
|
2020-07-29 21:19:36 +00:00
|
|
|
flags = if not conf.verifyStateRoot: {skipStateRootValidation} else: {}
|
|
|
|
|
2021-05-07 11:36:21 +00:00
|
|
|
var
|
|
|
|
cache = StateCache()
|
2021-10-13 14:24:36 +00:00
|
|
|
info = ForkedEpochInfo()
|
2022-08-16 22:17:22 +00:00
|
|
|
let res = withTimerRet(timers[tTransition]): withBlck(blckX):
|
2022-06-09 12:57:33 +00:00
|
|
|
state_transition(
|
|
|
|
cfg, stateY[], blck, cache, info, flags, noRollback)
|
2022-01-17 11:19:58 +00:00
|
|
|
if res.isErr():
|
|
|
|
error "State transition failed", error = res.error()
|
2020-07-29 21:19:36 +00:00
|
|
|
quit 1
|
|
|
|
else:
|
2022-08-16 22:17:22 +00:00
|
|
|
withTimer(timers[tSaveState]):
|
|
|
|
saveSSZFile(conf.postState, stateY[])
|
|
|
|
|
|
|
|
if conf.printTimes:
|
|
|
|
printTimers(false, timers)
|
2020-07-29 21:19:36 +00:00
|
|
|
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
proc doSlots(conf: NcliConf) =
|
|
|
|
type
|
|
|
|
Timers = enum
|
|
|
|
tLoadState = "Load state from file"
|
|
|
|
tApplySlot = "Apply slot"
|
|
|
|
tApplyEpochSlot = "Apply epoch slot"
|
|
|
|
tSaveState = "Save state to file"
|
|
|
|
|
|
|
|
var timers: array[Timers, RunningStat]
|
|
|
|
let
|
2022-06-09 12:57:33 +00:00
|
|
|
cfg = getRuntimeConfig(conf.eth2Network)
|
|
|
|
stateY = withTimerRet(timers[tLoadState]):
|
|
|
|
newClone(readSszForkedHashedBeaconState(
|
|
|
|
cfg, readAllBytes(conf.preState2).tryGet()))
|
2021-05-07 11:36:21 +00:00
|
|
|
var
|
|
|
|
cache = StateCache()
|
2021-10-13 14:24:36 +00:00
|
|
|
info = ForkedEpochInfo()
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
for i in 0'u64..<conf.slot:
|
2022-01-11 10:01:54 +00:00
|
|
|
let isEpoch = (getStateField(stateY[], slot) + 1).is_epoch
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
withTimer(timers[if isEpoch: tApplyEpochSlot else: tApplySlot]):
|
2022-01-17 11:19:58 +00:00
|
|
|
process_slots(
|
2022-06-09 12:57:33 +00:00
|
|
|
cfg, stateY[], getStateField(stateY[], slot) + 1,
|
2022-01-17 11:19:58 +00:00
|
|
|
cache, info, {}).expect("should be able to advance slot")
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
|
|
|
|
withTimer(timers[tSaveState]):
|
2022-06-09 12:57:33 +00:00
|
|
|
saveSSZFile(conf.postState2, stateY[])
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
|
2022-08-16 22:17:22 +00:00
|
|
|
if conf.printTimes:
|
|
|
|
printTimers(false, timers)
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
|
2020-07-29 21:19:36 +00:00
|
|
|
proc doSSZ(conf: NcliConf) =
|
2022-08-16 22:17:22 +00:00
|
|
|
type Timers = enum
|
|
|
|
tLoad = "Load file"
|
|
|
|
tCompute = "Compute"
|
|
|
|
var timers: array[Timers, RunningStat]
|
|
|
|
|
2020-07-29 21:19:36 +00:00
|
|
|
let (kind, file) =
|
|
|
|
case conf.cmd:
|
|
|
|
of hashTreeRoot: (conf.htrKind, conf.htrFile)
|
|
|
|
of pretty: (conf.prettyKind, conf.prettyFile)
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
else:
|
2020-07-29 21:19:36 +00:00
|
|
|
raiseAssert "doSSZ() only implements hashTreeRoot and pretty commands"
|
|
|
|
|
|
|
|
template printit(t: untyped) {.dirty.} =
|
2022-08-16 22:17:22 +00:00
|
|
|
|
|
|
|
let v = withTimerRet(timers[tLoad]):
|
|
|
|
newClone(loadFile(file, t))
|
2020-07-29 21:19:36 +00:00
|
|
|
|
|
|
|
case conf.cmd:
|
|
|
|
of hashTreeRoot:
|
2022-08-16 22:17:22 +00:00
|
|
|
let root = withTimerRet(timers[tCompute]):
|
|
|
|
when t is ForkySignedBeaconBlock:
|
|
|
|
hash_tree_root(v[].message)
|
|
|
|
else:
|
|
|
|
hash_tree_root(v[])
|
|
|
|
|
|
|
|
echo root.data.toHex()
|
2020-07-29 21:19:36 +00:00
|
|
|
of pretty:
|
2021-11-10 11:39:08 +00:00
|
|
|
echo RestJson.encode(v[], pretty = true)
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
else:
|
2020-07-29 21:19:36 +00:00
|
|
|
raiseAssert "doSSZ() only implements hashTreeRoot and pretty commands"
|
|
|
|
|
2022-08-16 22:17:22 +00:00
|
|
|
if conf.printTimes:
|
|
|
|
printTimers(false, timers)
|
2020-07-29 21:19:36 +00:00
|
|
|
|
|
|
|
case kind
|
|
|
|
of "attester_slashing": printit(AttesterSlashing)
|
|
|
|
of "attestation": printit(Attestation)
|
2021-11-10 11:39:08 +00:00
|
|
|
of "phase0_signed_block": printit(phase0.SignedBeaconBlock)
|
|
|
|
of "altair_signed_block": printit(altair.SignedBeaconBlock)
|
2022-01-18 16:31:05 +00:00
|
|
|
of "bellatrix_signed_block": printit(bellatrix.SignedBeaconBlock)
|
2021-11-10 11:39:08 +00:00
|
|
|
of "phase0_block": printit(phase0.BeaconBlock)
|
|
|
|
of "altair_block": printit(altair.BeaconBlock)
|
2022-01-18 16:31:05 +00:00
|
|
|
of "bellatrix_block": printit(bellatrix.BeaconBlock)
|
2021-11-10 11:39:08 +00:00
|
|
|
of "phase0_block_body": printit(phase0.BeaconBlockBody)
|
|
|
|
of "altair_block_body": printit(altair.BeaconBlockBody)
|
2022-01-18 16:31:05 +00:00
|
|
|
of "bellatrix_block_body": printit(bellatrix.BeaconBlockBody)
|
2020-07-29 21:19:36 +00:00
|
|
|
of "block_header": printit(BeaconBlockHeader)
|
|
|
|
of "deposit": printit(Deposit)
|
|
|
|
of "deposit_data": printit(DepositData)
|
|
|
|
of "eth1_data": printit(Eth1Data)
|
2021-11-10 11:39:08 +00:00
|
|
|
of "phase0_state": printit(phase0.BeaconState)
|
2022-08-16 22:17:22 +00:00
|
|
|
of "altair_state": printit(altair.BeaconState)
|
2022-01-18 16:31:05 +00:00
|
|
|
of "bellatrix_state": printit(bellatrix.BeaconState)
|
2020-07-29 21:19:36 +00:00
|
|
|
of "proposer_slashing": printit(ProposerSlashing)
|
|
|
|
of "voluntary_exit": printit(VoluntaryExit)
|
|
|
|
|
|
|
|
when isMainModule:
|
2022-06-09 12:57:33 +00:00
|
|
|
let
|
|
|
|
conf = NcliConf.load()
|
2020-07-29 21:19:36 +00:00
|
|
|
|
|
|
|
case conf.cmd:
|
|
|
|
of hashTreeRoot: doSSZ(conf)
|
|
|
|
of pretty: doSSZ(conf)
|
|
|
|
of transition: doTransition(conf)
|
improve slot processing speeds (#1670)
about 40% better slot processing times (with LTO enabled) - these don't
do BLS but are used
heavily during replay (state transition = slot + block transition)
tests using a recent medalla state and advancing it 1000 slots:
```
./ncli slots --preState2:state-302271-3c1dbf19-c1f944bf.ssz --slot:1000
--postState2:xx.ssz
```
pre:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
39.236, 0.000, 39.236, 39.236, 1,
Load state from file
0.049, 0.002, 0.046, 0.063, 968,
Apply slot
256.504, 81.008, 213.471, 591.902, 32,
Apply epoch slot
28.597, 0.000, 28.597, 28.597, 1,
Save state to file
```
cast:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
37.079, 0.000, 37.079, 37.079, 1,
Load state from file
0.042, 0.002, 0.040, 0.090, 968,
Apply slot
215.552, 68.763, 180.155, 500.103, 32,
Apply epoch slot
25.106, 0.000, 25.106, 25.106, 1,
Save state to file
```
cast+rewards:
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
40.049, 0.000, 40.049, 40.049, 1,
Load state from file
0.048, 0.001, 0.045, 0.060, 968,
Apply slot
164.981, 76.273, 142.099, 477.868, 32,
Apply epoch slot
28.498, 0.000, 28.498, 28.498, 1,
Save state to file
```
cast+rewards+shr
```
All time are ms
Average, StdDev, Min, Max, Samples,
Test
Validation is turned off meaning that no BLS operations are performed
12.898, 0.000, 12.898, 12.898, 1,
Load state from file
0.039, 0.002, 0.038, 0.054, 968,
Apply slot
139.971, 68.797, 120.088, 428.844, 32,
Apply epoch slot
24.761, 0.000, 24.761, 24.761, 1,
Save state to file
```
2020-09-16 20:59:33 +00:00
|
|
|
of slots: doSlots(conf)
|