Skip to content

Commit

Permalink
feat: emit slashing events (#6391)
Browse files Browse the repository at this point in the history
* feat: emit slashing events

* chore: added tests

* chore: wording

Co-authored-by: Nico Flaig <nflaig@protonmail.com>

---------

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
  • Loading branch information
jeluard and nflaig authored Feb 8, 2024
1 parent c98a48a commit 036fb39
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/api/src/beacon/routes/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export enum EventType {
attestation = "attestation",
/** The node has received a valid voluntary exit (from P2P or API) */
voluntaryExit = "voluntary_exit",
/** The node has received a valid proposer slashing (from P2P or API) */
proposerSlashing = "proposer_slashing",
/** The node has received a valid attester slashing (from P2P or API) */
attesterSlashing = "attester_slashing",
/** The node has received a valid blsToExecutionChange (from P2P or API) */
blsToExecutionChange = "bls_to_execution_change",
/** Finalized checkpoint has been updated */
Expand All @@ -58,6 +62,8 @@ export const eventTypes: {[K in EventType]: K} = {
[EventType.block]: EventType.block,
[EventType.attestation]: EventType.attestation,
[EventType.voluntaryExit]: EventType.voluntaryExit,
[EventType.proposerSlashing]: EventType.proposerSlashing,
[EventType.attesterSlashing]: EventType.attesterSlashing,
[EventType.blsToExecutionChange]: EventType.blsToExecutionChange,
[EventType.finalizedCheckpoint]: EventType.finalizedCheckpoint,
[EventType.chainReorg]: EventType.chainReorg,
Expand Down Expand Up @@ -85,6 +91,8 @@ export type EventData = {
};
[EventType.attestation]: phase0.Attestation;
[EventType.voluntaryExit]: phase0.SignedVoluntaryExit;
[EventType.proposerSlashing]: phase0.ProposerSlashing;
[EventType.attesterSlashing]: phase0.AttesterSlashing;
[EventType.blsToExecutionChange]: capella.SignedBLSToExecutionChange;
[EventType.finalizedCheckpoint]: {
block: RootHex;
Expand Down Expand Up @@ -174,6 +182,8 @@ export function getTypeByEvent(): {[K in EventType]: TypeJson<EventData[K]>} {

[EventType.attestation]: ssz.phase0.Attestation,
[EventType.voluntaryExit]: ssz.phase0.SignedVoluntaryExit,
[EventType.proposerSlashing]: ssz.phase0.ProposerSlashing,
[EventType.attesterSlashing]: ssz.phase0.AttesterSlashing,
[EventType.blsToExecutionChange]: ssz.capella.SignedBLSToExecutionChange,

[EventType.finalizedCheckpoint]: new ContainerType(
Expand Down
62 changes: 62 additions & 0 deletions packages/api/test/unit/beacon/testData/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,68 @@ export const eventTestData: EventData = {
signature:
"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505",
}),
[EventType.proposerSlashing]: ssz.phase0.ProposerSlashing.fromJson({
signed_header_1: {
message: {
slot: "0",
proposer_index: "0",
parent_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
state_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
body_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
signature:
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
signed_header_2: {
message: {
slot: "0",
proposer_index: "0",
parent_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
state_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
body_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
signature:
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
}),
[EventType.attesterSlashing]: ssz.phase0.AttesterSlashing.fromJson({
attestation_1: {
attesting_indices: ["0", "1"],
data: {
slot: "0",
index: "0",
beacon_block_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
source: {
epoch: "0",
root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
target: {
epoch: "0",
root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
},
signature:
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
attestation_2: {
attesting_indices: ["0", "1"],
data: {
slot: "0",
index: "0",
beacon_block_root: "0x0000000000000000000000000000000000000000000000000000000000000000",
source: {
epoch: "0",
root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
target: {
epoch: "0",
root: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
},
signature:
"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
}),
[EventType.blsToExecutionChange]: ssz.capella.SignedBLSToExecutionChange.fromJson({
message: {
validator_index: "1",
Expand Down
10 changes: 10 additions & 0 deletions packages/beacon-node/src/chain/blocks/importBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ export async function importBlock(
this.emitter.emit(routes.events.EventType.attestation, attestation);
}
}
if (this.emitter.listenerCount(routes.events.EventType.attesterSlashing)) {
for (const attesterSlashing of block.message.body.attesterSlashings) {
this.emitter.emit(routes.events.EventType.attesterSlashing, attesterSlashing);
}
}
if (this.emitter.listenerCount(routes.events.EventType.proposerSlashing)) {
for (const proposerSlashing of block.message.body.proposerSlashings) {
this.emitter.emit(routes.events.EventType.proposerSlashing, proposerSlashing);
}
}
}

// Register stat metrics about the block after importing it
Expand Down
4 changes: 4 additions & 0 deletions packages/beacon-node/src/network/processor/gossipHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
} catch (e) {
logger.error("Error adding attesterSlashing to pool", {}, e as Error);
}

chain.emitter.emit(routes.events.EventType.attesterSlashing, attesterSlashing);
},

[GossipType.proposer_slashing]: async ({
Expand All @@ -470,6 +472,8 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler
} catch (e) {
logger.error("Error adding attesterSlashing to pool", {}, e as Error);
}

chain.emitter.emit(routes.events.EventType.proposerSlashing, proposerSlashing);
},

[GossipType.voluntary_exit]: async ({gossipData, topic}: GossipHandlerParamGeneric<GossipType.voluntary_exit>) => {
Expand Down
64 changes: 64 additions & 0 deletions packages/beacon-node/test/e2e/network/gossipsub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,70 @@ function runTests({useWorker}: {useWorker: boolean}): void {
);
});

it("Publish and receive an attesterSlashing", async function () {
let onAttesterSlashingChange: (payload: Uint8Array) => void;
const onAttesterSlashingChangePromise = new Promise<Uint8Array>((resolve) => (onAttesterSlashingChange = resolve));

const {netA, netB} = await mockModules({
[GossipType.attester_slashing]: async ({gossipData}: GossipHandlerParamGeneric<GossipType.attester_slashing>) => {
onAttesterSlashingChange(gossipData.serializedData);
},
});

await Promise.all([onPeerConnect(netA), onPeerConnect(netB), connect(netA, netB)]);
expect(netA.getConnectedPeerCount()).toBe(1);
expect(netB.getConnectedPeerCount()).toBe(1);

await netA.subscribeGossipCoreTopics();
await netB.subscribeGossipCoreTopics();

// Wait to have a peer connected to a topic
while (!netA.closed) {
await sleep(500);
if (await hasSomeMeshPeer(netA)) {
break;
}
}

const attesterSlashing = ssz.phase0.AttesterSlashing.defaultValue();
await netA.publishAttesterSlashing(attesterSlashing);

const received = await onAttesterSlashingChangePromise;
expect(Buffer.from(received)).toEqual(Buffer.from(ssz.phase0.AttesterSlashing.serialize(attesterSlashing)));
});

it("Publish and receive a proposerSlashing", async function () {
let onProposerSlashingChange: (payload: Uint8Array) => void;
const onProposerSlashingChangePromise = new Promise<Uint8Array>((resolve) => (onProposerSlashingChange = resolve));

const {netA, netB} = await mockModules({
[GossipType.proposer_slashing]: async ({gossipData}: GossipHandlerParamGeneric<GossipType.proposer_slashing>) => {
onProposerSlashingChange(gossipData.serializedData);
},
});

await Promise.all([onPeerConnect(netA), onPeerConnect(netB), connect(netA, netB)]);
expect(netA.getConnectedPeerCount()).toBe(1);
expect(netB.getConnectedPeerCount()).toBe(1);

await netA.subscribeGossipCoreTopics();
await netB.subscribeGossipCoreTopics();

// Wait to have a peer connected to a topic
while (!netA.closed) {
await sleep(500);
if (await hasSomeMeshPeer(netA)) {
break;
}
}

const proposerSlashing = ssz.phase0.ProposerSlashing.defaultValue();
await netA.publishProposerSlashing(proposerSlashing);

const received = await onProposerSlashingChangePromise;
expect(Buffer.from(received)).toEqual(Buffer.from(ssz.phase0.ProposerSlashing.serialize(proposerSlashing)));
});

it("Publish and receive a LightClientOptimisticUpdate", async function () {
let onLightClientOptimisticUpdate: (ou: Uint8Array) => void;
const onLightClientOptimisticUpdatePromise = new Promise<Uint8Array>(
Expand Down

1 comment on commit 036fb39

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 036fb39 Previous: cb99fc4 Ratio
forkChoice updateHead vc 600000 bc 64 eq 300000 71.751 ms/op 15.818 ms/op 4.54
Full benchmark results
Benchmark suite Current: 036fb39 Previous: cb99fc4 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 788.36 us/op 781.72 us/op 1.01
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 90.808 us/op 81.024 us/op 1.12
BLS verify - blst-native 1.3534 ms/op 1.2785 ms/op 1.06
BLS verifyMultipleSignatures 3 - blst-native 2.9265 ms/op 2.6808 ms/op 1.09
BLS verifyMultipleSignatures 8 - blst-native 6.3573 ms/op 5.8822 ms/op 1.08
BLS verifyMultipleSignatures 32 - blst-native 23.382 ms/op 21.498 ms/op 1.09
BLS verifyMultipleSignatures 64 - blst-native 45.663 ms/op 41.692 ms/op 1.10
BLS verifyMultipleSignatures 128 - blst-native 90.311 ms/op 82.488 ms/op 1.09
BLS deserializing 10000 signatures 971.53 ms/op 903.85 ms/op 1.07
BLS deserializing 100000 signatures 10.487 s/op 9.2095 s/op 1.14
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.6150 ms/op 1.3066 ms/op 1.24
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.8405 ms/op 1.4719 ms/op 1.25
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.9506 ms/op 2.7219 ms/op 1.08
BLS verifyMultipleSignatures - same message - 64 - blst-native 4.2812 ms/op 4.2498 ms/op 1.01
BLS verifyMultipleSignatures - same message - 128 - blst-native 6.9634 ms/op 7.4937 ms/op 0.93
BLS aggregatePubkeys 32 - blst-native 31.178 us/op 27.126 us/op 1.15
BLS aggregatePubkeys 128 - blst-native 135.26 us/op 99.345 us/op 1.36
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 82.105 ms/op 49.096 ms/op 1.67
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 67.658 ms/op 46.645 ms/op 1.45
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 62.899 ms/op 32.538 ms/op 1.93
getSlashingsAndExits - default max 388.78 us/op 216.85 us/op 1.79
getSlashingsAndExits - 2k 441.18 us/op 376.54 us/op 1.17
proposeBlockBody type=full, size=empty 6.4801 ms/op 5.0356 ms/op 1.29
isKnown best case - 1 super set check 426.00 ns/op 296.00 ns/op 1.44
isKnown normal case - 2 super set checks 631.00 ns/op 289.00 ns/op 2.18
isKnown worse case - 16 super set checks 632.00 ns/op 285.00 ns/op 2.22
CheckpointStateCache - add get delete 6.2080 us/op 4.8990 us/op 1.27
validate api signedAggregateAndProof - struct 2.9217 ms/op 2.7149 ms/op 1.08
validate gossip signedAggregateAndProof - struct 2.9646 ms/op 2.7206 ms/op 1.09
validate gossip attestation - vc 640000 1.4119 ms/op 1.3251 ms/op 1.07
batch validate gossip attestation - vc 640000 - chunk 32 172.96 us/op 157.06 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 64 155.98 us/op 139.37 us/op 1.12
batch validate gossip attestation - vc 640000 - chunk 128 151.98 us/op 134.26 us/op 1.13
batch validate gossip attestation - vc 640000 - chunk 256 144.85 us/op 133.63 us/op 1.08
pickEth1Vote - no votes 1.4222 ms/op 1.1459 ms/op 1.24
pickEth1Vote - max votes 10.185 ms/op 8.9590 ms/op 1.14
pickEth1Vote - Eth1Data hashTreeRoot value x2048 22.704 ms/op 22.168 ms/op 1.02
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 33.690 ms/op 24.552 ms/op 1.37
pickEth1Vote - Eth1Data fastSerialize value x2048 948.88 us/op 587.73 us/op 1.61
pickEth1Vote - Eth1Data fastSerialize tree x2048 9.9979 ms/op 6.0949 ms/op 1.64
bytes32 toHexString 1.1180 us/op 475.00 ns/op 2.35
bytes32 Buffer.toString(hex) 522.00 ns/op 281.00 ns/op 1.86
bytes32 Buffer.toString(hex) from Uint8Array 842.00 ns/op 406.00 ns/op 2.07
bytes32 Buffer.toString(hex) + 0x 603.00 ns/op 282.00 ns/op 2.14
Object access 1 prop 0.39400 ns/op 0.16100 ns/op 2.45
Map access 1 prop 0.29100 ns/op 0.15000 ns/op 1.94
Object get x1000 17.036 ns/op 7.0120 ns/op 2.43
Map get x1000 1.2870 ns/op 0.73300 ns/op 1.76
Object set x1000 92.401 ns/op 48.439 ns/op 1.91
Map set x1000 64.025 ns/op 41.436 ns/op 1.55
Return object 10000 times 0.28940 ns/op 0.24350 ns/op 1.19
Throw Error 10000 times 5.8164 us/op 3.8205 us/op 1.52
fastMsgIdFn sha256 / 200 bytes 4.7800 us/op 3.2960 us/op 1.45
fastMsgIdFn h32 xxhash / 200 bytes 467.00 ns/op 286.00 ns/op 1.63
fastMsgIdFn h64 xxhash / 200 bytes 452.00 ns/op 360.00 ns/op 1.26
fastMsgIdFn sha256 / 1000 bytes 14.963 us/op 11.485 us/op 1.30
fastMsgIdFn h32 xxhash / 1000 bytes 671.00 ns/op 484.00 ns/op 1.39
fastMsgIdFn h64 xxhash / 1000 bytes 681.00 ns/op 460.00 ns/op 1.48
fastMsgIdFn sha256 / 10000 bytes 137.30 us/op 105.14 us/op 1.31
fastMsgIdFn h32 xxhash / 10000 bytes 2.9890 us/op 2.0590 us/op 1.45
fastMsgIdFn h64 xxhash / 10000 bytes 2.3010 us/op 1.4340 us/op 1.60
send data - 1000 256B messages 30.550 ms/op 22.829 ms/op 1.34
send data - 1000 512B messages 38.901 ms/op 28.667 ms/op 1.36
send data - 1000 1024B messages 69.190 ms/op 40.220 ms/op 1.72
send data - 1000 1200B messages 87.068 ms/op 40.766 ms/op 2.14
send data - 1000 2048B messages 81.997 ms/op 53.480 ms/op 1.53
send data - 1000 4096B messages 78.355 ms/op 47.366 ms/op 1.65
send data - 1000 16384B messages 206.81 ms/op 116.28 ms/op 1.78
send data - 1000 65536B messages 806.42 ms/op 441.47 ms/op 1.83
enrSubnets - fastDeserialize 64 bits 2.8750 us/op 1.2340 us/op 2.33
enrSubnets - ssz BitVector 64 bits 1.0920 us/op 404.00 ns/op 2.70
enrSubnets - fastDeserialize 4 bits 422.00 ns/op 170.00 ns/op 2.48
enrSubnets - ssz BitVector 4 bits 923.00 ns/op 414.00 ns/op 2.23
prioritizePeers score -10:0 att 32-0.1 sync 2-0 185.90 us/op 96.828 us/op 1.92
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 237.86 us/op 128.86 us/op 1.85
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 315.46 us/op 159.72 us/op 1.98
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 607.37 us/op 288.64 us/op 2.10
prioritizePeers score 0:0 att 64-1 sync 4-1 536.94 us/op 335.02 us/op 1.60
array of 16000 items push then shift 2.8310 us/op 1.6016 us/op 1.77
LinkedList of 16000 items push then shift 16.485 ns/op 8.7500 ns/op 1.88
array of 16000 items push then pop 194.39 ns/op 95.453 ns/op 2.04
LinkedList of 16000 items push then pop 15.024 ns/op 8.5970 ns/op 1.75
array of 24000 items push then shift 3.1510 us/op 2.5319 us/op 1.24
LinkedList of 24000 items push then shift 14.884 ns/op 8.8390 ns/op 1.68
array of 24000 items push then pop 241.44 ns/op 113.85 ns/op 2.12
LinkedList of 24000 items push then pop 13.868 ns/op 8.6660 ns/op 1.60
intersect bitArray bitLen 8 7.9130 ns/op 5.8920 ns/op 1.34
intersect array and set length 8 117.56 ns/op 67.392 ns/op 1.74
intersect bitArray bitLen 128 56.196 ns/op 34.590 ns/op 1.62
intersect array and set length 128 1.4617 us/op 836.02 ns/op 1.75
bitArray.getTrueBitIndexes() bitLen 128 2.8300 us/op 1.3860 us/op 2.04
bitArray.getTrueBitIndexes() bitLen 248 4.5010 us/op 2.3620 us/op 1.91
bitArray.getTrueBitIndexes() bitLen 512 8.8590 us/op 4.7030 us/op 1.88
Buffer.concat 32 items 2.1960 us/op 917.00 ns/op 2.39
Uint8Array.set 32 items 3.4060 us/op 1.8880 us/op 1.80
Set add up to 64 items then delete first 6.7771 us/op 4.2949 us/op 1.58
OrderedSet add up to 64 items then delete first 9.3506 us/op 5.3814 us/op 1.74
Set add up to 64 items then delete last 7.0983 us/op 5.0855 us/op 1.40
OrderedSet add up to 64 items then delete last 9.9906 us/op 6.5443 us/op 1.53
Set add up to 64 items then delete middle 6.8994 us/op 4.7267 us/op 1.46
OrderedSet add up to 64 items then delete middle 12.010 us/op 7.4349 us/op 1.62
Set add up to 128 items then delete first 14.039 us/op 9.4403 us/op 1.49
OrderedSet add up to 128 items then delete first 20.754 us/op 12.747 us/op 1.63
Set add up to 128 items then delete last 13.537 us/op 9.9304 us/op 1.36
OrderedSet add up to 128 items then delete last 20.475 us/op 11.817 us/op 1.73
Set add up to 128 items then delete middle 12.176 us/op 9.7361 us/op 1.25
OrderedSet add up to 128 items then delete middle 22.140 us/op 17.330 us/op 1.28
Set add up to 256 items then delete first 24.148 us/op 20.382 us/op 1.18
OrderedSet add up to 256 items then delete first 31.986 us/op 25.520 us/op 1.25
Set add up to 256 items then delete last 22.437 us/op 18.147 us/op 1.24
OrderedSet add up to 256 items then delete last 32.793 us/op 23.422 us/op 1.40
Set add up to 256 items then delete middle 22.555 us/op 18.422 us/op 1.22
OrderedSet add up to 256 items then delete middle 54.096 us/op 45.030 us/op 1.20
transfer serialized Status (84 B) 1.9640 us/op 1.7060 us/op 1.15
copy serialized Status (84 B) 1.4640 us/op 1.2770 us/op 1.15
transfer serialized SignedVoluntaryExit (112 B) 2.0520 us/op 1.9130 us/op 1.07
copy serialized SignedVoluntaryExit (112 B) 1.4860 us/op 1.4600 us/op 1.02
transfer serialized ProposerSlashing (416 B) 2.6770 us/op 2.9950 us/op 0.89
copy serialized ProposerSlashing (416 B) 3.0050 us/op 2.8340 us/op 1.06
transfer serialized Attestation (485 B) 3.9170 us/op 3.2850 us/op 1.19
copy serialized Attestation (485 B) 3.0590 us/op 2.8780 us/op 1.06
transfer serialized AttesterSlashing (33232 B) 2.9400 us/op 3.2000 us/op 0.92
copy serialized AttesterSlashing (33232 B) 12.322 us/op 7.1850 us/op 1.71
transfer serialized Small SignedBeaconBlock (128000 B) 4.5790 us/op 3.8180 us/op 1.20
copy serialized Small SignedBeaconBlock (128000 B) 34.385 us/op 15.861 us/op 2.17
transfer serialized Avg SignedBeaconBlock (200000 B) 5.0580 us/op 3.9360 us/op 1.29
copy serialized Avg SignedBeaconBlock (200000 B) 50.932 us/op 24.257 us/op 2.10
transfer serialized BlobsSidecar (524380 B) 6.5980 us/op 3.8080 us/op 1.73
copy serialized BlobsSidecar (524380 B) 214.52 us/op 110.01 us/op 1.95
transfer serialized Big SignedBeaconBlock (1000000 B) 6.3070 us/op 3.8330 us/op 1.65
copy serialized Big SignedBeaconBlock (1000000 B) 282.33 us/op 158.52 us/op 1.78
pass gossip attestations to forkchoice per slot 6.6015 ms/op 4.2971 ms/op 1.54
forkChoice updateHead vc 100000 bc 64 eq 0 831.02 us/op 703.47 us/op 1.18
forkChoice updateHead vc 600000 bc 64 eq 0 6.6204 ms/op 4.1302 ms/op 1.60
forkChoice updateHead vc 1000000 bc 64 eq 0 11.479 ms/op 6.8351 ms/op 1.68
forkChoice updateHead vc 600000 bc 320 eq 0 5.4578 ms/op 4.0866 ms/op 1.34
forkChoice updateHead vc 600000 bc 1200 eq 0 5.4758 ms/op 4.2527 ms/op 1.29
forkChoice updateHead vc 600000 bc 7200 eq 0 7.4698 ms/op 5.1423 ms/op 1.45
forkChoice updateHead vc 600000 bc 64 eq 1000 17.397 ms/op 10.954 ms/op 1.59
forkChoice updateHead vc 600000 bc 64 eq 10000 17.176 ms/op 11.642 ms/op 1.48
forkChoice updateHead vc 600000 bc 64 eq 300000 71.751 ms/op 15.818 ms/op 4.54
computeDeltas 500000 validators 300 proto nodes 9.7580 ms/op 6.4010 ms/op 1.52
computeDeltas 500000 validators 1200 proto nodes 7.3334 ms/op 6.6543 ms/op 1.10
computeDeltas 500000 validators 7200 proto nodes 6.8783 ms/op 6.5841 ms/op 1.04
computeDeltas 750000 validators 300 proto nodes 10.539 ms/op 10.381 ms/op 1.02
computeDeltas 750000 validators 1200 proto nodes 10.310 ms/op 11.263 ms/op 0.92
computeDeltas 750000 validators 7200 proto nodes 10.648 ms/op 10.876 ms/op 0.98
computeDeltas 1400000 validators 300 proto nodes 21.053 ms/op 21.317 ms/op 0.99
computeDeltas 1400000 validators 1200 proto nodes 20.312 ms/op 20.108 ms/op 1.01
computeDeltas 1400000 validators 7200 proto nodes 20.148 ms/op 20.248 ms/op 1.00
computeDeltas 2100000 validators 300 proto nodes 29.906 ms/op 29.790 ms/op 1.00
computeDeltas 2100000 validators 1200 proto nodes 28.580 ms/op 30.143 ms/op 0.95
computeDeltas 2100000 validators 7200 proto nodes 29.868 ms/op 29.880 ms/op 1.00
altair processAttestation - 250000 vs - 7PWei normalcase 3.0721 ms/op 3.1623 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei worstcase 3.9708 ms/op 4.6440 ms/op 0.86
altair processAttestation - setStatus - 1/6 committees join 182.28 us/op 203.37 us/op 0.90
altair processAttestation - setStatus - 1/3 committees join 363.77 us/op 382.98 us/op 0.95
altair processAttestation - setStatus - 1/2 committees join 510.37 us/op 516.15 us/op 0.99
altair processAttestation - setStatus - 2/3 committees join 624.16 us/op 636.69 us/op 0.98
altair processAttestation - setStatus - 4/5 committees join 853.35 us/op 959.94 us/op 0.89
altair processAttestation - setStatus - 100% committees join 980.38 us/op 1.1557 ms/op 0.85
altair processBlock - 250000 vs - 7PWei normalcase 11.260 ms/op 13.730 ms/op 0.82
altair processBlock - 250000 vs - 7PWei normalcase hashState 43.009 ms/op 42.443 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase 45.108 ms/op 41.982 ms/op 1.07
altair processBlock - 250000 vs - 7PWei worstcase hashState 111.76 ms/op 104.01 ms/op 1.07
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2290 ms/op 3.0790 ms/op 1.05
phase0 processBlock - 250000 vs - 7PWei worstcase 36.055 ms/op 33.161 ms/op 1.09
altair processEth1Data - 250000 vs - 7PWei normalcase 854.29 us/op 735.01 us/op 1.16
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 12.319 us/op 21.139 us/op 0.58
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 55.500 us/op 73.998 us/op 0.75
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 36.451 us/op 23.975 us/op 1.52
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 15.949 us/op 12.388 us/op 1.29
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 188.45 us/op 238.39 us/op 0.79
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.4335 ms/op 2.0913 ms/op 0.69
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.8921 ms/op 2.4322 ms/op 0.78
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.8891 ms/op 2.3467 ms/op 0.80
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.0750 ms/op 5.2909 ms/op 0.77
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.5253 ms/op 2.6495 ms/op 1.33
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.9716 ms/op 6.5981 ms/op 1.06
Tree 40 250000 create 445.46 ms/op 535.46 ms/op 0.83
Tree 40 250000 get(125000) 241.67 ns/op 228.22 ns/op 1.06
Tree 40 250000 set(125000) 1.1718 us/op 1.4383 us/op 0.81
Tree 40 250000 toArray() 24.070 ms/op 24.810 ms/op 0.97
Tree 40 250000 iterate all - toArray() + loop 23.872 ms/op 25.252 ms/op 0.95
Tree 40 250000 iterate all - get(i) 76.875 ms/op 78.896 ms/op 0.97
MutableVector 250000 create 15.632 ms/op 15.406 ms/op 1.01
MutableVector 250000 get(125000) 6.7830 ns/op 7.6170 ns/op 0.89
MutableVector 250000 set(125000) 321.51 ns/op 590.63 ns/op 0.54
MutableVector 250000 toArray() 4.0026 ms/op 4.9283 ms/op 0.81
MutableVector 250000 iterate all - toArray() + loop 4.0196 ms/op 4.7994 ms/op 0.84
MutableVector 250000 iterate all - get(i) 1.6493 ms/op 1.7937 ms/op 0.92
Array 250000 create 3.4616 ms/op 4.3540 ms/op 0.80
Array 250000 clone - spread 1.6278 ms/op 1.5474 ms/op 1.05
Array 250000 get(125000) 1.3390 ns/op 1.7390 ns/op 0.77
Array 250000 set(125000) 4.8600 ns/op 5.3690 ns/op 0.91
Array 250000 iterate all - loop 179.50 us/op 180.71 us/op 0.99
effectiveBalanceIncrements clone Uint8Array 300000 64.391 us/op 48.579 us/op 1.33
effectiveBalanceIncrements clone MutableVector 300000 521.00 ns/op 396.00 ns/op 1.32
effectiveBalanceIncrements rw all Uint8Array 300000 235.81 us/op 206.95 us/op 1.14
effectiveBalanceIncrements rw all MutableVector 300000 162.99 ms/op 103.46 ms/op 1.58
phase0 afterProcessEpoch - 250000 vs - 7PWei 131.85 ms/op 127.33 ms/op 1.04
phase0 beforeProcessEpoch - 250000 vs - 7PWei 65.419 ms/op 66.226 ms/op 0.99
altair processEpoch - mainnet_e81889 588.05 ms/op 559.10 ms/op 1.05
mainnet_e81889 - altair beforeProcessEpoch 100.88 ms/op 93.815 ms/op 1.08
mainnet_e81889 - altair processJustificationAndFinalization 23.211 us/op 17.811 us/op 1.30
mainnet_e81889 - altair processInactivityUpdates 9.0689 ms/op 6.6234 ms/op 1.37
mainnet_e81889 - altair processRewardsAndPenalties 75.178 ms/op 42.611 ms/op 1.76
mainnet_e81889 - altair processRegistryUpdates 3.6130 us/op 2.9660 us/op 1.22
mainnet_e81889 - altair processSlashings 1.1160 us/op 759.00 ns/op 1.47
mainnet_e81889 - altair processEth1DataReset 1.2910 us/op 1.8300 us/op 0.71
mainnet_e81889 - altair processEffectiveBalanceUpdates 4.6006 ms/op 1.4639 ms/op 3.14
mainnet_e81889 - altair processSlashingsReset 8.8680 us/op 7.9900 us/op 1.11
mainnet_e81889 - altair processRandaoMixesReset 10.116 us/op 7.9420 us/op 1.27
mainnet_e81889 - altair processHistoricalRootsUpdate 1.4340 us/op 1.5950 us/op 0.90
mainnet_e81889 - altair processParticipationFlagUpdates 2.7900 us/op 6.3540 us/op 0.44
mainnet_e81889 - altair processSyncCommitteeUpdates 1.3050 us/op 2.0070 us/op 0.65
mainnet_e81889 - altair afterProcessEpoch 129.89 ms/op 124.24 ms/op 1.05
capella processEpoch - mainnet_e217614 3.1599 s/op 2.5352 s/op 1.25
mainnet_e217614 - capella beforeProcessEpoch 706.50 ms/op 486.06 ms/op 1.45
mainnet_e217614 - capella processJustificationAndFinalization 41.950 us/op 19.133 us/op 2.19
mainnet_e217614 - capella processInactivityUpdates 38.147 ms/op 21.198 ms/op 1.80
mainnet_e217614 - capella processRewardsAndPenalties 567.60 ms/op 422.81 ms/op 1.34
mainnet_e217614 - capella processRegistryUpdates 46.490 us/op 17.112 us/op 2.72
mainnet_e217614 - capella processSlashings 2.0500 us/op 578.00 ns/op 3.55
mainnet_e217614 - capella processEth1DataReset 1.4920 us/op 452.00 ns/op 3.30
mainnet_e217614 - capella processEffectiveBalanceUpdates 7.2009 ms/op 5.6264 ms/op 1.28
mainnet_e217614 - capella processSlashingsReset 11.190 us/op 3.6630 us/op 3.05
mainnet_e217614 - capella processRandaoMixesReset 13.900 us/op 4.5600 us/op 3.05
mainnet_e217614 - capella processHistoricalRootsUpdate 1.9200 us/op 427.00 ns/op 4.50
mainnet_e217614 - capella processParticipationFlagUpdates 6.6010 us/op 1.4300 us/op 4.62
mainnet_e217614 - capella afterProcessEpoch 406.95 ms/op 301.82 ms/op 1.35
phase0 processEpoch - mainnet_e58758 638.36 ms/op 436.38 ms/op 1.46
mainnet_e58758 - phase0 beforeProcessEpoch 187.01 ms/op 125.38 ms/op 1.49
mainnet_e58758 - phase0 processJustificationAndFinalization 36.759 us/op 17.257 us/op 2.13
mainnet_e58758 - phase0 processRewardsAndPenalties 68.405 ms/op 37.873 ms/op 1.81
mainnet_e58758 - phase0 processRegistryUpdates 18.728 us/op 11.921 us/op 1.57
mainnet_e58758 - phase0 processSlashings 1.1690 us/op 420.00 ns/op 2.78
mainnet_e58758 - phase0 processEth1DataReset 1.0960 us/op 426.00 ns/op 2.57
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.6483 ms/op 1.1714 ms/op 1.41
mainnet_e58758 - phase0 processSlashingsReset 7.3170 us/op 3.0230 us/op 2.42
mainnet_e58758 - phase0 processRandaoMixesReset 11.672 us/op 5.8810 us/op 1.98
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.0080 us/op 543.00 ns/op 1.86
mainnet_e58758 - phase0 processParticipationRecordUpdates 9.3050 us/op 4.4510 us/op 2.09
mainnet_e58758 - phase0 afterProcessEpoch 111.56 ms/op 97.974 ms/op 1.14
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.5988 ms/op 1.3860 ms/op 1.15
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.0366 ms/op 1.9794 ms/op 1.03
altair processInactivityUpdates - 250000 normalcase 35.104 ms/op 23.606 ms/op 1.49
altair processInactivityUpdates - 250000 worstcase 32.457 ms/op 20.158 ms/op 1.61
phase0 processRegistryUpdates - 250000 normalcase 17.642 us/op 8.1010 us/op 2.18
phase0 processRegistryUpdates - 250000 badcase_full_deposits 619.26 us/op 410.16 us/op 1.51
phase0 processRegistryUpdates - 250000 worstcase 0.5 228.19 ms/op 125.88 ms/op 1.81
altair processRewardsAndPenalties - 250000 normalcase 100.11 ms/op 42.949 ms/op 2.33
altair processRewardsAndPenalties - 250000 worstcase 70.068 ms/op 40.880 ms/op 1.71
phase0 getAttestationDeltas - 250000 normalcase 16.652 ms/op 8.9342 ms/op 1.86
phase0 getAttestationDeltas - 250000 worstcase 15.073 ms/op 9.0759 ms/op 1.66
phase0 processSlashings - 250000 worstcase 152.25 us/op 82.023 us/op 1.86
altair processSyncCommitteeUpdates - 250000 207.02 ms/op 155.67 ms/op 1.33
BeaconState.hashTreeRoot - No change 946.00 ns/op 376.00 ns/op 2.52
BeaconState.hashTreeRoot - 1 full validator 190.57 us/op 122.80 us/op 1.55
BeaconState.hashTreeRoot - 32 full validator 2.4864 ms/op 1.5146 ms/op 1.64
BeaconState.hashTreeRoot - 512 full validator 26.192 ms/op 13.752 ms/op 1.90
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 232.04 us/op 145.10 us/op 1.60
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 3.3261 ms/op 2.1634 ms/op 1.54
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 46.055 ms/op 23.908 ms/op 1.93
BeaconState.hashTreeRoot - 1 balances 155.93 us/op 107.98 us/op 1.44
BeaconState.hashTreeRoot - 32 balances 1.3863 ms/op 1.2388 ms/op 1.12
BeaconState.hashTreeRoot - 512 balances 17.893 ms/op 13.398 ms/op 1.34
BeaconState.hashTreeRoot - 250000 balances 261.90 ms/op 229.58 ms/op 1.14
aggregationBits - 2048 els - zipIndexesInBitList 32.154 us/op 18.553 us/op 1.73
byteArrayEquals 32 83.088 ns/op 75.711 ns/op 1.10
Buffer.compare 32 62.341 ns/op 56.832 ns/op 1.10
byteArrayEquals 1024 2.4109 us/op 2.0780 us/op 1.16
Buffer.compare 1024 80.340 ns/op 71.998 ns/op 1.12
byteArrayEquals 16384 39.180 us/op 32.686 us/op 1.20
Buffer.compare 16384 328.54 ns/op 244.73 ns/op 1.34
byteArrayEquals 123687377 304.22 ms/op 263.96 ms/op 1.15
Buffer.compare 123687377 15.476 ms/op 8.9139 ms/op 1.74
byteArrayEquals 32 - diff last byte 99.423 ns/op 84.093 ns/op 1.18
Buffer.compare 32 - diff last byte 69.658 ns/op 58.951 ns/op 1.18
byteArrayEquals 1024 - diff last byte 2.6420 us/op 2.2338 us/op 1.18
Buffer.compare 1024 - diff last byte 92.732 ns/op 78.283 ns/op 1.18
byteArrayEquals 16384 - diff last byte 41.573 us/op 34.887 us/op 1.19
Buffer.compare 16384 - diff last byte 328.98 ns/op 301.11 ns/op 1.09
byteArrayEquals 123687377 - diff last byte 316.93 ms/op 272.26 ms/op 1.16
Buffer.compare 123687377 - diff last byte 11.742 ms/op 9.7619 ms/op 1.20
byteArrayEquals 32 - random bytes 7.4070 ns/op 6.2760 ns/op 1.18
Buffer.compare 32 - random bytes 73.088 ns/op 63.914 ns/op 1.14
byteArrayEquals 1024 - random bytes 7.3790 ns/op 7.1700 ns/op 1.03
Buffer.compare 1024 - random bytes 73.251 ns/op 63.377 ns/op 1.16
byteArrayEquals 16384 - random bytes 7.5230 ns/op 6.3050 ns/op 1.19
Buffer.compare 16384 - random bytes 73.215 ns/op 63.362 ns/op 1.16
byteArrayEquals 123687377 - random bytes 22.110 ns/op 9.2900 ns/op 2.38
Buffer.compare 123687377 - random bytes 91.180 ns/op 76.700 ns/op 1.19
regular array get 100000 times 57.507 us/op 46.504 us/op 1.24
wrappedArray get 100000 times 57.147 us/op 46.481 us/op 1.23
arrayWithProxy get 100000 times 19.451 ms/op 14.805 ms/op 1.31
ssz.Root.equals 72.382 ns/op 58.481 ns/op 1.24
byteArrayEquals 64.747 ns/op 57.281 ns/op 1.13
Buffer.compare 17.895 ns/op 12.741 ns/op 1.40
shuffle list - 16384 els 8.2966 ms/op 7.3652 ms/op 1.13
shuffle list - 250000 els 121.40 ms/op 106.96 ms/op 1.14
processSlot - 1 slots 27.129 us/op 18.632 us/op 1.46
processSlot - 32 slots 5.2467 ms/op 3.2672 ms/op 1.61
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 87.782 ms/op 61.870 ms/op 1.42
getCommitteeAssignments - req 1 vs - 250000 vc 3.2964 ms/op 2.5147 ms/op 1.31
getCommitteeAssignments - req 100 vs - 250000 vc 4.6867 ms/op 3.7257 ms/op 1.26
getCommitteeAssignments - req 1000 vs - 250000 vc 5.0341 ms/op 4.0430 ms/op 1.25
findModifiedValidators - 10000 modified validators 914.49 ms/op 531.88 ms/op 1.72
findModifiedValidators - 1000 modified validators 634.23 ms/op 467.55 ms/op 1.36
findModifiedValidators - 100 modified validators 599.23 ms/op 464.25 ms/op 1.29
findModifiedValidators - 10 modified validators 624.08 ms/op 427.86 ms/op 1.46
findModifiedValidators - 1 modified validators 534.38 ms/op 425.03 ms/op 1.26
findModifiedValidators - no difference 633.49 ms/op 420.26 ms/op 1.51
compare ViewDUs 5.6061 s/op 4.8502 s/op 1.16
compare each validator Uint8Array 2.2289 s/op 2.0767 s/op 1.07
compare ViewDU to Uint8Array 1.7209 s/op 1.4589 s/op 1.18
migrate state 1000000 validators, 24 modified, 0 new 1.0485 s/op 881.48 ms/op 1.19
migrate state 1000000 validators, 1700 modified, 1000 new 1.4385 s/op 1.0784 s/op 1.33
migrate state 1000000 validators, 3400 modified, 2000 new 2.0124 s/op 1.3290 s/op 1.51
migrate state 1500000 validators, 24 modified, 0 new 980.21 ms/op 770.13 ms/op 1.27
migrate state 1500000 validators, 1700 modified, 1000 new 1.2343 s/op 1.1069 s/op 1.12
migrate state 1500000 validators, 3400 modified, 2000 new 1.5147 s/op 1.2666 s/op 1.20
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.5800 ns/op 4.2500 ns/op 1.31
state getBlockRootAtSlot - 250000 vs - 7PWei 914.50 ns/op 849.71 ns/op 1.08
computeProposers - vc 250000 11.108 ms/op 8.8213 ms/op 1.26
computeEpochShuffling - vc 250000 111.10 ms/op 103.30 ms/op 1.08
getNextSyncCommittee - vc 250000 182.06 ms/op 147.99 ms/op 1.23
computeSigningRoot for AttestationData 36.266 us/op 25.285 us/op 1.43
hash AttestationData serialized data then Buffer.toString(base64) 2.7073 us/op 2.3199 us/op 1.17
toHexString serialized data 1.6036 us/op 1.1311 us/op 1.42
Buffer.toString(base64) 292.40 ns/op 227.78 ns/op 1.28

Please sign in to comment.