@lodestar/beacon-node 1.48.0-dev.acdde443d2 → 1.48.0-dev.af8bc602aa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +4 -4
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/chain/archiveStore/archiveStore.d.ts +0 -1
  5. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  6. package/lib/chain/archiveStore/archiveStore.js +0 -1
  7. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  8. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  9. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
  10. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  11. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  12. package/lib/chain/archiveStore/historicalState/metrics.js +1 -12
  13. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  14. package/lib/chain/archiveStore/historicalState/types.d.ts +0 -2
  15. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
  16. package/lib/chain/archiveStore/historicalState/types.js.map +1 -1
  17. package/lib/chain/archiveStore/historicalState/worker.js +1 -4
  18. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js +34 -31
  21. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  22. package/lib/chain/blocks/index.d.ts.map +1 -1
  23. package/lib/chain/blocks/index.js +2 -3
  24. package/lib/chain/blocks/index.js.map +1 -1
  25. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  26. package/lib/chain/blocks/writeBlockInputToDb.js +16 -9
  27. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  28. package/lib/chain/chain.d.ts +3 -4
  29. package/lib/chain/chain.d.ts.map +1 -1
  30. package/lib/chain/chain.js +35 -60
  31. package/lib/chain/chain.js.map +1 -1
  32. package/lib/chain/errors/blockError.d.ts +7 -19
  33. package/lib/chain/errors/blockError.d.ts.map +1 -1
  34. package/lib/chain/errors/blockError.js +2 -2
  35. package/lib/chain/errors/blockError.js.map +1 -1
  36. package/lib/chain/errors/dataColumnSidecarError.d.ts +2 -15
  37. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  38. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  39. package/lib/chain/errors/executionPayloadEnvelope.d.ts +11 -10
  40. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  41. package/lib/chain/errors/executionPayloadEnvelope.js +2 -0
  42. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  43. package/lib/chain/interface.d.ts +2 -2
  44. package/lib/chain/interface.d.ts.map +1 -1
  45. package/lib/chain/prepareNextSlot.js +13 -13
  46. package/lib/chain/prepareNextSlot.js.map +1 -1
  47. package/lib/chain/validation/block.d.ts.map +1 -1
  48. package/lib/chain/validation/block.js +54 -35
  49. package/lib/chain/validation/block.js.map +1 -1
  50. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  51. package/lib/chain/validation/dataColumnSidecar.js +13 -38
  52. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  53. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  54. package/lib/chain/validation/executionPayloadEnvelope.js +29 -10
  55. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  56. package/lib/db/beacon.d.ts +5 -14
  57. package/lib/db/beacon.d.ts.map +1 -1
  58. package/lib/db/beacon.js +3 -17
  59. package/lib/db/beacon.js.map +1 -1
  60. package/lib/db/index.d.ts +0 -1
  61. package/lib/db/index.d.ts.map +1 -1
  62. package/lib/db/interface.d.ts +1 -8
  63. package/lib/db/interface.d.ts.map +1 -1
  64. package/lib/db/repositories/blockArchive.d.ts +1 -8
  65. package/lib/db/repositories/blockArchive.d.ts.map +1 -1
  66. package/lib/db/repositories/blockArchive.js +28 -65
  67. package/lib/db/repositories/blockArchive.js.map +1 -1
  68. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -1
  69. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  70. package/lib/db/repositories/blockArchiveIndex.js +7 -3
  71. package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
  72. package/lib/metrics/metrics/lodestar.d.ts +0 -18
  73. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  74. package/lib/metrics/metrics/lodestar.js +1 -55
  75. package/lib/metrics/metrics/lodestar.js.map +1 -1
  76. package/lib/monitoring/clientStats.js +1 -1
  77. package/lib/monitoring/clientStats.js.map +1 -1
  78. package/lib/network/gossip/encoding.d.ts.map +1 -1
  79. package/lib/network/gossip/encoding.js +6 -0
  80. package/lib/network/gossip/encoding.js.map +1 -1
  81. package/lib/network/gossip/topic.d.ts +1 -2
  82. package/lib/network/gossip/topic.d.ts.map +1 -1
  83. package/lib/network/gossip/topic.js +20 -4
  84. package/lib/network/gossip/topic.js.map +1 -1
  85. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  86. package/lib/network/processor/gossipHandlers.js +7 -6
  87. package/lib/network/processor/gossipHandlers.js.map +1 -1
  88. package/lib/network/processor/index.d.ts +3 -49
  89. package/lib/network/processor/index.d.ts.map +1 -1
  90. package/lib/network/processor/index.js +98 -232
  91. package/lib/network/processor/index.js.map +1 -1
  92. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  93. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +91 -112
  94. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  95. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  96. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +0 -2
  97. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  98. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  99. package/lib/network/reqresp/protocols.js +22 -6
  100. package/lib/network/reqresp/protocols.js.map +1 -1
  101. package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts +1 -2
  102. package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -1
  103. package/lib/network/reqresp/utils/dataColumnResponseValidation.js +9 -14
  104. package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
  105. package/lib/node/nodejs.d.ts +1 -2
  106. package/lib/node/nodejs.d.ts.map +1 -1
  107. package/lib/node/nodejs.js +2 -4
  108. package/lib/node/nodejs.js.map +1 -1
  109. package/lib/util/sszBytes.d.ts +0 -6
  110. package/lib/util/sszBytes.d.ts.map +1 -1
  111. package/lib/util/sszBytes.js +1 -1
  112. package/lib/util/sszBytes.js.map +1 -1
  113. package/package.json +16 -16
  114. package/src/api/impl/beacon/blocks/index.ts +4 -8
  115. package/src/chain/archiveStore/archiveStore.ts +1 -6
  116. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
  117. package/src/chain/archiveStore/historicalState/metrics.ts +1 -14
  118. package/src/chain/archiveStore/historicalState/types.ts +0 -2
  119. package/src/chain/archiveStore/historicalState/worker.ts +1 -4
  120. package/src/chain/archiveStore/utils/archiveBlocks.ts +39 -34
  121. package/src/chain/blocks/index.ts +2 -13
  122. package/src/chain/blocks/writeBlockInputToDb.ts +17 -10
  123. package/src/chain/chain.ts +34 -75
  124. package/src/chain/errors/blockError.ts +10 -22
  125. package/src/chain/errors/dataColumnSidecarError.ts +8 -24
  126. package/src/chain/errors/executionPayloadEnvelope.ts +11 -14
  127. package/src/chain/interface.ts +2 -2
  128. package/src/chain/prepareNextSlot.ts +16 -16
  129. package/src/chain/validation/block.ts +70 -35
  130. package/src/chain/validation/dataColumnSidecar.ts +14 -47
  131. package/src/chain/validation/executionPayloadEnvelope.ts +37 -10
  132. package/src/db/beacon.ts +6 -33
  133. package/src/db/index.ts +0 -1
  134. package/src/db/interface.ts +1 -9
  135. package/src/db/repositories/blockArchive.ts +30 -89
  136. package/src/db/repositories/blockArchiveIndex.ts +9 -4
  137. package/src/metrics/metrics/lodestar.ts +1 -57
  138. package/src/monitoring/clientStats.ts +1 -1
  139. package/src/network/gossip/encoding.ts +6 -0
  140. package/src/network/gossip/topic.ts +25 -3
  141. package/src/network/processor/gossipHandlers.ts +11 -11
  142. package/src/network/processor/index.ts +148 -263
  143. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +105 -139
  144. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +0 -2
  145. package/src/network/reqresp/protocols.ts +24 -7
  146. package/src/network/reqresp/utils/dataColumnResponseValidation.ts +7 -15
  147. package/src/node/nodejs.ts +1 -6
  148. package/src/util/sszBytes.ts +1 -1
  149. package/lib/db/dataColumnStore.d.ts +0 -39
  150. package/lib/db/dataColumnStore.d.ts.map +0 -1
  151. package/lib/db/dataColumnStore.js +0 -81
  152. package/lib/db/dataColumnStore.js.map +0 -1
  153. package/lib/db/flatFileStore/atomicWrite.d.ts +0 -8
  154. package/lib/db/flatFileStore/atomicWrite.d.ts.map +0 -1
  155. package/lib/db/flatFileStore/atomicWrite.js +0 -61
  156. package/lib/db/flatFileStore/atomicWrite.js.map +0 -1
  157. package/lib/db/flatFileStore/dcolFormat.d.ts +0 -90
  158. package/lib/db/flatFileStore/dcolFormat.d.ts.map +0 -1
  159. package/lib/db/flatFileStore/dcolFormat.js +0 -286
  160. package/lib/db/flatFileStore/dcolFormat.js.map +0 -1
  161. package/lib/db/flatFileStore/errors.d.ts +0 -82
  162. package/lib/db/flatFileStore/errors.d.ts.map +0 -1
  163. package/lib/db/flatFileStore/errors.js +0 -32
  164. package/lib/db/flatFileStore/errors.js.map +0 -1
  165. package/lib/db/flatFileStore/flatFileStore.d.ts +0 -41
  166. package/lib/db/flatFileStore/flatFileStore.d.ts.map +0 -1
  167. package/lib/db/flatFileStore/flatFileStore.js +0 -251
  168. package/lib/db/flatFileStore/flatFileStore.js.map +0 -1
  169. package/lib/db/flatFileStore/index.d.ts +0 -4
  170. package/lib/db/flatFileStore/index.d.ts.map +0 -1
  171. package/lib/db/flatFileStore/index.js +0 -2
  172. package/lib/db/flatFileStore/index.js.map +0 -1
  173. package/lib/db/flatFileStore/interface.d.ts +0 -25
  174. package/lib/db/flatFileStore/interface.d.ts.map +0 -1
  175. package/lib/db/flatFileStore/interface.js +0 -2
  176. package/lib/db/flatFileStore/interface.js.map +0 -1
  177. package/lib/db/flatFileStore/metrics.d.ts +0 -24
  178. package/lib/db/flatFileStore/metrics.d.ts.map +0 -1
  179. package/lib/db/flatFileStore/metrics.js +0 -25
  180. package/lib/db/flatFileStore/metrics.js.map +0 -1
  181. package/lib/db/flatFileStore/path.d.ts +0 -9
  182. package/lib/db/flatFileStore/path.d.ts.map +0 -1
  183. package/lib/db/flatFileStore/path.js +0 -21
  184. package/lib/db/flatFileStore/path.js.map +0 -1
  185. package/lib/db/flatFileStore/slotIndex.d.ts +0 -14
  186. package/lib/db/flatFileStore/slotIndex.d.ts.map +0 -1
  187. package/lib/db/flatFileStore/slotIndex.js +0 -46
  188. package/lib/db/flatFileStore/slotIndex.js.map +0 -1
  189. package/lib/db/flatFileStore/snappy.d.ts +0 -3
  190. package/lib/db/flatFileStore/snappy.d.ts.map +0 -1
  191. package/lib/db/flatFileStore/snappy.js +0 -12
  192. package/lib/db/flatFileStore/snappy.js.map +0 -1
  193. package/src/db/dataColumnStore.ts +0 -113
  194. package/src/db/flatFileStore/atomicWrite.ts +0 -65
  195. package/src/db/flatFileStore/dcolFormat.ts +0 -389
  196. package/src/db/flatFileStore/errors.ts +0 -53
  197. package/src/db/flatFileStore/flatFileStore.ts +0 -310
  198. package/src/db/flatFileStore/index.ts +0 -3
  199. package/src/db/flatFileStore/interface.ts +0 -21
  200. package/src/db/flatFileStore/metrics.ts +0 -48
  201. package/src/db/flatFileStore/path.ts +0 -32
  202. package/src/db/flatFileStore/slotIndex.ts +0 -56
  203. package/src/db/flatFileStore/snappy.ts +0 -14
