@lodestar/beacon-node 1.45.0-dev.d7859e978b → 1.45.0-dev.e10fb5e991

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 (93) hide show
  1. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/pool/index.js +0 -1
  3. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  4. package/lib/api/impl/validator/index.d.ts.map +1 -1
  5. package/lib/api/impl/validator/index.js +9 -3
  6. package/lib/api/impl/validator/index.js.map +1 -1
  7. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  8. package/lib/chain/blocks/importBlock.js +9 -4
  9. package/lib/chain/blocks/importBlock.js.map +1 -1
  10. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -2
  11. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  12. package/lib/chain/blocks/payloadEnvelopeProcessor.js +17 -17
  13. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  14. package/lib/chain/chain.d.ts +1 -2
  15. package/lib/chain/chain.d.ts.map +1 -1
  16. package/lib/chain/chain.js +1 -3
  17. package/lib/chain/chain.js.map +1 -1
  18. package/lib/chain/interface.d.ts +1 -2
  19. package/lib/chain/interface.d.ts.map +1 -1
  20. package/lib/chain/interface.js.map +1 -1
  21. package/lib/chain/opPools/proposerPreferencesPool.d.ts +2 -1
  22. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  23. package/lib/chain/opPools/proposerPreferencesPool.js +3 -0
  24. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  25. package/lib/chain/options.d.ts +1 -0
  26. package/lib/chain/options.d.ts.map +1 -1
  27. package/lib/chain/options.js +1 -0
  28. package/lib/chain/options.js.map +1 -1
  29. package/lib/chain/seenCache/index.d.ts +0 -1
  30. package/lib/chain/seenCache/index.d.ts.map +1 -1
  31. package/lib/chain/seenCache/index.js +0 -1
  32. package/lib/chain/seenCache/index.js.map +1 -1
  33. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +1 -0
  34. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  35. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +7 -0
  36. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  37. package/lib/chain/shufflingCache.d.ts +6 -0
  38. package/lib/chain/shufflingCache.d.ts.map +1 -1
  39. package/lib/chain/shufflingCache.js +21 -6
  40. package/lib/chain/shufflingCache.js.map +1 -1
  41. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  42. package/lib/chain/stateCache/persistentCheckpointsCache.js +3 -2
  43. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  44. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  45. package/lib/chain/validation/proposerPreferences.js +11 -3
  46. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  47. package/lib/network/gossip/topic.d.ts +19 -776
  48. package/lib/network/gossip/topic.d.ts.map +1 -1
  49. package/lib/network/peers/discover.d.ts.map +1 -1
  50. package/lib/network/peers/discover.js +17 -12
  51. package/lib/network/peers/discover.js.map +1 -1
  52. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  53. package/lib/network/processor/gossipHandlers.js +26 -14
  54. package/lib/network/processor/gossipHandlers.js.map +1 -1
  55. package/lib/sync/range/chain.d.ts +4 -1
  56. package/lib/sync/range/chain.d.ts.map +1 -1
  57. package/lib/sync/range/chain.js +3 -3
  58. package/lib/sync/range/chain.js.map +1 -1
  59. package/lib/sync/range/range.d.ts.map +1 -1
  60. package/lib/sync/range/range.js +10 -0
  61. package/lib/sync/range/range.js.map +1 -1
  62. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  63. package/lib/sync/utils/downloadByRange.js +25 -19
  64. package/lib/sync/utils/downloadByRange.js.map +1 -1
  65. package/lib/util/graffiti.d.ts +15 -0
  66. package/lib/util/graffiti.d.ts.map +1 -1
  67. package/lib/util/graffiti.js +55 -0
  68. package/lib/util/graffiti.js.map +1 -1
  69. package/package.json +14 -14
  70. package/src/api/impl/beacon/pool/index.ts +0 -1
  71. package/src/api/impl/validator/index.ts +9 -3
  72. package/src/chain/blocks/importBlock.ts +18 -4
  73. package/src/chain/blocks/payloadEnvelopeProcessor.ts +17 -17
  74. package/src/chain/chain.ts +0 -3
  75. package/src/chain/interface.ts +0 -2
  76. package/src/chain/opPools/proposerPreferencesPool.ts +5 -1
  77. package/src/chain/options.ts +2 -0
  78. package/src/chain/seenCache/index.ts +0 -1
  79. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +8 -0
  80. package/src/chain/shufflingCache.ts +23 -7
  81. package/src/chain/stateCache/persistentCheckpointsCache.ts +3 -2
  82. package/src/chain/validation/proposerPreferences.ts +12 -3
  83. package/src/network/peers/discover.ts +16 -11
  84. package/src/network/processor/gossipHandlers.ts +29 -15
  85. package/src/sync/range/chain.ts +4 -5
  86. package/src/sync/range/range.ts +10 -0
  87. package/src/sync/utils/downloadByRange.ts +26 -19
  88. package/src/util/graffiti.ts +78 -0
  89. package/lib/chain/seenCache/seenProposerPreferences.d.ts +0 -16
  90. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +0 -1
  91. package/lib/chain/seenCache/seenProposerPreferences.js +0 -26
  92. package/lib/chain/seenCache/seenProposerPreferences.js.map +0 -1
  93. package/src/chain/seenCache/seenProposerPreferences.ts +0 -32
