@lodestar/beacon-node 1.52.0-dev.18d4ea7338 → 1.52.0-dev.1f4a364fc5
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/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +18 -5
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +3 -1
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +2 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +6 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -16
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +3 -3
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +41 -18
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +3 -2
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/opPools/opPool.js +6 -6
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +30 -40
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +8 -4
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +2 -1
- package/lib/sync/unknownBlock.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +20 -5
- package/src/api/impl/beacon/pool/index.ts +9 -7
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/debug/index.ts +6 -2
- package/src/api/impl/validator/index.ts +2 -1
- package/src/chain/blocks/index.ts +3 -30
- package/src/chain/chain.ts +69 -34
- package/src/chain/errors/executionPayloadBid.ts +3 -2
- package/src/chain/interface.ts +1 -1
- package/src/chain/opPools/opPool.ts +6 -6
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
- package/src/chain/validation/executionPayloadBid.ts +40 -42
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/processor/gossipHandlers.ts +14 -10
- package/src/sync/unknownBlock.ts +2 -1
package/src/chain/chain.ts
CHANGED
|
@@ -701,7 +701,8 @@ export class BeaconChain implements IBeaconChain {
|
|
|
701
701
|
const state = await this.regen.getBlockSlotState(block, slot, {dontTransferCache: true}, RegenCaller.restApi);
|
|
702
702
|
return {
|
|
703
703
|
state,
|
|
704
|
-
|
|
704
|
+
// The canonical variant can be FULL, a state reports the status of the payload its block builds on
|
|
705
|
+
executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
|
|
705
706
|
finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
|
|
706
707
|
};
|
|
707
708
|
}
|
|
@@ -717,7 +718,7 @@ export class BeaconChain implements IBeaconChain {
|
|
|
717
718
|
return (
|
|
718
719
|
state && {
|
|
719
720
|
state,
|
|
720
|
-
executionOptimistic: isOptimisticBlock(block),
|
|
721
|
+
executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
|
|
721
722
|
finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
|
|
722
723
|
}
|
|
723
724
|
);
|
|
@@ -865,7 +866,9 @@ export class BeaconChain implements IBeaconChain {
|
|
|
865
866
|
const finalizedBlock = this.forkChoice.getFinalizedBlock();
|
|
866
867
|
if (slot > finalizedBlock.slot) {
|
|
867
868
|
// Unfinalized slot, attempt to find in fork-choice
|
|
868
|
-
const
|
|
869
|
+
const canonicalBlock = this.forkChoice.getCanonicalBlockAtSlot(slot);
|
|
870
|
+
// The canonical variant can be FULL, a block reports the status of the payload it builds on
|
|
871
|
+
const block = canonicalBlock && this.forkChoice.getBlockHexDefaultStatus(canonicalBlock.blockRoot);
|
|
869
872
|
if (block) {
|
|
870
873
|
// Block found in fork-choice.
|
|
871
874
|
// It may be in the block input cache, awaiting full DA reconstruction, check there first
|
|
@@ -1606,38 +1609,76 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1606
1609
|
}
|
|
1607
1610
|
|
|
1608
1611
|
/**
|
|
1609
|
-
* Invalid state root error is critical and it causes the node to stale most of the time so we want to
|
|
1610
|
-
*
|
|
1612
|
+
* Invalid state root error is critical and it causes the node to stale most of the time so we want to persist
|
|
1613
|
+
* preState, postState and block for further investigation.
|
|
1611
1614
|
*/
|
|
1612
1615
|
async persistInvalidStateRoot(
|
|
1613
1616
|
preState: IBeaconStateView,
|
|
1614
1617
|
postState: IBeaconStateView,
|
|
1615
1618
|
block: SignedBeaconBlock
|
|
1616
1619
|
): Promise<void> {
|
|
1620
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1617
1623
|
const blockSlot = block.message.slot;
|
|
1618
|
-
const
|
|
1619
|
-
const
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1624
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1625
|
+
const preStateRoot = toRootHex(preState.hashTreeRoot());
|
|
1626
|
+
const postStateRoot = toRootHex(postState.hashTreeRoot());
|
|
1627
|
+
const logStr = `slot_${blockSlot}_invalid_state_root_${postStateRoot}`;
|
|
1628
|
+
try {
|
|
1629
|
+
await Promise.all([
|
|
1630
|
+
this.persistSszObject(
|
|
1631
|
+
`SignedBeaconBlock_slot_${blockSlot}`,
|
|
1632
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1633
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1634
|
+
`${logStr}_block`
|
|
1635
|
+
),
|
|
1636
|
+
this.persistSszObject(
|
|
1637
|
+
`preState_slot_${preState.slot}_BeaconState`,
|
|
1638
|
+
preState.serialize(),
|
|
1639
|
+
preStateRoot,
|
|
1640
|
+
`${logStr}_pre_state`
|
|
1641
|
+
),
|
|
1642
|
+
this.persistSszObject(
|
|
1643
|
+
`postState_slot_${postState.slot}_BeaconState`,
|
|
1644
|
+
postState.serialize(),
|
|
1645
|
+
postStateRoot,
|
|
1646
|
+
`${logStr}_post_state`
|
|
1647
|
+
),
|
|
1648
|
+
]);
|
|
1649
|
+
} catch (e) {
|
|
1650
|
+
this.logger.error(
|
|
1651
|
+
"Error persisting invalid state root objects",
|
|
1652
|
+
{slot: blockSlot, preStateRoot, postStateRoot},
|
|
1653
|
+
e as Error
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
async persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void> {
|
|
1659
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
const blockSlot = block.message.slot;
|
|
1663
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1664
|
+
try {
|
|
1665
|
+
await Promise.all([
|
|
1666
|
+
this.persistSszObject(
|
|
1667
|
+
forkTypes.SignedBeaconBlock.typeName,
|
|
1668
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1669
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1670
|
+
`${blockSlot}_invalid_signature`
|
|
1671
|
+
),
|
|
1672
|
+
this.persistSszObject(
|
|
1673
|
+
"BeaconState",
|
|
1674
|
+
state.serialize(),
|
|
1675
|
+
toRootHex(state.hashTreeRoot()),
|
|
1676
|
+
`${state.slot}_invalid_signature`
|
|
1677
|
+
),
|
|
1678
|
+
]);
|
|
1679
|
+
} catch (e) {
|
|
1680
|
+
this.logger.error("Error persisting invalid signature objects", {slot: blockSlot}, e as Error);
|
|
1681
|
+
}
|
|
1641
1682
|
}
|
|
1642
1683
|
|
|
1643
1684
|
persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void {
|
|
@@ -1652,12 +1693,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1652
1693
|
}
|
|
1653
1694
|
}
|
|
1654
1695
|
|
|
1655
|
-
persistInvalidSszBytes(typeName: string, sszBytes: Uint8Array, rootHex: RootHex, suffix?: string): void {
|
|
1656
|
-
if (this.opts.persistInvalidSszObjects) {
|
|
1657
|
-
void this.persistSszObject(typeName, sszBytes, rootHex, suffix);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
1696
|
/**
|
|
1662
1697
|
* Regenerate state for attestation verification, this does not happen with default chain option of maxSkipSlots = 32 .
|
|
1663
1698
|
* However, need to handle just in case. Lodestar doesn't support multiple regen state requests for attestation verification
|
|
@@ -7,7 +7,7 @@ export enum ExecutionPayloadBidErrorCode {
|
|
|
7
7
|
NON_ZERO_EXECUTION_PAYMENT = "EXECUTION_PAYLOAD_BID_ERROR_NON_ZERO_EXECUTION_PAYMENT",
|
|
8
8
|
BLOCK_HASH_EQUALS_PARENT_BLOCK_HASH = "EXECUTION_PAYLOAD_BID_ERROR_BLOCK_HASH_EQUALS_PARENT_BLOCK_HASH",
|
|
9
9
|
INCOMPATIBLE_WITH_HEAD = "EXECUTION_PAYLOAD_BID_ERROR_INCOMPATIBLE_WITH_HEAD",
|
|
10
|
-
|
|
10
|
+
BID_LIMIT_REACHED = "EXECUTION_PAYLOAD_BID_ERROR_BID_LIMIT_REACHED",
|
|
11
11
|
BID_TOO_LOW = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_LOW",
|
|
12
12
|
BID_TOO_HIGH = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_HIGH",
|
|
13
13
|
BUILDER_MAY_EXIT = "EXECUTION_PAYLOAD_BID_ERROR_BUILDER_MAY_EXIT",
|
|
@@ -46,11 +46,12 @@ export type ExecutionPayloadBidErrorType =
|
|
|
46
46
|
headBlockRoot: RootHex;
|
|
47
47
|
}
|
|
48
48
|
| {
|
|
49
|
-
code: ExecutionPayloadBidErrorCode.
|
|
49
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED;
|
|
50
50
|
builderIndex: BuilderIndex;
|
|
51
51
|
slot: Slot;
|
|
52
52
|
parentBlockRoot: RootHex;
|
|
53
53
|
parentBlockHash: RootHex;
|
|
54
|
+
bidLimit: number;
|
|
54
55
|
}
|
|
55
56
|
| {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number}
|
|
56
57
|
| {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number}
|
package/src/chain/interface.ts
CHANGED
|
@@ -303,8 +303,8 @@ export interface IBeaconChain {
|
|
|
303
303
|
postState: IBeaconStateView,
|
|
304
304
|
block: SignedBeaconBlock
|
|
305
305
|
): Promise<void>;
|
|
306
|
+
persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void>;
|
|
306
307
|
persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void;
|
|
307
|
-
persistInvalidSszBytes(type: string, sszBytes: Uint8Array, rootHex: RootHex, suffix?: string): void;
|
|
308
308
|
regenStateForAttestationVerification(
|
|
309
309
|
attEpoch: Epoch,
|
|
310
310
|
shufflingDependentRoot: RootHex,
|
|
@@ -290,7 +290,7 @@ export class OpPool {
|
|
|
290
290
|
const endAttesterSlashings = stepsMetrics?.startTimer();
|
|
291
291
|
const attesterSlashings: AttesterSlashing[] = [];
|
|
292
292
|
const maxAttesterSlashings = stateFork >= ForkSeq.electra ? MAX_ATTESTER_SLASHINGS_ELECTRA : MAX_ATTESTER_SLASHINGS;
|
|
293
|
-
|
|
293
|
+
for (const [key, attesterSlashing] of this.attesterSlashings) {
|
|
294
294
|
const domains = getAttesterSlashingSignatureDomains(this.config, state.slot, attesterSlashing.attesterSlashing);
|
|
295
295
|
if (!attesterSlashing.verifiedDomains.every((domain, i) => byteArrayEquals(domain, domains[i]))) {
|
|
296
296
|
this.attesterSlashings.delete(key);
|
|
@@ -300,18 +300,15 @@ export class OpPool {
|
|
|
300
300
|
const slashableIndices = new Set<ValidatorIndex>();
|
|
301
301
|
for (let i = 0; i < attesterSlashing.intersectingIndices.length; i++) {
|
|
302
302
|
const index = attesterSlashing.intersectingIndices[i];
|
|
303
|
-
//
|
|
303
|
+
// Covered by an earlier slashing in this block, the remaining indices may still be slashable
|
|
304
304
|
if (toBeSlashedIndices.has(index)) {
|
|
305
|
-
continue
|
|
305
|
+
continue;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
const validator = state.getValidator(index);
|
|
309
309
|
if (isSlashableAtEpoch(validator, stateEpoch)) {
|
|
310
310
|
slashableIndices.add(index);
|
|
311
311
|
}
|
|
312
|
-
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
313
|
-
break attesterSlashing;
|
|
314
|
-
}
|
|
315
312
|
}
|
|
316
313
|
|
|
317
314
|
// If there were slashable indices in this slashing
|
|
@@ -321,6 +318,9 @@ export class OpPool {
|
|
|
321
318
|
for (const index of slashableIndices) {
|
|
322
319
|
toBeSlashedIndices.add(index);
|
|
323
320
|
}
|
|
321
|
+
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
endAttesterSlashings?.({
|
|
@@ -6,38 +6,58 @@ import {MapDef} from "@lodestar/utils";
|
|
|
6
6
|
*/
|
|
7
7
|
const SLOTS_RETAINED = 2;
|
|
8
8
|
|
|
9
|
+
export type SeenBuilderBids = {
|
|
10
|
+
/** Number of valid bids seen */
|
|
11
|
+
count: number;
|
|
12
|
+
/**
|
|
13
|
+
* The builder's bid limit. Bids for the same slot and parent root are validated against the same state,
|
|
14
|
+
* so it is known without the state once a bid was valid
|
|
15
|
+
*/
|
|
16
|
+
limit: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
/**
|
|
10
|
-
*
|
|
20
|
+
* Counts the valid execution payload bids seen per
|
|
11
21
|
* (slot, builder, parent block hash, parent block root).
|
|
12
22
|
*/
|
|
13
23
|
export class SeenExecutionPayloadBids {
|
|
14
|
-
private readonly
|
|
15
|
-
() => new MapDef<BuilderIndex,
|
|
24
|
+
private readonly bidsByBranchByBuilderBySlot = new MapDef<Slot, MapDef<BuilderIndex, Map<string, SeenBuilderBids>>>(
|
|
25
|
+
() => new MapDef<BuilderIndex, Map<string, SeenBuilderBids>>(() => new Map<string, SeenBuilderBids>())
|
|
16
26
|
);
|
|
17
27
|
private lowestPermissibleSlot: Slot = 0;
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
get(
|
|
30
|
+
slot: Slot,
|
|
31
|
+
builderIndex: BuilderIndex,
|
|
32
|
+
parentBlockHash: RootHex,
|
|
33
|
+
parentBlockRoot: RootHex
|
|
34
|
+
): SeenBuilderBids | undefined {
|
|
35
|
+
return this.bidsByBranchByBuilderBySlot
|
|
36
|
+
.get(slot)
|
|
37
|
+
?.get(builderIndex)
|
|
38
|
+
?.get(branchKey(parentBlockHash, parentBlockRoot));
|
|
24
39
|
}
|
|
25
40
|
|
|
26
|
-
add(
|
|
41
|
+
add(
|
|
42
|
+
slot: Slot,
|
|
43
|
+
builderIndex: BuilderIndex,
|
|
44
|
+
parentBlockHash: RootHex,
|
|
45
|
+
parentBlockRoot: RootHex,
|
|
46
|
+
bidLimit: number
|
|
47
|
+
): void {
|
|
27
48
|
if (slot < this.lowestPermissibleSlot) {
|
|
28
49
|
throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
|
|
29
50
|
}
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.add(branchKey(parentBlockHash, parentBlockRoot));
|
|
51
|
+
const bidsByBranch = this.bidsByBranchByBuilderBySlot.getOrDefault(slot).getOrDefault(builderIndex);
|
|
52
|
+
const key = branchKey(parentBlockHash, parentBlockRoot);
|
|
53
|
+
bidsByBranch.set(key, {count: (bidsByBranch.get(key)?.count ?? 0) + 1, limit: bidLimit});
|
|
34
54
|
}
|
|
35
55
|
|
|
36
56
|
prune(currentSlot: Slot): void {
|
|
37
57
|
this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
|
|
38
|
-
for (const slot of this.
|
|
58
|
+
for (const slot of this.bidsByBranchByBuilderBySlot.keys()) {
|
|
39
59
|
if (slot < this.lowestPermissibleSlot) {
|
|
40
|
-
this.
|
|
60
|
+
this.bidsByBranchByBuilderBySlot.delete(slot);
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
}
|
|
@@ -16,33 +16,6 @@ import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} fr
|
|
|
16
16
|
import {IBeaconChain} from "../index.js";
|
|
17
17
|
import {RegenCaller} from "../regen/index.js";
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Relative increment over the current highest bid required to forward a bid, in basis points.
|
|
21
|
-
* With 3%, laddering from 1 gwei to 1 ETH takes ~256 bids given the floor and cap below, see
|
|
22
|
-
* https://github.com/ethereum/consensus-specs/pull/4792#issuecomment-3714553549.
|
|
23
|
-
*/
|
|
24
|
-
const BID_INCREMENT_BPS = 300;
|
|
25
|
-
/**
|
|
26
|
-
* Minimum absolute increment (0.0001 ETH). Covers low bid values where the relative increment
|
|
27
|
-
* is tiny and provides weak spam protection.
|
|
28
|
-
*/
|
|
29
|
-
const BID_INCREMENT_FLOOR_GWEI = 100_000;
|
|
30
|
-
/**
|
|
31
|
-
* Maximum absolute increment (0.01 ETH). Bounds the barrier for legitimate competition on
|
|
32
|
-
* high value blocks where the relative increment would suppress closely competing bids.
|
|
33
|
-
*/
|
|
34
|
-
const BID_INCREMENT_CAP_GWEI = 10_000_000;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Return the minimum value a new bid must have to be forwarded given the current highest bid.
|
|
38
|
-
* Division before multiplication to stay within safe integer range for max gwei values.
|
|
39
|
-
*/
|
|
40
|
-
function getMinBidValue(currentHighestBid: number): number {
|
|
41
|
-
const relativeIncrement = Math.floor(currentHighestBid / 10_000) * BID_INCREMENT_BPS;
|
|
42
|
-
const increment = Math.min(Math.max(BID_INCREMENT_FLOOR_GWEI, relativeIncrement), BID_INCREMENT_CAP_GWEI);
|
|
43
|
-
return currentHighestBid + increment;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
19
|
/**
|
|
47
20
|
* Check whether a bid builds on one of the paths compatible with the local head branch.
|
|
48
21
|
*
|
|
@@ -165,27 +138,30 @@ async function validateExecutionPayloadBid(
|
|
|
165
138
|
});
|
|
166
139
|
}
|
|
167
140
|
|
|
168
|
-
// [IGNORE]
|
|
169
|
-
// the
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
|
|
141
|
+
// [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
|
|
142
|
+
// Bids for the same slot and parent root are validated against the same state, so bids past the
|
|
143
|
+
// limit can be dropped before state regeneration and the other expensive validation steps.
|
|
144
|
+
const seenBids = chain.seenExecutionPayloadBids.get(
|
|
145
|
+
bid.slot,
|
|
146
|
+
bid.builderIndex,
|
|
147
|
+
bidParentBlockHash,
|
|
148
|
+
bidParentBlockRoot
|
|
149
|
+
);
|
|
150
|
+
if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
|
|
173
151
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
174
|
-
code: ExecutionPayloadBidErrorCode.
|
|
152
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
175
153
|
builderIndex: bid.builderIndex,
|
|
176
154
|
slot: bid.slot,
|
|
177
155
|
parentBlockRoot: bidParentBlockRoot,
|
|
178
156
|
parentBlockHash: bidParentBlockHash,
|
|
157
|
+
bidLimit: seenBids.limit,
|
|
179
158
|
});
|
|
180
159
|
}
|
|
181
160
|
|
|
182
161
|
// [IGNORE] this bid is the highest value bid seen for the tuple
|
|
183
162
|
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
|
|
184
|
-
// As a DoS prevention measure, the bid must also exceed the current highest bid by a minimum
|
|
185
|
-
// increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
|
|
186
|
-
// from builders submitting numerous bids with minimal value increments.
|
|
187
163
|
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
|
|
188
|
-
if (bestBid !== null && bid.value
|
|
164
|
+
if (bestBid !== null && bid.value <= bestBid.signedBid.message.value) {
|
|
189
165
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
190
166
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
191
167
|
bidValue: bid.value,
|
|
@@ -366,6 +342,24 @@ async function validateExecutionPayloadBid(
|
|
|
366
342
|
});
|
|
367
343
|
}
|
|
368
344
|
|
|
345
|
+
// [IGNORE] The builder has not reached its bid limit for the tuple
|
|
346
|
+
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
|
|
347
|
+
// not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
|
|
348
|
+
const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
|
|
349
|
+
if (
|
|
350
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
351
|
+
0) >= bidLimit
|
|
352
|
+
) {
|
|
353
|
+
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
354
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
355
|
+
builderIndex: bid.builderIndex,
|
|
356
|
+
slot: bid.slot,
|
|
357
|
+
parentBlockRoot: bidParentBlockRoot,
|
|
358
|
+
parentBlockHash: bidParentBlockHash,
|
|
359
|
+
bidLimit,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
369
363
|
// [IGNORE] `bid.value` is less or equal than the builder's excess balance --
|
|
370
364
|
// i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
|
|
371
365
|
if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
|
|
@@ -426,20 +420,24 @@ async function validateExecutionPayloadBid(
|
|
|
426
420
|
});
|
|
427
421
|
}
|
|
428
422
|
|
|
429
|
-
// Repeat the
|
|
430
|
-
// for the same builder and tuple from
|
|
431
|
-
if (
|
|
423
|
+
// Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
|
|
424
|
+
// for the same builder and tuple from all passing validation.
|
|
425
|
+
if (
|
|
426
|
+
(chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
|
|
427
|
+
0) >= bidLimit
|
|
428
|
+
) {
|
|
432
429
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
433
|
-
code: ExecutionPayloadBidErrorCode.
|
|
430
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
|
|
434
431
|
builderIndex: bid.builderIndex,
|
|
435
432
|
slot: bid.slot,
|
|
436
433
|
parentBlockRoot: bidParentBlockRoot,
|
|
437
434
|
parentBlockHash: bidParentBlockHash,
|
|
435
|
+
bidLimit,
|
|
438
436
|
});
|
|
439
437
|
}
|
|
440
438
|
|
|
441
439
|
// Valid
|
|
442
|
-
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
|
|
440
|
+
chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
|
|
443
441
|
|
|
444
442
|
return {proposerIndex: proposerPreferences.message.validatorIndex};
|
|
445
443
|
}
|