@lodestar/beacon-node 1.50.0-dev.b37917f96a → 1.50.0-dev.b726a05a4d
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.
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +26 -0
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/beaconProposerCache.d.ts +6 -0
- package/lib/chain/beaconProposerCache.d.ts.map +1 -1
- package/lib/chain/beaconProposerCache.js +16 -0
- package/lib/chain/beaconProposerCache.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +1 -2
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/chain.d.ts +1 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +15 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +2 -0
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +1 -23
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +4 -0
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +13 -1
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
- package/lib/chain/opPools/utils.d.ts +11 -0
- package/lib/chain/opPools/utils.d.ts.map +1 -1
- package/lib/chain/opPools/utils.js +22 -0
- package/lib/chain/opPools/utils.js.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +11 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts +8 -0
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +40 -28
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/db/beacon.d.ts +2 -1
- package/lib/db/beacon.d.ts.map +1 -1
- package/lib/db/beacon.js +3 -1
- package/lib/db/beacon.js.map +1 -1
- package/lib/db/buckets.d.ts +2 -1
- package/lib/db/buckets.d.ts.map +1 -1
- package/lib/db/buckets.js +1 -0
- package/lib/db/buckets.js.map +1 -1
- package/lib/db/interface.d.ts +2 -1
- package/lib/db/interface.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/index.d.ts +1 -0
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +1 -0
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/db/repositories/proposerPreferences.d.ts +14 -0
- package/lib/db/repositories/proposerPreferences.d.ts.map +1 -0
- package/lib/db/repositories/proposerPreferences.js +21 -0
- package/lib/db/repositories/proposerPreferences.js.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts +9 -0
- package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -0
- package/lib/execution/engine/blobVersionedHashes.js +74 -0
- package/lib/execution/engine/blobVersionedHashes.js.map +1 -0
- package/lib/execution/engine/http.d.ts +45 -13
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +236 -198
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/index.d.ts +3 -2
- package/lib/execution/engine/index.d.ts.map +1 -1
- package/lib/execution/engine/index.js +33 -8
- package/lib/execution/engine/index.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +1 -1
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcTransport.d.ts +25 -0
- package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -0
- package/lib/execution/engine/jsonRpcTransport.js +158 -0
- package/lib/execution/engine/jsonRpcTransport.js.map +1 -0
- package/lib/execution/engine/restHttpClient.d.ts +71 -0
- package/lib/execution/engine/restHttpClient.d.ts.map +1 -0
- package/lib/execution/engine/restHttpClient.js +201 -0
- package/lib/execution/engine/restHttpClient.js.map +1 -0
- package/lib/execution/engine/restTransport.d.ts +46 -0
- package/lib/execution/engine/restTransport.d.ts.map +1 -0
- package/lib/execution/engine/restTransport.js +399 -0
- package/lib/execution/engine/restTransport.js.map +1 -0
- package/lib/execution/engine/sszTypes.d.ts +1261 -0
- package/lib/execution/engine/sszTypes.d.ts.map +1 -0
- package/lib/execution/engine/sszTypes.js +216 -0
- package/lib/execution/engine/sszTypes.js.map +1 -0
- package/lib/execution/engine/transport.d.ts +39 -0
- package/lib/execution/engine/transport.d.ts.map +1 -0
- package/lib/execution/engine/transport.js +2 -0
- package/lib/execution/engine/transport.js.map +1 -0
- package/lib/execution/engine/types.d.ts +2 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +24 -57
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/execution/engine/utils.d.ts.map +1 -1
- package/lib/execution/engine/utils.js +9 -2
- package/lib/execution/engine/utils.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +3 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +5 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/core/events.d.ts +5 -1
- package/lib/network/core/events.d.ts.map +1 -1
- package/lib/network/core/events.js +8 -0
- package/lib/network/core/events.js.map +1 -1
- package/lib/network/processor/gossipHandlers.js +1 -1
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/node/options.d.ts +3 -2
- package/lib/node/options.d.ts.map +1 -1
- package/lib/node/options.js +2 -2
- package/lib/node/options.js.map +1 -1
- package/lib/util/asyncIterableToEvents.d.ts +10 -2
- package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
- package/lib/util/asyncIterableToEvents.js +29 -3
- package/lib/util/asyncIterableToEvents.js.map +1 -1
- package/lib/util/metadata.d.ts.map +1 -1
- package/lib/util/metadata.js +2 -1
- package/lib/util/metadata.js.map +1 -1
- package/package.json +16 -15
- package/src/api/impl/validator/index.ts +37 -0
- package/src/chain/beaconProposerCache.ts +19 -1
- package/src/chain/blocks/importBlock.ts +1 -2
- package/src/chain/chain.ts +17 -0
- package/src/chain/interface.ts +2 -0
- package/src/chain/opPools/opPool.ts +1 -31
- package/src/chain/opPools/proposerPreferencesPool.ts +20 -1
- package/src/chain/opPools/utils.ts +31 -0
- package/src/chain/prepareNextSlot.ts +15 -3
- package/src/chain/produceBlock/produceBlockBody.ts +68 -34
- package/src/db/beacon.ts +3 -0
- package/src/db/buckets.ts +1 -0
- package/src/db/interface.ts +2 -0
- package/src/db/repositories/index.ts +1 -0
- package/src/db/repositories/proposerPreferences.ts +23 -0
- package/src/execution/engine/blobVersionedHashes.ts +72 -0
- package/src/execution/engine/http.ts +304 -271
- package/src/execution/engine/index.ts +41 -7
- package/src/execution/engine/interface.ts +1 -1
- package/src/execution/engine/jsonRpcTransport.ts +247 -0
- package/src/execution/engine/restHttpClient.ts +269 -0
- package/src/execution/engine/restTransport.ts +544 -0
- package/src/execution/engine/sszTypes.ts +354 -0
- package/src/execution/engine/transport.ts +61 -0
- package/src/execution/engine/types.ts +34 -74
- package/src/execution/engine/utils.ts +12 -2
- package/src/metrics/metrics/lodestar.ts +5 -0
- package/src/network/core/events.ts +16 -1
- package/src/network/processor/gossipHandlers.ts +1 -1
- package/src/node/options.ts +10 -1
- package/src/util/asyncIterableToEvents.ts +44 -5
- package/src/util/metadata.ts +2 -1
package/src/chain/chain.ts
CHANGED
|
@@ -620,12 +620,14 @@ export class BeaconChain implements IBeaconChain {
|
|
|
620
620
|
async loadFromDisk(): Promise<void> {
|
|
621
621
|
await this.regen.init();
|
|
622
622
|
await this.opPool.fromPersisted(this.db, this.getHeadState(), this.bls, this.clock.currentSlot);
|
|
623
|
+
await this.proposerPreferencesPool.fromPersisted(this.db, this.clock.currentSlot);
|
|
623
624
|
}
|
|
624
625
|
|
|
625
626
|
/** Persist in-memory data to the DB. Call at least once before stopping the process */
|
|
626
627
|
async persistToDisk(): Promise<void> {
|
|
627
628
|
await this.archiveStore.persistToDisk();
|
|
628
629
|
await this.opPool.toPersisted(this.db);
|
|
630
|
+
await this.proposerPreferencesPool.toPersisted(this.db);
|
|
629
631
|
}
|
|
630
632
|
|
|
631
633
|
getHeadState(): IBeaconStateView {
|
|
@@ -1934,6 +1936,21 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1934
1936
|
}
|
|
1935
1937
|
}
|
|
1936
1938
|
|
|
1939
|
+
async updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void> {
|
|
1940
|
+
let hasNewValidators = false;
|
|
1941
|
+
for (const validatorIndex of validatorIndices) {
|
|
1942
|
+
if (this.beaconProposerCache.track(epoch, validatorIndex)) {
|
|
1943
|
+
hasNewValidators = true;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// Only update validator custody if we discovered new validators
|
|
1948
|
+
if (hasNewValidators) {
|
|
1949
|
+
const finalizedCheckpoint = this.forkChoice.getFinalizedCheckpoint();
|
|
1950
|
+
await this.updateValidatorsCustodyRequirement(finalizedCheckpoint);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1937
1954
|
private async updateValidatorsCustodyRequirement(finalizedCheckpoint: CheckpointWithHex): Promise<void> {
|
|
1938
1955
|
if (this.custodyConfig.targetCustodyGroupCount === this.config.NUMBER_OF_CUSTODY_GROUPS) {
|
|
1939
1956
|
// Custody requirements can only be increased, we can disable dynamic custody updates
|
package/src/chain/interface.ts
CHANGED
|
@@ -288,6 +288,8 @@ export interface IBeaconChain {
|
|
|
288
288
|
waitForBlock(slot: Slot, root: RootHex): Promise<boolean>;
|
|
289
289
|
|
|
290
290
|
updateBeaconProposerData(epoch: Epoch, proposers: ProposerPreparationData[]): Promise<void>;
|
|
291
|
+
/** Track validators that use this node for duties, e.g. by subscribing to attestation subnets */
|
|
292
|
+
updateAttachedValidators(epoch: Epoch, validatorIndices: ValidatorIndex[]): Promise<void>;
|
|
291
293
|
|
|
292
294
|
persistBlock(data: BeaconBlock | BlindedBeaconBlock, suffix?: string): void;
|
|
293
295
|
persistExecutionPayloadEnvelope(envelope: gloas.ExecutionPayloadEnvelope): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {DbBatch, Id, Repository} from "@lodestar/db";
|
|
3
2
|
import {
|
|
4
3
|
BLS_WITHDRAWAL_PREFIX,
|
|
5
4
|
ForkName,
|
|
@@ -42,6 +41,7 @@ import {
|
|
|
42
41
|
getAttesterSlashingSignatureDomains,
|
|
43
42
|
getProposerSlashingSignatureDomain,
|
|
44
43
|
isValidBlsToExecutionChangeForBlockInclusion,
|
|
44
|
+
persistDiff,
|
|
45
45
|
} from "./utils.js";
|
|
46
46
|
|
|
47
47
|
type HexRoot = string;
|
|
@@ -500,33 +500,3 @@ function isVoluntaryExitSignatureIncludable(stateFork: ForkSeq, voluntaryExitFor
|
|
|
500
500
|
function isSlashableAtEpoch(validator: phase0.Validator, epoch: Epoch): boolean {
|
|
501
501
|
return !validator.slashed && validator.activationEpoch <= epoch && epoch < validator.withdrawableEpoch;
|
|
502
502
|
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Persist target items `items` in `dbRepo` doing minimum put and delete writes.
|
|
506
|
-
* Reads all keys in repository to compute the diff between current persisted data and target data.
|
|
507
|
-
*/
|
|
508
|
-
async function persistDiff<K extends Id, V>(
|
|
509
|
-
dbRepo: Repository<K, V>,
|
|
510
|
-
items: {key: K; value: V}[],
|
|
511
|
-
serializeKey: (key: K) => number | string,
|
|
512
|
-
opts: {updateExisting?: boolean} = {}
|
|
513
|
-
): Promise<void> {
|
|
514
|
-
const persistedKeys = await dbRepo.keys();
|
|
515
|
-
const batch: DbBatch<K, V> = [];
|
|
516
|
-
|
|
517
|
-
const persistedKeysSerialized = new Set(persistedKeys.map(serializeKey));
|
|
518
|
-
for (const item of items) {
|
|
519
|
-
if (opts.updateExisting || !persistedKeysSerialized.has(serializeKey(item.key))) {
|
|
520
|
-
batch.push({type: "put", key: item.key, value: item.value});
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
const targetKeysSerialized = new Set(items.map((item) => serializeKey(item.key)));
|
|
525
|
-
for (const persistedKey of persistedKeys) {
|
|
526
|
-
if (!targetKeysSerialized.has(serializeKey(persistedKey))) {
|
|
527
|
-
batch.push({type: "del", key: persistedKey});
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (batch.length > 0) await dbRepo.batch(batch);
|
|
532
|
-
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {RootHex, Slot, ValidatorIndex, gloas} from "@lodestar/types";
|
|
2
|
-
import {toRootHex} from "@lodestar/utils";
|
|
2
|
+
import {toHex, toRootHex} from "@lodestar/utils";
|
|
3
|
+
import {IBeaconDb} from "../../db/index.js";
|
|
4
|
+
import {persistDiff} from "./utils.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Pool of validated `SignedProposerPreferences` indexed by `(slot, dependent_root)`.
|
|
@@ -64,4 +66,21 @@ export class ProposerPreferencesPool {
|
|
|
64
66
|
if (slot < currentSlot) this.bySlot.delete(slot);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
|
|
70
|
+
/** Restore the preferences of upcoming slots, they were validated before they were persisted */
|
|
71
|
+
async fromPersisted(db: IBeaconDb, currentSlot: Slot): Promise<void> {
|
|
72
|
+
for (const signed of await db.proposerPreferences.values()) {
|
|
73
|
+
if (signed.message.proposalSlot >= currentSlot) {
|
|
74
|
+
this.add(signed);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async toPersisted(db: IBeaconDb): Promise<void> {
|
|
80
|
+
await persistDiff(
|
|
81
|
+
db.proposerPreferences,
|
|
82
|
+
this.getAll().map((signed) => ({key: db.proposerPreferences.getId(signed), value: signed})),
|
|
83
|
+
toHex
|
|
84
|
+
);
|
|
85
|
+
}
|
|
67
86
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Signature} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
+
import {DbBatch, Id, Repository} from "@lodestar/db";
|
|
3
4
|
import {BLS_WITHDRAWAL_PREFIX, DOMAIN_BEACON_ATTESTER, DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
|
|
4
5
|
import {IBeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
5
6
|
import {AttesterSlashing, Domain, Slot, capella, phase0} from "@lodestar/types";
|
|
@@ -91,3 +92,33 @@ export function isValidBlsToExecutionChangeForBlockInclusion(
|
|
|
91
92
|
export function isElectraAggregate(aggregate: AggregateFast): aggregate is AggregateFastElectra {
|
|
92
93
|
return (aggregate as AggregateFastElectra).committeeBits !== undefined;
|
|
93
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Persist target items `items` in `dbRepo` doing minimum put and delete writes.
|
|
98
|
+
* Reads all keys in repository to compute the diff between current persisted data and target data.
|
|
99
|
+
*/
|
|
100
|
+
export async function persistDiff<K extends Id, V>(
|
|
101
|
+
dbRepo: Repository<K, V>,
|
|
102
|
+
items: {key: K; value: V}[],
|
|
103
|
+
serializeKey: (key: K) => number | string,
|
|
104
|
+
opts: {updateExisting?: boolean} = {}
|
|
105
|
+
): Promise<void> {
|
|
106
|
+
const persistedKeys = await dbRepo.keys();
|
|
107
|
+
const batch: DbBatch<K, V> = [];
|
|
108
|
+
|
|
109
|
+
const persistedKeysSerialized = new Set(persistedKeys.map(serializeKey));
|
|
110
|
+
for (const item of items) {
|
|
111
|
+
if (opts.updateExisting || !persistedKeysSerialized.has(serializeKey(item.key))) {
|
|
112
|
+
batch.push({type: "put", key: item.key, value: item.value});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const targetKeysSerialized = new Set(items.map((item) => serializeKey(item.key)));
|
|
117
|
+
for (const persistedKey of persistedKeys) {
|
|
118
|
+
if (!targetKeysSerialized.has(serializeKey(persistedKey))) {
|
|
119
|
+
batch.push({type: "del", key: persistedKey});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (batch.length > 0) await dbRepo.batch(batch);
|
|
124
|
+
}
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
isStatePostGloas,
|
|
23
23
|
} from "@lodestar/state-transition";
|
|
24
24
|
import {Bytes32, Slot, ValidatorIndex} from "@lodestar/types";
|
|
25
|
-
import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
|
|
25
|
+
import {Logger, fromHex, isErrorAborted, sleep, toHex} from "@lodestar/utils";
|
|
26
26
|
import {GENESIS_SLOT} from "../constants/constants.js";
|
|
27
27
|
import {BuilderStatus} from "../execution/builder/http.js";
|
|
28
28
|
import {PayloadAttributes} from "../execution/index.js";
|
|
@@ -31,7 +31,11 @@ import {ClockEvent} from "../util/clock.js";
|
|
|
31
31
|
import {isQueueErrorAborted} from "../util/queue/index.js";
|
|
32
32
|
import {ForkchoiceCaller} from "./forkChoice/index.js";
|
|
33
33
|
import {IBeaconChain} from "./interface.js";
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
getPayloadAttributesForSSE,
|
|
36
|
+
getPooledProposerPreferences,
|
|
37
|
+
prepareExecutionPayload,
|
|
38
|
+
} from "./produceBlock/produceBlockBody.js";
|
|
35
39
|
import {RegenCaller} from "./regen/index.js";
|
|
36
40
|
|
|
37
41
|
// TODO GLOAS: re-evaluate this timing
|
|
@@ -158,7 +162,15 @@ export class PrepareNextSlotScheduler {
|
|
|
158
162
|
};
|
|
159
163
|
|
|
160
164
|
const proposerIndex = await getProposerIndex();
|
|
161
|
-
|
|
165
|
+
if (this.chain.beaconProposerCache.has(proposerIndex)) {
|
|
166
|
+
const pooledPreferences = isForkPostGloas(fork)
|
|
167
|
+
? getPooledProposerPreferences(this.chain, prepareSlot, headRoot)
|
|
168
|
+
: null;
|
|
169
|
+
feeRecipient =
|
|
170
|
+
pooledPreferences !== null
|
|
171
|
+
? toHex(pooledPreferences.feeRecipient)
|
|
172
|
+
: this.chain.beaconProposerCache.getOrDefault(proposerIndex);
|
|
173
|
+
}
|
|
162
174
|
|
|
163
175
|
// Predict the proposer head of the next slot when either:
|
|
164
176
|
// - we are proposing the next slot (single-slot proposer-boost-reorg), or
|
|
@@ -77,6 +77,7 @@ import {IExecutionBuilder, IExecutionEngine, PayloadAttributes, PayloadId} from
|
|
|
77
77
|
import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
|
|
78
78
|
import {fromGraffitiBytes} from "../../util/graffiti.js";
|
|
79
79
|
import {kzg} from "../../util/kzg.js";
|
|
80
|
+
import {BeaconProposerCache} from "../beaconProposerCache.js";
|
|
80
81
|
import type {BeaconChain} from "../chain.js";
|
|
81
82
|
import {CommonBlockBody} from "../interface.js";
|
|
82
83
|
import {ProposerPreferencesPool} from "../opPools/index.js";
|
|
@@ -286,10 +287,13 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
286
287
|
// this into a completely separate function and have pre/post gloas more separated
|
|
287
288
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
288
289
|
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
const {feeRecipient, feeRecipientType} = getProposerFeeRecipient(
|
|
291
|
+
requestedFeeRecipient,
|
|
292
|
+
getPooledProposerPreferences(this, blockSlot, parentBlock.blockRoot),
|
|
293
|
+
this.beaconProposerCache,
|
|
294
|
+
proposerIndex
|
|
295
|
+
);
|
|
296
|
+
Object.assign(logMeta, {feeRecipientType, feeRecipient});
|
|
293
297
|
|
|
294
298
|
const endExecutionPayload = this.metrics?.executionBlockProductionTimeSteps.startTimer();
|
|
295
299
|
|
|
@@ -442,13 +446,12 @@ export async function produceBlockBody<T extends BlockType>(
|
|
|
442
446
|
|
|
443
447
|
const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice, this.logger);
|
|
444
448
|
const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
|
|
445
|
-
const feeRecipient =
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
449
|
+
const {feeRecipient, feeRecipientType} = getProposerFeeRecipient(
|
|
450
|
+
requestedFeeRecipient,
|
|
451
|
+
null,
|
|
452
|
+
this.beaconProposerCache,
|
|
453
|
+
proposerIndex
|
|
454
|
+
);
|
|
452
455
|
Object.assign(logMeta, {feeRecipientType, feeRecipient});
|
|
453
456
|
|
|
454
457
|
if (blockType === BlockType.Blinded) {
|
|
@@ -974,9 +977,8 @@ function preparePayloadAttributes(
|
|
|
974
977
|
* Resolve the proposer's preferred (target) gas limit for the Gloas `PayloadAttributesV4`
|
|
975
978
|
* `targetGasLimit` field (consensus-specs#5235, execution-apis#796).
|
|
976
979
|
*
|
|
977
|
-
* Sourced from the `SignedProposerPreferences` the proposer's VC submitted to the pool
|
|
978
|
-
*
|
|
979
|
-
* preferences are pooled, target the parent payload's gas limit so the gas limit stays
|
|
980
|
+
* Sourced from the `SignedProposerPreferences` the proposer's VC submitted to the pool. When no
|
|
981
|
+
* matching preferences are pooled, target the parent payload's gas limit so the gas limit stays
|
|
980
982
|
* unchanged (`is_gas_limit_target_compatible` then requires `gas_limit == parent_gas_limit`).
|
|
981
983
|
*
|
|
982
984
|
* The parent payload's gas_limit is read from fork choice — the variant matching
|
|
@@ -991,26 +993,9 @@ function getProposerTargetGasLimit(
|
|
|
991
993
|
parentBlockHash: Bytes32
|
|
992
994
|
): bigint {
|
|
993
995
|
const parentBlockRootHex = toRootHex(parentBlockRoot);
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
return null;
|
|
998
|
-
}
|
|
999
|
-
try {
|
|
1000
|
-
return getShufflingDependentRoot(
|
|
1001
|
-
chain.forkChoice,
|
|
1002
|
-
computeEpochAtSlot(prepareSlot),
|
|
1003
|
-
computeEpochAtSlot(parentBlock.slot),
|
|
1004
|
-
parentBlock
|
|
1005
|
-
);
|
|
1006
|
-
} catch {
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
1009
|
-
})();
|
|
1010
|
-
|
|
1011
|
-
const pref = dependentRootHex !== null ? chain.proposerPreferencesPool.get(prepareSlot, dependentRootHex) : null;
|
|
1012
|
-
if (pref !== null) {
|
|
1013
|
-
return pref.message.targetGasLimit;
|
|
996
|
+
const preferences = getPooledProposerPreferences(chain, prepareSlot, parentBlockRootHex);
|
|
997
|
+
if (preferences !== null) {
|
|
998
|
+
return preferences.targetGasLimit;
|
|
1014
999
|
}
|
|
1015
1000
|
|
|
1016
1001
|
const parentPayloadVariant = chain.forkChoice.getBlockHexAndBlockHash(parentBlockRootHex, toRootHex(parentBlockHash));
|
|
@@ -1022,6 +1007,55 @@ function getProposerTargetGasLimit(
|
|
|
1022
1007
|
return BigInt(parentPayloadVariant.executionPayloadGasLimit);
|
|
1023
1008
|
}
|
|
1024
1009
|
|
|
1010
|
+
/** The proposer's request wins over its signed preferences, which win over its registered proposer data */
|
|
1011
|
+
function getProposerFeeRecipient(
|
|
1012
|
+
requestedFeeRecipient: string | undefined,
|
|
1013
|
+
pooledPreferences: gloas.ProposerPreferences | null,
|
|
1014
|
+
beaconProposerCache: BeaconProposerCache,
|
|
1015
|
+
proposerIndex: ValidatorIndex
|
|
1016
|
+
): {feeRecipient: string; feeRecipientType: "requested" | "preferences" | "cached" | "default"} {
|
|
1017
|
+
if (requestedFeeRecipient !== undefined) {
|
|
1018
|
+
return {feeRecipient: requestedFeeRecipient, feeRecipientType: "requested"};
|
|
1019
|
+
}
|
|
1020
|
+
if (pooledPreferences !== null) {
|
|
1021
|
+
return {feeRecipient: toHex(pooledPreferences.feeRecipient), feeRecipientType: "preferences"};
|
|
1022
|
+
}
|
|
1023
|
+
const cachedFeeRecipient = beaconProposerCache.get(proposerIndex);
|
|
1024
|
+
if (cachedFeeRecipient !== undefined) {
|
|
1025
|
+
return {feeRecipient: cachedFeeRecipient, feeRecipientType: "cached"};
|
|
1026
|
+
}
|
|
1027
|
+
return {feeRecipient: beaconProposerCache.getOrDefault(proposerIndex), feeRecipientType: "default"};
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* The preferences the proposer of `slot` signed for the branch of `parentBlockRoot`, the same
|
|
1032
|
+
* `(slot, dependent_root)` lookup as gossip bid validation. Null if none are pooled.
|
|
1033
|
+
*/
|
|
1034
|
+
export function getPooledProposerPreferences(
|
|
1035
|
+
chain: {forkChoice: IForkChoice; proposerPreferencesPool: ProposerPreferencesPool},
|
|
1036
|
+
slot: Slot,
|
|
1037
|
+
parentBlockRootHex: RootHex
|
|
1038
|
+
): gloas.ProposerPreferences | null {
|
|
1039
|
+
const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentBlockRootHex);
|
|
1040
|
+
if (parentBlock === null) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
let dependentRootHex: RootHex;
|
|
1045
|
+
try {
|
|
1046
|
+
dependentRootHex = getShufflingDependentRoot(
|
|
1047
|
+
chain.forkChoice,
|
|
1048
|
+
computeEpochAtSlot(slot),
|
|
1049
|
+
computeEpochAtSlot(parentBlock.slot),
|
|
1050
|
+
parentBlock
|
|
1051
|
+
);
|
|
1052
|
+
} catch {
|
|
1053
|
+
return null;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
return chain.proposerPreferencesPool.get(slot, dependentRootHex)?.message ?? null;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1025
1059
|
export async function produceCommonBlockBody<T extends BlockType>(
|
|
1026
1060
|
this: BeaconChain,
|
|
1027
1061
|
blockType: T,
|
package/src/db/beacon.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
DataColumnSidecarRepository,
|
|
23
23
|
ExecutionPayloadEnvelopeArchiveRepository,
|
|
24
24
|
ExecutionPayloadEnvelopeRepository,
|
|
25
|
+
ProposerPreferencesRepository,
|
|
25
26
|
ProposerSlashingRepository,
|
|
26
27
|
StateArchiveRepository,
|
|
27
28
|
SyncCommitteeRepository,
|
|
@@ -53,6 +54,7 @@ export class BeaconDb implements IBeaconDb {
|
|
|
53
54
|
|
|
54
55
|
voluntaryExit: VoluntaryExitRepository;
|
|
55
56
|
proposerSlashing: ProposerSlashingRepository;
|
|
57
|
+
proposerPreferences: ProposerPreferencesRepository;
|
|
56
58
|
attesterSlashing: AttesterSlashingRepository;
|
|
57
59
|
blsToExecutionChange: BLSToExecutionChangeRepository;
|
|
58
60
|
|
|
@@ -89,6 +91,7 @@ export class BeaconDb implements IBeaconDb {
|
|
|
89
91
|
this.voluntaryExit = new VoluntaryExitRepository(config, db);
|
|
90
92
|
this.blsToExecutionChange = new BLSToExecutionChangeRepository(config, db);
|
|
91
93
|
this.proposerSlashing = new ProposerSlashingRepository(config, db);
|
|
94
|
+
this.proposerPreferences = new ProposerPreferencesRepository(config, db);
|
|
92
95
|
this.attesterSlashing = new AttesterSlashingRepository(config, db);
|
|
93
96
|
|
|
94
97
|
// lightclient
|
package/src/db/buckets.ts
CHANGED
|
@@ -73,6 +73,7 @@ export enum Bucket {
|
|
|
73
73
|
gloas_executionPayloadEnvelope = 59, // GLOAS BeaconBlockRoot -> SignedExecutionPayloadEnvelope
|
|
74
74
|
gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope, or 0x00 + SignedExecutionPayloadHeaderEnvelope
|
|
75
75
|
earliestAvailableSlot = 61, // singleton -> Slot
|
|
76
|
+
gloas_proposerPreferences = 62, // Slot || DependentRoot -> SignedProposerPreferences
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export function getBucketNameByValue<T extends Bucket>(enumValue: T): keyof typeof Bucket {
|
package/src/db/interface.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
DataColumnSidecarRepository,
|
|
18
18
|
ExecutionPayloadEnvelopeArchiveRepository,
|
|
19
19
|
ExecutionPayloadEnvelopeRepository,
|
|
20
|
+
ProposerPreferencesRepository,
|
|
20
21
|
ProposerSlashingRepository,
|
|
21
22
|
StateArchiveRepository,
|
|
22
23
|
SyncCommitteeRepository,
|
|
@@ -52,6 +53,7 @@ export interface IBeaconDb {
|
|
|
52
53
|
// op pool
|
|
53
54
|
voluntaryExit: VoluntaryExitRepository;
|
|
54
55
|
proposerSlashing: ProposerSlashingRepository;
|
|
56
|
+
proposerPreferences: ProposerPreferencesRepository;
|
|
55
57
|
attesterSlashing: AttesterSlashingRepository;
|
|
56
58
|
blsToExecutionChange: BLSToExecutionChangeRepository;
|
|
57
59
|
|
|
@@ -18,6 +18,7 @@ export {BestLightClientUpdateRepository} from "./lightclientBestUpdate.js";
|
|
|
18
18
|
export {CheckpointHeaderRepository} from "./lightclientCheckpointHeader.js";
|
|
19
19
|
export {SyncCommitteeRepository} from "./lightclientSyncCommittee.js";
|
|
20
20
|
export {SyncCommitteeWitnessRepository} from "./lightclientSyncCommitteeWitness.js";
|
|
21
|
+
export {ProposerPreferencesRepository} from "./proposerPreferences.js";
|
|
21
22
|
export {ProposerSlashingRepository} from "./proposerSlashing.js";
|
|
22
23
|
export {StateArchiveRepository} from "./stateArchive.js";
|
|
23
24
|
export {VoluntaryExitRepository} from "./voluntaryExit.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {Db, Repository} from "@lodestar/db";
|
|
3
|
+
import {gloas, ssz} from "@lodestar/types";
|
|
4
|
+
import {intToBytes} from "@lodestar/utils";
|
|
5
|
+
import {Bucket, getBucketNameByValue} from "../buckets.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* SignedProposerPreferences indexed by proposal slot and dependent root
|
|
9
|
+
*
|
|
10
|
+
* Added via gossip or api
|
|
11
|
+
* Removed once the proposal slot has passed
|
|
12
|
+
*/
|
|
13
|
+
export class ProposerPreferencesRepository extends Repository<Uint8Array, gloas.SignedProposerPreferences> {
|
|
14
|
+
constructor(config: ChainForkConfig, db: Db) {
|
|
15
|
+
const bucket = Bucket.gloas_proposerPreferences;
|
|
16
|
+
super(config, db, bucket, ssz.gloas.SignedProposerPreferences, getBucketNameByValue(bucket));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getId(value: gloas.SignedProposerPreferences): Uint8Array {
|
|
20
|
+
const {proposalSlot, dependentRoot} = value.message;
|
|
21
|
+
return Buffer.concat([intToBytes(proposalSlot, 8, "be"), dependentRoot]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {byteArrayEquals} from "@lodestar/utils";
|
|
2
|
+
import {VersionedHashes} from "./interface.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Preserve Deneb's is_valid_versioned_hashes check when the REST envelope omits expected hashes.
|
|
6
|
+
* EIP-4844 encodes blob_versioned_hashes at index 10 of the signed type-3 transaction's RLP list.
|
|
7
|
+
* Skip unrelated fields without decoding or copying them, including untrusted nested access lists.
|
|
8
|
+
* The EL remains responsible for the other transaction validity checks.
|
|
9
|
+
*/
|
|
10
|
+
export function isValidBlobVersionedHashes(transactions: Uint8Array[], expected: VersionedHashes): boolean {
|
|
11
|
+
let index = 0;
|
|
12
|
+
for (const transaction of transactions) {
|
|
13
|
+
if (transaction.length === 0) return false;
|
|
14
|
+
if (transaction[0] !== 0x03) continue;
|
|
15
|
+
|
|
16
|
+
const outer = readRlpItem(transaction, 1, transaction.length);
|
|
17
|
+
if (!outer?.isList || outer.end !== transaction.length) return false;
|
|
18
|
+
|
|
19
|
+
let offset = outer.start;
|
|
20
|
+
for (let fieldIndex = 0; fieldIndex < 14; fieldIndex++) {
|
|
21
|
+
const field = readRlpItem(transaction, offset, outer.end);
|
|
22
|
+
if (field === null) return false;
|
|
23
|
+
if (fieldIndex === 10) {
|
|
24
|
+
if (!field.isList) return false;
|
|
25
|
+
// A canonical RLP-encoded Bytes32 is exactly the 0xa0 prefix followed by 32 bytes.
|
|
26
|
+
const count = (field.end - field.start) / 33;
|
|
27
|
+
if (!Number.isInteger(count) || index + count > expected.length) return false;
|
|
28
|
+
for (let hashOffset = field.start; hashOffset < field.end; hashOffset += 33) {
|
|
29
|
+
if (
|
|
30
|
+
transaction[hashOffset] !== 0xa0 ||
|
|
31
|
+
!byteArrayEquals(transaction.subarray(hashOffset + 1, hashOffset + 33), expected[index])
|
|
32
|
+
) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
index++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
offset = field.end;
|
|
39
|
+
}
|
|
40
|
+
if (offset !== outer.end) return false;
|
|
41
|
+
}
|
|
42
|
+
return index === expected.length;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Read one RLP item's boundaries without descending into lists. */
|
|
46
|
+
function readRlpItem(
|
|
47
|
+
bytes: Uint8Array,
|
|
48
|
+
offset: number,
|
|
49
|
+
limit: number
|
|
50
|
+
): {start: number; end: number; isList: boolean} | null {
|
|
51
|
+
if (offset >= limit) return null;
|
|
52
|
+
const prefix = bytes[offset];
|
|
53
|
+
if (prefix < 0x80) return {start: offset, end: offset + 1, isList: false};
|
|
54
|
+
|
|
55
|
+
const isList = prefix >= 0xc0;
|
|
56
|
+
const lengthCode = prefix - (isList ? 0xc0 : 0x80);
|
|
57
|
+
let start = offset + 1;
|
|
58
|
+
let length = lengthCode;
|
|
59
|
+
if (lengthCode > 55) {
|
|
60
|
+
const lengthBytes = lengthCode - 55;
|
|
61
|
+
start += lengthBytes;
|
|
62
|
+
if (start > limit || bytes[offset + 1] === 0) return null;
|
|
63
|
+
length = 0;
|
|
64
|
+
for (let i = offset + 1; i < start; i++) {
|
|
65
|
+
length = length * 256 + bytes[i];
|
|
66
|
+
}
|
|
67
|
+
if (length <= 55) return null;
|
|
68
|
+
}
|
|
69
|
+
if (length > limit - start) return null;
|
|
70
|
+
if (!isList && length === 1 && bytes[start] < 0x80) return null;
|
|
71
|
+
return {start, end: start + length, isList};
|
|
72
|
+
}
|