@@ -37,3 +37,81 @@ export function getDefaultGraffiti(
37
37
  // No EL client info available. We still want to include CL info albeit not spec compliant
38
38
  return `${consensusClientVersion.code}${consensusClientVersion.commit.slice(0, 4)}`;
39
39
  }
40
+
41
+ function appendLongestFittingSuffix(userGraffiti: string, suffixes: string[]): string {
42
+ const userGraffitiBytes = Buffer.byteLength(userGraffiti, "utf8");
43
+ if (userGraffitiBytes >= GRAFFITI_SIZE) {
44
+ return userGraffiti;
45
+ }
46
+
47
+ const availableBytes = GRAFFITI_SIZE - userGraffitiBytes;
48
+
49
+ for (const suffix of suffixes) {
50
+ if (Buffer.byteLength(suffix, "utf8") <= availableBytes) {
51
+ return `${userGraffiti}${suffix}`;
52
+ }
53
+ }
54
+
55
+ return userGraffiti;
56
+ }
57
+
58
+ /**
59
+ * Appends the richest available client watermark that fits after user graffiti.
60
+ *
61
+ * Tiers are:
62
+ * - full EL/CL watermark, e.g. " BU9b0eLS80c2"
63
+ * - EL/CL client codes, e.g. " BULS"
64
+ * - CL client code, e.g. " LS"
65
+ */
66
+ export function appendClientInfoToGraffiti(
67
+ userGraffiti: string,
68
+ consensusClientVersion: ClientVersion,
69
+ executionClientVersion: ClientVersion | null | undefined,
70
+ opts: {private?: boolean} = {}
71
+ ): string {
72
+ if (opts.private) {
73
+ return userGraffiti;
74
+ }
75
+
76
+ // Graffiti supplied via the beacon API is decoded from a fixed 32-byte field (see
77
+ // fromGraffitiHex) and arrives right-padded with NUL bytes. Trim only trailing padding
78
+ // NULs; a NUL that appears in the middle of the string is data, not padding.
79
+ let end = userGraffiti.length;
80
+ while (end > 0 && userGraffiti.charCodeAt(end - 1) === 0) {
81
+ end--;
82
+ }
83
+ const graffiti = userGraffiti.slice(0, end);
84
+
85
+ const fullClientInfo = getDefaultGraffiti(consensusClientVersion, executionClientVersion, {private: false});
86
+ if (graffiti.length === 0) {
87
+ return fullClientInfo;
88
+ }
89
+
90
+ const suffixes =
91
+ executionClientVersion != null
92
+ ? [
93
+ ` ${fullClientInfo}`,
94
+ ` ${executionClientVersion.code}${consensusClientVersion.code}`,
95
+ ` ${consensusClientVersion.code}`,
96
+ ]
97
+ : [` ${fullClientInfo}`, ` ${consensusClientVersion.code}`];
98
+
99
+ return appendLongestFittingSuffix(graffiti, suffixes);
100
+ }
101
+
102
+ export function getBlockGraffiti(
103
+ userGraffiti: string | undefined,
104
+ consensusClientVersion: ClientVersion,
105
+ executionClientVersion: ClientVersion | null | undefined,
106
+ opts: {private?: boolean; graffitiAppend?: boolean}
107
+ ): string {
108
+ if (userGraffiti === undefined) {
109
+ return getDefaultGraffiti(consensusClientVersion, executionClientVersion, opts);
110
+ }
111
+
112
+ if (opts.graffitiAppend === false) {
113
+ return userGraffiti;
114
+ }
115
+
116
+ return appendClientInfoToGraffiti(userGraffiti, consensusClientVersion, executionClientVersion, opts);
117
+ }
@@ -1,16 +0,0 @@
1
- import { RootHex, Slot, ValidatorIndex } from "@lodestar/types";
2
- /**
3
- * Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
4
- */
5
- export declare class SeenProposerPreferences {
6
- private readonly validatorByDependentRootBySlot;
7
- isKnown(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean;
8
- add(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): void;
9
- /**
10
- * Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
11
- * passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
12
- * on each slot tick.
13
- */
14
- prune(currentSlot: Slot): void;
15
- }
16
- //# sourceMappingURL=seenProposerPreferences.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seenProposerPreferences.d.ts","sourceRoot":"","sources":["../../../src/chain/seenCache/seenProposerPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAG9D;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAE7C;IAEF,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAE3F;IAED,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,GAAG,IAAI,CAEpF;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAM7B;CACF"}
@@ -1,26 +0,0 @@
1
- import { MapDef } from "@lodestar/utils";
2
- /**
3
- * Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
4
- */
5
- export class SeenProposerPreferences {
6
- validatorByDependentRootBySlot = new MapDef(() => new Map());
7
- isKnown(dependentRoot, proposalSlot, validatorIndex) {
8
- return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
9
- }
10
- add(dependentRoot, proposalSlot, validatorIndex) {
11
- this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
12
- }
13
- /**
14
- * Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
15
- * passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
16
- * on each slot tick.
17
- */
18
- prune(currentSlot) {
19
- for (const slot of this.validatorByDependentRootBySlot.keys()) {
20
- if (slot < currentSlot) {
21
- this.validatorByDependentRootBySlot.delete(slot);
22
- }
23
- }
24
- }
25
- }
26
- //# sourceMappingURL=seenProposerPreferences.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seenProposerPreferences.js","sourceRoot":"","sources":["../../../src/chain/seenCache/seenProposerPreferences.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACjB,8BAA8B,GAAG,IAAI,MAAM,CAC1D,GAAG,EAAE,CAAC,IAAI,GAAG,EAA2B,CACzC,CAAC;IAEF,OAAO,CAAC,aAAsB,EAAE,YAAkB,EAAE,cAA8B,EAAW;QAC3F,OAAO,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,KAAK,cAAc,CAAC;IAAA,CACrG;IAED,GAAG,CAAC,aAAsB,EAAE,YAAkB,EAAE,cAA8B,EAAQ;QACpF,IAAI,CAAC,8BAA8B,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAAA,CACnG;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAiB,EAAQ;QAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,8BAA8B,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9D,IAAI,IAAI,GAAG,WAAW,EAAE,CAAC;gBACvB,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IAAA,CACF;CACF"}
@@ -1,32 +0,0 @@
1
- import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
- import {MapDef} from "@lodestar/utils";
3
-
4
- /**
5
- * Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
6
- */
7
- export class SeenProposerPreferences {
8
- private readonly validatorByDependentRootBySlot = new MapDef<Slot, Map<RootHex, ValidatorIndex>>(
9
- () => new Map<RootHex, ValidatorIndex>()
10
- );
11
-
12
- isKnown(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
13
- return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
14
- }
15
-
16
- add(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
17
- this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
18
- }
19
-
20
- /**
21
- * Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
22
- * passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
23
- * on each slot tick.
24
- */
25
- prune(currentSlot: Slot): void {
26
- for (const slot of this.validatorByDependentRootBySlot.keys()) {
27
- if (slot < currentSlot) {
28
- this.validatorByDependentRootBySlot.delete(slot);
29
- }
30
- }
31
- }
32
- }