@@ -1,17 +1,16 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {Db, DbBatch, FilterOptions, KeyValue, Repository} from "@lodestar/db";
2
+ import {Db, FilterOptions, KeyValue, Repository} from "@lodestar/db";
3
3
  import {Root, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
4
- import {bytesToInt, intToBytes} from "@lodestar/utils";
4
+ import {bytesToInt} from "@lodestar/utils";
5
5
  import {getSignedBlockTypeFromBytes} from "../../util/multifork.js";
6
6
  import {Bucket, getBucketNameByValue} from "../buckets.js";
7
7
  import {
8
8
  deleteParentRootIndex,
9
9
  deleteRootIndex,
10
10
  getParentRootIndex,
11
- getParentRootIndexKey,
12
11
  getRootIndex,
13
- getRootIndexKey,
14
- getSlotIndexKey,
12
+ storeParentRootIndex,
13
+ storeRootIndex,
15
14
  } from "./blockArchiveIndex.js";
16
15
 
17
16
  export interface BlockFilterOptions extends FilterOptions<Slot> {
@@ -57,91 +56,37 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
57
56
  // Overrides to index
58
57
 
59
58
  async put(key: Slot, value: SignedBeaconBlock): Promise<void> {
60
- await this.batchPut([{key, value}]);
61
- }
62
-
63
- async putBinary(key: Slot, value: Uint8Array): Promise<void> {
64
- const block = this.decodeValue(value);
65
- await this.batchPutBinary([
66
- {
67
- key,
68
- value,
69
- slot: block.message.slot,
70
- blockRoot: this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message),
71
- parentRoot: block.message.parentRoot,
72
- },
59
+ const blockRoot = this.config.getForkTypes(value.message.slot).BeaconBlock.hashTreeRoot(value.message);
60
+ const slot = value.message.slot;
61
+ await Promise.all([
62
+ super.put(key, value),
63
+ storeRootIndex(this.db, slot, blockRoot),
64
+ storeParentRootIndex(this.db, slot, value.message.parentRoot),
73
65
  ]);
74
66
  }
75
67
 
76
68
  async batchPut(items: KeyValue<Slot, SignedBeaconBlock>[]): Promise<void> {
77
- await this.batchPutBinary(
78
- items.map(({key, value}) => ({
79
- key,
80
- value: this.encodeValue(value),
81
- slot: value.message.slot,
82
- blockRoot: this.config.getForkTypes(value.message.slot).BeaconBlock.hashTreeRoot(value.message),
83
- parentRoot: value.message.parentRoot,
84
- }))
85
- );
69
+ await Promise.all([
70
+ super.batchPut(items),
71
+ Array.from(items).map((item) => {
72
+ const slot = item.value.message.slot;
73
+ const blockRoot = this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(item.value.message);
74
+ return storeRootIndex(this.db, slot, blockRoot);
75
+ }),
76
+ Array.from(items).map((item) => {
77
+ const slot = item.value.message.slot;
78
+ const parentRoot = item.value.message.parentRoot;
79
+ return storeParentRootIndex(this.db, slot, parentRoot);
80
+ }),
81
+ ]);
86
82
  }
87
83
 
88
84
  async batchPutBinary(items: BlockArchiveBatchPutBinaryItem[]): Promise<void> {
89
- await this.db.batchPut(
90
- items.flatMap((item) => this.indexedBlockEntries(item)),
91
- this.dbReqOpts
92
- );
93
- }
94
-
95
- async delete(slot: Slot): Promise<void> {
96
- await this.batchDelete([slot]);
97
- }
98
-
99
- async batchDelete(slots: Slot[]): Promise<void> {
100
- await this.db.batchDelete(
101
- slots.flatMap((slot) => [this.encodeKey(slot), getSlotIndexKey(slot)]),
102
- this.dbReqOpts
103
- );
104
- }
105
-
106
- async batch(operations: DbBatch<Slot, SignedBeaconBlock>): Promise<void> {
107
- await this.batchBinary(
108
- operations.map((operation) =>
109
- operation.type === "put" ? {...operation, value: this.encodeValue(operation.value)} : operation
110
- )
111
- );
112
- }
113
-
114
- async batchBinary(operations: DbBatch<Slot, Uint8Array>): Promise<void> {
115
- const batch: DbBatch<Uint8Array, Uint8Array> = [];
116
- for (const operation of operations) {
117
- if (operation.type === "del") {
118
- batch.push(
119
- {type: "del", key: this.encodeKey(operation.key)},
120
- {type: "del", key: getSlotIndexKey(operation.key)}
121
- );
122
- } else {
123
- const block = this.decodeValue(operation.value);
124
- const entries = this.indexedBlockEntries({
125
- key: operation.key,
126
- value: operation.value,
127
- slot: block.message.slot,
128
- blockRoot: this.config.getForkTypes(block.message.slot).BeaconBlock.hashTreeRoot(block.message),
129
- parentRoot: block.message.parentRoot,
130
- });
131
- batch.push(...entries.map((entry) => ({type: "put" as const, ...entry})));
132
- }
133
- }
134
- await this.db.batch(batch, this.dbReqOpts);
135
- }
136
-
137
- private indexedBlockEntries(item: BlockArchiveBatchPutBinaryItem): KeyValue<Uint8Array, Uint8Array>[] {
138
- const slotBytes = intToBytes(item.slot, 8, "be");
139
- return [
140
- {key: this.encodeKey(item.key), value: item.value},
141
- {key: getRootIndexKey(item.blockRoot), value: slotBytes},
142
- {key: getParentRootIndexKey(item.parentRoot), value: slotBytes},
143
- {key: getSlotIndexKey(item.key), value: item.blockRoot},
144
- ];
85
+ await Promise.all([
86
+ super.batchPutBinary(items),
87
+ Array.from(items).map((item) => storeRootIndex(this.db, item.slot, item.blockRoot)),
88
+ Array.from(items).map((item) => storeParentRootIndex(this.db, item.slot, item.parentRoot)),
89
+ ]);
145
90
  }
146
91
 
147
92
  async remove(value: SignedBeaconBlock): Promise<void> {
@@ -155,10 +100,10 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
155
100
  async batchRemove(values: SignedBeaconBlock[]): Promise<void> {
156
101
  await Promise.all([
157
102
  super.batchRemove(values),
158
- ...values.map((value) =>
103
+ Array.from(values).map((value) =>
159
104
  deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value)
160
105
  ),
161
- ...values.map((value) => deleteParentRootIndex(this.db, value)),
106
+ Array.from(values).map((value) => deleteParentRootIndex(this.db, value)),
162
107
  ]);
163
108
  }
164
109
 
@@ -195,10 +140,6 @@ export class BlockArchiveRepository extends Repository<Slot, SignedBeaconBlock>
195
140
  return slot !== null ? this.get(slot) : null;
196
141
  }
197
142
 
198
- async getRootBySlot(slot: Slot): Promise<Root | null> {
199
- return this.db.get(getSlotIndexKey(slot), {bucketId: getBucketNameByValue(Bucket.index_mainChain)});
200
- }
201
-
202
143
  async getSlotByRoot(root: Root): Promise<Slot | null> {
203
144
  return this.parseSlot(await getRootIndex(this.db, root));
204
145
  }
@@ -1,6 +1,7 @@
1
1
  import {Db, encodeKey} from "@lodestar/db";
2
2
  import {ForkAll} from "@lodestar/params";
3
3
  import {Root, SSZTypesFor, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
4
+ import {intToBytes} from "@lodestar/utils";
4
5
  import {Bucket, getBucketNameByValue} from "../buckets.js";
5
6
 
6
7
  export const rootIndexBucketId = getBucketNameByValue(Bucket.index_blockArchiveRootIndex);
@@ -14,6 +15,14 @@ export async function getParentRootIndex(db: Db, parentRoot: Root): Promise<Uint
14
15
  return db.get(getParentRootIndexKey(parentRoot), {bucketId: parentRootIndexBucketId});
15
16
  }
16
17
 
18
+ export async function storeRootIndex(db: Db, slot: Slot, blockRoot: Root): Promise<void> {
19
+ return db.put(getRootIndexKey(blockRoot), intToBytes(slot, 8, "be"), {bucketId: rootIndexBucketId});
20
+ }
21
+
22
+ export async function storeParentRootIndex(db: Db, slot: Slot, parentRoot: Root): Promise<void> {
23
+ return db.put(getParentRootIndexKey(parentRoot), intToBytes(slot, 8, "be"), {bucketId: parentRootIndexBucketId});
24
+ }
25
+
17
26
  export async function deleteRootIndex(
18
27
  db: Db,
19
28
  signedBeaconBlockType: SSZTypesFor<ForkAll, "SignedBeaconBlock">,
@@ -34,7 +43,3 @@ export function getParentRootIndexKey(parentRoot: Root): Uint8Array {
34
43
  export function getRootIndexKey(root: Root): Uint8Array {
35
44
  return encodeKey(Bucket.index_blockArchiveRootIndex, root);
36
45
  }
37
-
38
- export function getSlotIndexKey(slot: Slot): Uint8Array {
39
- return encodeKey(Bucket.index_mainChain, slot);
40
- }
@@ -21,7 +21,6 @@ import {ReprocessStatus} from "../../chain/reprocess.js";
21
21
  import {RejectReason} from "../../chain/seenCache/seenAttestationData.js";
22
22
  import {CacheItemType} from "../../chain/stateCache/types.js";
23
23
  import {OpSource} from "../../chain/validatorMonitor.js";
24
- import type {FlatFileStoreOperation} from "../../db/flatFileStore/metrics.js";
25
24
  import {ExecutionPayloadStatus} from "../../execution/index.js";
26
25
  import {GossipType} from "../../network/index.js";
27
26
  import {CannotAcceptWorkReason, ReprocessRejectReason} from "../../network/processor/index.js";
@@ -2100,7 +2099,7 @@ export function createLodestarMetrics(
2100
2099
  }),
2101
2100
  dbSizeTotal: register.gauge({
2102
2101
  name: "lodestar_db_size_bytes_total",
2103
- help: "Approximate number of bytes of file system space used by LevelDB",
2102
+ help: "Approximate number of bytes of file system space used by db",
2104
2103
  }),
2105
2104
  dbApproximateSizeTime: register.histogram({
2106
2105
  name: "lodestar_db_approximate_size_time_seconds",
@@ -2109,61 +2108,6 @@ export function createLodestarMetrics(
2109
2108
  }),
2110
2109
  },
2111
2110
 
2112
- flatFileStore: {
2113
- operationDuration: {
2114
- read: register.histogram({
2115
- name: "lodestar_flat_file_store_read_duration_seconds",
2116
- help: "Duration of flat file store reads in seconds",
2117
- buckets: [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05],
2118
- }),
2119
- write: register.histogram({
2120
- name: "lodestar_flat_file_store_write_duration_seconds",
2121
- help: "Duration of flat file store writes in seconds",
2122
- buckets: [0.005, 0.01, 0.05, 0.1, 0.5, 1],
2123
- }),
2124
- delete: register.histogram({
2125
- name: "lodestar_flat_file_store_delete_duration_seconds",
2126
- help: "Duration of flat file store deletions in seconds",
2127
- buckets: [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05],
2128
- }),
2129
- prune: register.histogram({
2130
- name: "lodestar_flat_file_store_prune_duration_seconds",
2131
- help: "Duration of flat file store pruning in seconds",
2132
- buckets: [0.0005, 0.01, 0.05, 0.5, 5, 30],
2133
- }),
2134
- },
2135
- operationErrors: register.counter<{operation: FlatFileStoreOperation}>({
2136
- name: "lodestar_flat_file_store_operation_errors_total",
2137
- help: "Total count of failed flat file store operations",
2138
- labelNames: ["operation"],
2139
- }),
2140
- readBytes: register.counter({
2141
- name: "lodestar_flat_file_store_read_bytes_total",
2142
- help: "Total bytes read from flat file storage",
2143
- }),
2144
- writeBytes: register.counter({
2145
- name: "lodestar_flat_file_store_write_bytes_total",
2146
- help: "Total bytes written to flat file storage",
2147
- }),
2148
- prunedDirectories: register.counter({
2149
- name: "lodestar_flat_file_store_pruned_directories_total",
2150
- help: "Total count of slot directories pruned from flat file storage",
2151
- }),
2152
- slotIndexSize: register.gauge({
2153
- name: "lodestar_flat_file_store_indexed_slots",
2154
- help: "Count of indexed flat file slot directories, including empty directories awaiting pruning",
2155
- }),
2156
- startupDuration: register.histogram({
2157
- name: "lodestar_flat_file_store_startup_duration_seconds",
2158
- help: "Duration of flat file store slot index reconstruction in seconds",
2159
- buckets: [0.1, 0.5, 1, 5, 10, 30, 60, 300],
2160
- }),
2161
- startupErrors: register.counter({
2162
- name: "lodestar_flat_file_store_startup_errors_total",
2163
- help: "Total count of flat file store startup failures",
2164
- }),
2165
- },
2166
-
2167
2111
  pruneHistory: {
2168
2112
  pruneCount: register.gauge({
2169
2113
  name: "lodestar_prune_history_prune_count_total",
@@ -107,7 +107,7 @@ function createBeaconNodeStats(): ClientStats {
107
107
  metricName: "lodestar_db_size_bytes_total",
108
108
  jsonType: JsonType.Number,
109
109
  defaultValue: 0,
110
- description: "Amount of bytes consumed on disk by the beacon node's LevelDB database",
110
+ description: "Amount of bytes consumed on disk by the beacon node's database",
111
111
  }),
112
112
  networkLibp2pBytesTotalReceive: new MetricProperty({
113
113
  jsonKey: "network_libp2p_bytes_total_receive",
@@ -123,6 +123,9 @@ export class DataTransformSnappy implements DataTransform {
123
123
  if (uncompressedDataLength > maxSize) {
124
124
  throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${maxSize}`);
125
125
  }
126
+ if (uncompressedDataLength > sszType.maxSize) {
127
+ throw Error(`ssz_snappy decoded data length ${uncompressedDataLength} > ${sszType.maxSize}`);
128
+ }
126
129
 
127
130
  // Only after sanity length checks, we can decompress the data
128
131
  // Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
@@ -143,6 +146,9 @@ export class DataTransformSnappy implements DataTransform {
143
146
  if (data.length > maxSize) {
144
147
  throw Error(`ssz_snappy encoded data length ${data.length} > ${maxSize}`);
145
148
  }
149
+ if (data.length > sszType.maxSize) {
150
+ throw Error(`ssz_snappy encoded data length ${data.length} > ${sszType.maxSize}`);
151
+ }
146
152
 
147
153
  // Using Buffer.alloc() instead of Buffer.allocUnsafe() to mitigate high GC pressure observed in some environments
148
154
  const compressedData = Buffer.alloc(snappyWasm.max_compress_len(data.length));
@@ -4,11 +4,17 @@ import {
4
4
  ATTESTATION_SUBNET_COUNT,
5
5
  ForkName,
6
6
  ForkSeq,
7
+ MAX_ATTESTER_SLASHING_SIZE,
8
+ MAX_DATA_COLUMN_SIDECAR_SIZE,
9
+ MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
10
+ MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
11
+ MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE,
7
12
  SYNC_COMMITTEE_SUBNET_COUNT,
8
13
  isForkPostAltair,
9
14
  isForkPostElectra,
10
15
  isForkPostFulu,
11
16
  isForkPostGloas,
17
+ isForkPostHeze,
12
18
  } from "@lodestar/params";
13
19
  import {Attestation, SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
14
20
  import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
@@ -133,11 +139,27 @@ export function getGossipSSZType(topic: GossipTopic) {
133
139
  }
134
140
 
135
141
  /**
136
- * Return the maximum uncompressed SSZ byte length accepted for a gossip object, the SSZ type max size
137
- * or MAX_PAYLOAD_SIZE, whichever is smaller.
142
+ * Return the maximum uncompressed SSZ byte length accepted for a gossip object.
138
143
  */
139
144
  export function getGossipSSZMaxSize(topic: GossipTopic, maxPayloadSize: number, sszType?: CompositeTypeAny): number {
140
- return Math.min((sszType ?? getGossipSSZType(topic)).maxSize, maxPayloadSize);
145
+ const {fork} = topic.boundary;
146
+ // Gloas progressive containers have broad theoretical SSZ max sizes; use the preset p2p bounds instead.
147
+ switch (topic.type) {
148
+ case GossipType.beacon_block:
149
+ return maxPayloadSize;
150
+ case GossipType.beacon_aggregate_and_proof:
151
+ return isForkPostGloas(fork) ? MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
152
+ case GossipType.attester_slashing:
153
+ return isForkPostGloas(fork) ? MAX_ATTESTER_SLASHING_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
154
+ case GossipType.data_column_sidecar:
155
+ return isForkPostGloas(fork) ? MAX_DATA_COLUMN_SIDECAR_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
156
+ case GossipType.execution_payload:
157
+ return maxPayloadSize;
158
+ case GossipType.execution_payload_bid:
159
+ return isForkPostHeze(fork) ? MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE : MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE;
160
+ default:
161
+ return (sszType ?? getGossipSSZType(topic)).maxSize;
162
+ }
141
163
  }
142
164
 
143
165
  /**
@@ -27,7 +27,7 @@ import {
27
27
  ssz,
28
28
  sszTypesFor,
29
29
  } from "@lodestar/types";
30
- import {LogLevel, Logger, toHex, toRootHex} from "@lodestar/utils";
30
+ import {LogLevel, Logger, prettyBytes, toHex, toRootHex} from "@lodestar/utils";
31
31
  import {
32
32
  BlockInput,
33
33
  BlockInputColumns,
@@ -157,6 +157,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
157
157
  const slot = signedBlock.message.slot;
158
158
  const forkTypes = config.getForkTypes(slot);
159
159
  const blockRootHex = toRootHex(forkTypes.BeaconBlock.hashTreeRoot(signedBlock.message));
160
+ const blockShortHex = prettyBytes(blockRootHex);
160
161
  const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
161
162
  const recvToValLatency = Date.now() / 1000 - seenTimestampSec;
162
163
 
@@ -166,7 +167,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
166
167
 
167
168
  const logCtx = {
168
169
  slot,
169
- root: blockRootHex,
170
170
  currentSlot: chain.clock.currentSlot,
171
171
  peerId: peerIdStr,
172
172
  delaySec,
@@ -227,7 +227,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
227
227
  return blockInput;
228
228
  } catch (e) {
229
229
  if (e instanceof BlockGossipError) {
230
- logger.debug("Gossip block has error", {slot, root: blockRootHex, code: e.type.code});
230
+ logger.debug("Gossip block has error", {slot, root: blockShortHex, code: e.type.code});
231
231
  if (
232
232
  (e.type.code === BlockErrorCode.PARENT_BLOCK_UNKNOWN ||
233
233
  e.type.code === BlockErrorCode.PARENT_PAYLOAD_UNKNOWN) &&
@@ -249,12 +249,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
249
249
  throw e;
250
250
  }
251
251
 
252
- chain.persistInvalidSszValue(
253
- forkTypes.SignedBeaconBlock,
254
- signedBlock,
255
- `gossip_reject_slot_${slot}`,
256
- blockRootHex
257
- );
252
+ chain.persistInvalidSszValue(forkTypes.SignedBeaconBlock, signedBlock, `gossip_reject_slot_${slot}`);
258
253
  }
259
254
 
260
255
  // REJECT or unexpected (non-BlockGossipError) error: drop the optimistically-added entries from
@@ -284,6 +279,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
284
279
  const slot = blobBlockHeader.slot;
285
280
  const fork = config.getForkName(slot);
286
281
  const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobBlockHeader));
282
+ const blockShortHex = prettyBytes(blockRootHex);
287
283
 
288
284
  const delaySec = chain.clock.secFromSlot(slot, seenTimestampSec);
289
285
  const recvToValLatency = Date.now() / 1000 - seenTimestampSec;
@@ -336,7 +332,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
336
332
  if (e instanceof BlobSidecarGossipError) {
337
333
  // Don't trigger this yet if full block and blobs haven't arrived yet
338
334
  if (e.type.code === BlobSidecarErrorCode.PARENT_UNKNOWN) {
339
- logger.debug("Gossip blob has error", {slot, root: blockRootHex, code: e.type.code});
335
+ logger.debug("Gossip blob has error", {slot, root: blockShortHex, code: e.type.code});
340
336
  // no need to trigger `unknownBlockParent` event here, as we already did it in `validateBeaconBlock()`
341
337
  //
342
338
  // TODO(fulu): is this note above correct? Could have random blob that we see that could trigger
@@ -700,7 +696,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
700
696
  logLevel = LogLevel.error;
701
697
  }
702
698
  metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"});
703
- logger[logLevel]("Error processing block", {slot, root: blockInput.blockRootHex, peer: peerIdStr}, e as Error);
699
+ logger[logLevel](
700
+ "Error processing block",
701
+ {slot, peer: peerIdStr, blockRoot: prettyBytes(blockInput.blockRootHex)},
702
+ e as Error
703
+ );
704
704
  // TODO(fulu): Revisit when we prune block inputs
705
705
  chain.seenBlockInputCache.prune(blockInput.blockRootHex);
706
706
  });