@lodestar/beacon-node 1.52.0-dev.d88015cb2a → 1.52.0-dev.dad8e3af98
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 +13 -4
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +4 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +9 -3
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -17
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/chain.d.ts +6 -5
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +62 -20
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +15 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.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/seenAttesters.d.ts +1 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +1 -1
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
- package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
- package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +24 -7
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +32 -16
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +9 -1
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +1 -29
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +79 -4
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +9 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/network/gossip/gossipsub.js +2 -2
- package/lib/network/gossip/gossipsub.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 +19 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/sync/range/batch.d.ts +6 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +17 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +8 -1
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +43 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/types.d.ts +12 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +2 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +28 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +234 -22
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +14 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +12 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +24 -2
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +43 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/eventLoop.d.ts +3 -3
- package/lib/util/eventLoop.d.ts.map +1 -1
- package/lib/util/eventLoop.js +3 -3
- package/lib/util/eventLoop.js.map +1 -1
- package/package.json +17 -17
- 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 +15 -5
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/blocks/importExecutionPayload.ts +9 -2
- package/src/chain/blocks/index.ts +3 -31
- package/src/chain/chain.ts +95 -37
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadEnvelope.ts +50 -0
- package/src/chain/interface.ts +1 -1
- package/src/chain/opPools/opPool.ts +6 -6
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/validation/aggregateAndProof.ts +24 -9
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +1 -31
- package/src/chain/validation/executionPayloadEnvelope.ts +87 -3
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/network/gossip/gossipsub.ts +2 -2
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/processor/gossipHandlers.ts +25 -13
- package/src/network/processor/index.ts +7 -2
- package/src/sync/range/batch.ts +20 -0
- package/src/sync/range/chain.ts +8 -0
- package/src/sync/range/range.ts +56 -3
- package/src/sync/types.ts +11 -0
- package/src/sync/unknownBlock.ts +272 -22
- package/src/sync/utils/downloadByRange.ts +29 -3
- package/src/sync/utils/downloadByRoot.ts +68 -2
- package/src/util/eventLoop.ts +3 -3
package/src/chain/chain.ts
CHANGED
|
@@ -93,7 +93,7 @@ import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
|
|
|
93
93
|
import {persistPayloadEnvelopeInput} from "./blocks/writePayloadEnvelopeInputToDb.js";
|
|
94
94
|
import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier, IBlsVerifier} from "./bls/index.js";
|
|
95
95
|
import {BuilderCircuitBreaker} from "./builderCircuitBreaker.js";
|
|
96
|
-
import {ColumnReconstructionTracker} from "./ColumnReconstructionTracker.js";
|
|
96
|
+
import {ColumnReconstructionTracker, RECONSTRUCTED_COLUMNS_WAIT_BPS} from "./ColumnReconstructionTracker.js";
|
|
97
97
|
import {ChainEvent, ChainEventEmitter, ReorgEventData} from "./emitter.js";
|
|
98
98
|
import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js";
|
|
99
99
|
import {ForkChoiceExecutionEngine} from "./forkChoiceExecutionEngine.js";
|
|
@@ -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
|
|
@@ -1126,6 +1129,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1126
1129
|
// After gloas, columns are tracked in PayloadEnvelopeInput
|
|
1127
1130
|
const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
1128
1131
|
if (payloadInput) {
|
|
1132
|
+
// Available with half the columns, peers that saw it attested expect the reconstructed rest
|
|
1133
|
+
if (
|
|
1134
|
+
!payloadInput.hasComputedAllData() &&
|
|
1135
|
+
payloadInput.hasAllData() &&
|
|
1136
|
+
indices.some((index) => !payloadInput.hasColumn(index))
|
|
1137
|
+
) {
|
|
1138
|
+
this.columnReconstructionTracker.triggerColumnReconstruction(payloadInput);
|
|
1139
|
+
await payloadInput
|
|
1140
|
+
.waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
|
|
1141
|
+
.catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
|
|
1142
|
+
}
|
|
1129
1143
|
for (let i = 0; i < indices.length; i++) {
|
|
1130
1144
|
const index = indices[i];
|
|
1131
1145
|
const sidecar = payloadInput.getColumn(index);
|
|
@@ -1147,6 +1161,17 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1147
1161
|
if (!isBlockInputColumns(blockInput)) {
|
|
1148
1162
|
throw new Error(`Expected block input to have columns: slot=${blockSlot} root=${blockRootHex}`);
|
|
1149
1163
|
}
|
|
1164
|
+
// Available with half the columns, peers that saw it attested expect the reconstructed rest
|
|
1165
|
+
if (
|
|
1166
|
+
!blockInput.hasComputedAllData() &&
|
|
1167
|
+
blockInput.hasAllData() &&
|
|
1168
|
+
indices.some((index) => !blockInput.hasColumn(index))
|
|
1169
|
+
) {
|
|
1170
|
+
this.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
|
|
1171
|
+
await blockInput
|
|
1172
|
+
.waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
|
|
1173
|
+
.catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
|
|
1174
|
+
}
|
|
1150
1175
|
for (let i = 0; i < indices.length; i++) {
|
|
1151
1176
|
const index = indices[i];
|
|
1152
1177
|
const sidecar = blockInput.getColumn(index);
|
|
@@ -1473,9 +1498,10 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1473
1498
|
|
|
1474
1499
|
/**
|
|
1475
1500
|
* Emit `head` and `head_v2` when the fork choice head differs between two observations. Every caller that
|
|
1476
|
-
* can move the head, `updateAndGetHead()` and `
|
|
1501
|
+
* can move the head, `updateAndGetHead()`, `updateTime()` and `onExecutionPayload()`, must capture the head before
|
|
1502
|
+
* and pass both.
|
|
1477
1503
|
*/
|
|
1478
|
-
|
|
1504
|
+
emitHeadEvents(prevHead: ProtoBlock, head: ProtoBlock): void {
|
|
1479
1505
|
const headRootChanged = head.blockRoot !== prevHead.blockRoot;
|
|
1480
1506
|
|
|
1481
1507
|
if (!headRootChanged && prevHead.payloadStatus === head.payloadStatus) {
|
|
@@ -1606,38 +1632,76 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1606
1632
|
}
|
|
1607
1633
|
|
|
1608
1634
|
/**
|
|
1609
|
-
* Invalid state root error is critical and it causes the node to stale most of the time so we want to
|
|
1610
|
-
*
|
|
1635
|
+
* Invalid state root error is critical and it causes the node to stale most of the time so we want to persist
|
|
1636
|
+
* preState, postState and block for further investigation.
|
|
1611
1637
|
*/
|
|
1612
1638
|
async persistInvalidStateRoot(
|
|
1613
1639
|
preState: IBeaconStateView,
|
|
1614
1640
|
postState: IBeaconStateView,
|
|
1615
1641
|
block: SignedBeaconBlock
|
|
1616
1642
|
): Promise<void> {
|
|
1643
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1617
1646
|
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
|
-
|
|
1647
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1648
|
+
const preStateRoot = toRootHex(preState.hashTreeRoot());
|
|
1649
|
+
const postStateRoot = toRootHex(postState.hashTreeRoot());
|
|
1650
|
+
const logStr = `slot_${blockSlot}_invalid_state_root_${postStateRoot}`;
|
|
1651
|
+
try {
|
|
1652
|
+
await Promise.all([
|
|
1653
|
+
this.persistSszObject(
|
|
1654
|
+
`SignedBeaconBlock_slot_${blockSlot}`,
|
|
1655
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1656
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1657
|
+
`${logStr}_block`
|
|
1658
|
+
),
|
|
1659
|
+
this.persistSszObject(
|
|
1660
|
+
`preState_slot_${preState.slot}_BeaconState`,
|
|
1661
|
+
preState.serialize(),
|
|
1662
|
+
preStateRoot,
|
|
1663
|
+
`${logStr}_pre_state`
|
|
1664
|
+
),
|
|
1665
|
+
this.persistSszObject(
|
|
1666
|
+
`postState_slot_${postState.slot}_BeaconState`,
|
|
1667
|
+
postState.serialize(),
|
|
1668
|
+
postStateRoot,
|
|
1669
|
+
`${logStr}_post_state`
|
|
1670
|
+
),
|
|
1671
|
+
]);
|
|
1672
|
+
} catch (e) {
|
|
1673
|
+
this.logger.error(
|
|
1674
|
+
"Error persisting invalid state root objects",
|
|
1675
|
+
{slot: blockSlot, preStateRoot, postStateRoot},
|
|
1676
|
+
e as Error
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
async persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void> {
|
|
1682
|
+
if (!this.opts.persistInvalidSszObjects) {
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
const blockSlot = block.message.slot;
|
|
1686
|
+
const forkTypes = this.config.getForkTypes(blockSlot);
|
|
1687
|
+
try {
|
|
1688
|
+
await Promise.all([
|
|
1689
|
+
this.persistSszObject(
|
|
1690
|
+
forkTypes.SignedBeaconBlock.typeName,
|
|
1691
|
+
forkTypes.SignedBeaconBlock.serialize(block),
|
|
1692
|
+
toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
|
|
1693
|
+
`${blockSlot}_invalid_signature`
|
|
1694
|
+
),
|
|
1695
|
+
this.persistSszObject(
|
|
1696
|
+
"BeaconState",
|
|
1697
|
+
state.serialize(),
|
|
1698
|
+
toRootHex(state.hashTreeRoot()),
|
|
1699
|
+
`${state.slot}_invalid_signature`
|
|
1700
|
+
),
|
|
1701
|
+
]);
|
|
1702
|
+
} catch (e) {
|
|
1703
|
+
this.logger.error("Error persisting invalid signature objects", {slot: blockSlot}, e as Error);
|
|
1704
|
+
}
|
|
1641
1705
|
}
|
|
1642
1706
|
|
|
1643
1707
|
persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void {
|
|
@@ -1652,12 +1716,6 @@ export class BeaconChain implements IBeaconChain {
|
|
|
1652
1716
|
}
|
|
1653
1717
|
}
|
|
1654
1718
|
|
|
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
1719
|
/**
|
|
1662
1720
|
* Regenerate state for attestation verification, this does not happen with default chain option of maxSkipSlots = 32 .
|
|
1663
1721
|
* However, need to handle just in case. Lodestar doesn't support multiple regen state requests for attestation verification
|
|
@@ -151,6 +151,14 @@ export enum AttestationErrorCode {
|
|
|
151
151
|
* Gloas: index-1 attestation but the execution payload has not been seen yet
|
|
152
152
|
*/
|
|
153
153
|
EXECUTION_PAYLOAD_NOT_SEEN = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_NOT_SEEN",
|
|
154
|
+
/**
|
|
155
|
+
* Gloas: index-1 attestation to a block whose execution payload is not yet validated by the execution engine
|
|
156
|
+
*/
|
|
157
|
+
EXECUTION_PAYLOAD_OPTIMISTIC = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_OPTIMISTIC",
|
|
158
|
+
/**
|
|
159
|
+
* Gloas: index-1 attestation to a block whose execution payload was invalidated
|
|
160
|
+
*/
|
|
161
|
+
EXECUTION_PAYLOAD_INVALID = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_INVALID",
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
export type AttestationErrorType =
|
|
@@ -190,7 +198,9 @@ export type AttestationErrorType =
|
|
|
190
198
|
| {code: AttestationErrorCode.ATTESTER_NOT_IN_COMMITTEE}
|
|
191
199
|
| {code: AttestationErrorCode.INVALID_PAYLOAD_STATUS_VALUE; attDataIndex: number}
|
|
192
200
|
| {code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT}
|
|
193
|
-
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
201
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
202
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC; beaconBlockRoot: RootHex}
|
|
203
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID; beaconBlockRoot: RootHex};
|
|
194
204
|
|
|
195
205
|
export class AttestationError extends GossipActionError<AttestationErrorType> {
|
|
196
206
|
getMetadata(): Record<string, string | number | null> {
|
|
@@ -9,10 +9,17 @@ export enum ExecutionPayloadEnvelopeErrorCode {
|
|
|
9
9
|
ENVELOPE_ALREADY_KNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_ALREADY_KNOWN",
|
|
10
10
|
INVALID_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_BLOCK",
|
|
11
11
|
SLOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISMATCH",
|
|
12
|
+
PARENT_BEACON_BLOCK_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PARENT_BEACON_BLOCK_ROOT_MISMATCH",
|
|
12
13
|
BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH",
|
|
14
|
+
PREV_RANDAO_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PREV_RANDAO_MISMATCH",
|
|
15
|
+
GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_GAS_LIMIT_MISMATCH",
|
|
13
16
|
BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH",
|
|
14
17
|
EXECUTION_REQUESTS_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EXECUTION_REQUESTS_ROOT_MISMATCH",
|
|
15
18
|
TOO_MANY_TRANSACTIONS = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_TOO_MANY_TRANSACTIONS",
|
|
19
|
+
PARENT_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PARENT_HASH_MISMATCH",
|
|
20
|
+
INCORRECT_TIMESTAMP = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INCORRECT_TIMESTAMP",
|
|
21
|
+
EMPTY_TRANSACTION = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EMPTY_TRANSACTION",
|
|
22
|
+
WITHDRAWALS_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_WITHDRAWALS_MISMATCH",
|
|
16
23
|
INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
|
|
17
24
|
PAYLOAD_ENVELOPE_INPUT_MISSING = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PAYLOAD_ENVELOPE_INPUT_MISSING",
|
|
18
25
|
}
|
|
@@ -34,6 +41,13 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
34
41
|
envelopeSlot: Slot;
|
|
35
42
|
blockSlot: Slot;
|
|
36
43
|
}
|
|
44
|
+
| {
|
|
45
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH;
|
|
46
|
+
slot: Slot;
|
|
47
|
+
root: RootHex;
|
|
48
|
+
envelopeParentBeaconBlockRoot: RootHex;
|
|
49
|
+
blockParentRoot: RootHex;
|
|
50
|
+
}
|
|
37
51
|
| {
|
|
38
52
|
code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH;
|
|
39
53
|
slot: Slot;
|
|
@@ -41,6 +55,20 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
41
55
|
envelopeBuilderIndex: BuilderIndex;
|
|
42
56
|
bidBuilderIndex: BuilderIndex | null;
|
|
43
57
|
}
|
|
58
|
+
| {
|
|
59
|
+
code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH;
|
|
60
|
+
slot: Slot;
|
|
61
|
+
root: RootHex;
|
|
62
|
+
envelopePrevRandao: RootHex;
|
|
63
|
+
bidPrevRandao: RootHex;
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH;
|
|
67
|
+
slot: Slot;
|
|
68
|
+
root: RootHex;
|
|
69
|
+
envelopeGasLimit: number;
|
|
70
|
+
bidGasLimit: bigint;
|
|
71
|
+
}
|
|
44
72
|
| {
|
|
45
73
|
code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH;
|
|
46
74
|
slot: Slot;
|
|
@@ -62,6 +90,28 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
62
90
|
transactionCount: number;
|
|
63
91
|
maxTransactionCount: number;
|
|
64
92
|
}
|
|
93
|
+
| {
|
|
94
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH;
|
|
95
|
+
slot: Slot;
|
|
96
|
+
root: RootHex;
|
|
97
|
+
envelopeParentHash: RootHex;
|
|
98
|
+
latestBlockHash: RootHex;
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP;
|
|
102
|
+
slot: Slot;
|
|
103
|
+
root: RootHex;
|
|
104
|
+
envelopeTimestamp: number;
|
|
105
|
+
expectedTimestamp: number;
|
|
106
|
+
}
|
|
107
|
+
| {code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION; slot: Slot; root: RootHex; transactionIndex: number}
|
|
108
|
+
| {
|
|
109
|
+
code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH;
|
|
110
|
+
slot: Slot;
|
|
111
|
+
root: RootHex;
|
|
112
|
+
envelopeWithdrawalsRoot: RootHex;
|
|
113
|
+
expectedWithdrawalsRoot: RootHex;
|
|
114
|
+
}
|
|
65
115
|
| {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE; slot: Slot; root: RootHex}
|
|
66
116
|
| {code: ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING; blockRoot: RootHex};
|
|
67
117
|
|
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?.({
|
|
@@ -22,7 +22,7 @@ import {MapDef} from "@lodestar/utils";
|
|
|
22
22
|
//
|
|
23
23
|
// Assuming we're at epoch 99 while all other nodes at epoch 100, they all accept attestations at epoch 99, 100.
|
|
24
24
|
// If MAX_RETAINED_EPOCH = 2 then lowestPermissibleEpoch is 97 which is more than enough
|
|
25
|
-
const EPOCH_LOOKBACK_LIMIT = 2;
|
|
25
|
+
export const EPOCH_LOOKBACK_LIMIT = 2;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Keeps a cache to filter unaggregated attestations from the same validator in the same epoch.
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
import {Epoch, ValidatorIndex} from "@lodestar/types";
|
|
2
|
-
import {
|
|
3
|
-
// TODO abstract out the Seen* caches into an abstract abstract data structure
|
|
4
|
-
// that all the caches can extend since they share similar structure.
|
|
2
|
+
import {EPOCH_LOOKBACK_LIMIT} from "./seenAttesters.js";
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
/** A bitset per epoch, block import adds tens of thousands of indices per block on the main thread */
|
|
5
|
+
export class SeenBlockAttesters {
|
|
6
|
+
private readonly bitsByEpoch = new Map<Epoch, Uint8Array>();
|
|
7
|
+
private lowestPermissibleEpoch: Epoch = 0;
|
|
8
|
+
private byteLength = 0;
|
|
9
|
+
|
|
10
|
+
isKnown(epoch: Epoch, validatorIndex: ValidatorIndex): boolean {
|
|
11
|
+
const bits = this.bitsByEpoch.get(epoch);
|
|
12
|
+
// The index comes from API requests, the bitwise operators below would truncate it and alias a tracked index
|
|
13
|
+
if (
|
|
14
|
+
bits === undefined ||
|
|
15
|
+
!Number.isInteger(validatorIndex) ||
|
|
16
|
+
validatorIndex < 0 ||
|
|
17
|
+
validatorIndex >= bits.length * 8
|
|
18
|
+
) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
// Validator i is bit (i % 8) of byte floor(i / 8): `>>> 3` picks the byte, `& 7` the bit inside it
|
|
22
|
+
return (bits[validatorIndex >>> 3] & (1 << (validatorIndex & 7))) !== 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** `validatorIndexes` must be indices of the validator registry */
|
|
7
26
|
addIndices(epoch: Epoch, validatorIndexes: ValidatorIndex[]): void {
|
|
8
27
|
if (epoch < this.lowestPermissibleEpoch) {
|
|
9
28
|
throw Error(`EpochTooLow ${epoch} < ${this.lowestPermissibleEpoch}`);
|
|
10
29
|
}
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
let bits = this.bitsByEpoch.get(epoch);
|
|
32
|
+
if (bits === undefined) {
|
|
33
|
+
bits = new Uint8Array(this.byteLength);
|
|
34
|
+
this.bitsByEpoch.set(epoch, bits);
|
|
35
|
+
}
|
|
13
36
|
|
|
14
37
|
for (const index of validatorIndexes) {
|
|
15
|
-
|
|
38
|
+
// floor(index / 8), the byte that holds this validator's bit
|
|
39
|
+
const byteIndex = index >>> 3;
|
|
40
|
+
if (byteIndex >= bits.length) {
|
|
41
|
+
const grown: Uint8Array = new Uint8Array(Math.max(byteIndex + 1, bits.length * 2));
|
|
42
|
+
grown.set(bits);
|
|
43
|
+
bits = grown;
|
|
44
|
+
this.bitsByEpoch.set(epoch, bits);
|
|
45
|
+
this.byteLength = Math.max(this.byteLength, bits.length);
|
|
46
|
+
}
|
|
47
|
+
// Set bit (index % 8) of that byte
|
|
48
|
+
bits[byteIndex] |= 1 << (index & 7);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
prune(currentEpoch: Epoch): void {
|
|
53
|
+
this.lowestPermissibleEpoch = Math.max(currentEpoch - EPOCH_LOOKBACK_LIMIT, 0);
|
|
54
|
+
for (const epoch of this.bitsByEpoch.keys()) {
|
|
55
|
+
if (epoch < this.lowestPermissibleEpoch) {
|
|
56
|
+
this.bitsByEpoch.delete(epoch);
|
|
57
|
+
}
|
|
16
58
|
}
|
|
17
59
|
}
|
|
18
60
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
|
|
1
2
|
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
2
3
|
import {
|
|
3
4
|
ISignatureSet,
|
|
@@ -100,15 +101,29 @@ async function validateAggregateAndProof(
|
|
|
100
101
|
// (a client MAY queue attestations for processing until the payload is imported and SHOULD
|
|
101
102
|
// request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
|
|
102
103
|
// `aggregate.data.beacon_block_root`).
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
104
|
+
if (block !== null && attData.index === 1) {
|
|
105
|
+
const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
|
|
106
|
+
const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
|
|
107
|
+
if (fullBlock === null) {
|
|
108
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
109
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
110
|
+
beaconBlockRoot,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// [IGNORE] The attested execution payload is optimistic
|
|
114
|
+
if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
|
|
115
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
116
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
|
|
117
|
+
beaconBlockRoot,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// [REJECT] The attested execution payload is processed and invalid
|
|
121
|
+
if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
122
|
+
throw new AttestationError(GossipAction.REJECT, {
|
|
123
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
|
|
124
|
+
beaconBlockRoot,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
112
127
|
}
|
|
113
128
|
|
|
114
129
|
// [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {BitArray} from "@chainsafe/ssz";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
-
import {ProtoBlock} from "@lodestar/fork-choice";
|
|
3
|
+
import {ExecutionStatus, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
4
4
|
import {
|
|
5
5
|
ATTESTATION_SUBNET_COUNT,
|
|
6
6
|
DOMAIN_BEACON_ATTESTER,
|
|
@@ -309,25 +309,6 @@ async function validateAttestationNoSignatureCheck(
|
|
|
309
309
|
code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
-
|
|
313
|
-
// [REJECT] If `attestation.data.index == 1` (payload present for a past block),
|
|
314
|
-
// the execution payload for `block` passes validation.
|
|
315
|
-
// [IGNORE] When `attestation.data.index == 1` (payload present for a past block),
|
|
316
|
-
// the execution payload for `block` has been fully imported, including its data -- i.e.
|
|
317
|
-
// `is_payload_verified(store, attestation.data.beacon_block_root)` returns `True`
|
|
318
|
-
// (a client MAY queue attestations for processing until the payload is imported and
|
|
319
|
-
// SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot` using
|
|
320
|
-
// `attestation.data.beacon_block_root`).
|
|
321
|
-
if (
|
|
322
|
-
block !== null &&
|
|
323
|
-
attData.index === 1 &&
|
|
324
|
-
!chain.forkChoice.hasPayloadHexUnsafe(toRootHex(attData.beaconBlockRoot))
|
|
325
|
-
) {
|
|
326
|
-
throw new AttestationError(GossipAction.IGNORE, {
|
|
327
|
-
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
328
|
-
beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
312
|
} else {
|
|
332
313
|
// [REJECT] attestation.data.index == 0
|
|
333
314
|
if (attData.index !== 0) {
|
|
@@ -343,6 +324,36 @@ async function validateAttestationNoSignatureCheck(
|
|
|
343
324
|
committeeIndex = attestationOrCache.cache.committeeIndex;
|
|
344
325
|
}
|
|
345
326
|
|
|
327
|
+
// The payload status can change after the attestation data was cached, so this runs for cached data too
|
|
328
|
+
if (isForkPostGloas(fork) && attData.index === 1) {
|
|
329
|
+
const beaconBlockRoot = toRootHex(attData.beaconBlockRoot);
|
|
330
|
+
const fullBlock = chain.forkChoice.getBlockHex(beaconBlockRoot, PayloadStatus.FULL);
|
|
331
|
+
// [IGNORE] The corresponding execution payload envelope has been seen and verified
|
|
332
|
+
// (a client MAY queue attestations for processing until the payload is imported and
|
|
333
|
+
// SHOULD request the payload envelope via `ExecutionPayloadEnvelopesByRoot`).
|
|
334
|
+
// An unknown block is handled by `verifyHeadBlockAndTargetRoot`
|
|
335
|
+
if (fullBlock === null) {
|
|
336
|
+
if (chain.forkChoice.hasBlockHexUnsafe(beaconBlockRoot)) {
|
|
337
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
338
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
|
|
339
|
+
beaconBlockRoot,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
} else if (fullBlock.executionStatus === ExecutionStatus.Syncing) {
|
|
343
|
+
// [IGNORE] The attested execution payload is optimistic
|
|
344
|
+
throw new AttestationError(GossipAction.IGNORE, {
|
|
345
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC,
|
|
346
|
+
beaconBlockRoot,
|
|
347
|
+
});
|
|
348
|
+
} else if (fullBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
349
|
+
// [REJECT] The attested execution payload is processed and invalid
|
|
350
|
+
throw new AttestationError(GossipAction.REJECT, {
|
|
351
|
+
code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID,
|
|
352
|
+
beaconBlockRoot,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
346
357
|
chain.metrics?.gossipAttestation.attestationSlotToClockSlot.observe(
|
|
347
358
|
{caller: RegenCaller.validateGossipAttestation},
|
|
348
359
|
chain.clock.currentSlot - attSlot
|
|
@@ -121,13 +121,21 @@ export async function validateGossipBlock(
|
|
|
121
121
|
// (via gossip or non-gossip sources) (a client MAY queue blocks for processing once the parent payload is retrieved).
|
|
122
122
|
if (isGloasBeaconBlock(block)) {
|
|
123
123
|
const parentBlockHashHex = toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash);
|
|
124
|
-
|
|
124
|
+
const parentPayloadBlock = chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex);
|
|
125
|
+
if (parentPayloadBlock === null) {
|
|
125
126
|
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
126
127
|
code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
|
|
127
128
|
parentRoot,
|
|
128
129
|
parentBlockHash: parentBlockHashHex,
|
|
129
130
|
});
|
|
130
131
|
}
|
|
132
|
+
// [IGNORE] The block's parent passed validation but the payload it builds on is invalid
|
|
133
|
+
if (parentPayloadBlock.executionStatus === ExecutionStatus.Invalid) {
|
|
134
|
+
throw new BlockGossipError(GossipAction.IGNORE, {
|
|
135
|
+
code: BlockErrorCode.PARENT_EXECUTION_INVALID,
|
|
136
|
+
parentRoot,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
// [REJECT] The block is from a higher slot than its parent.
|
|
@@ -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
|
*
|
|
@@ -187,11 +160,8 @@ async function validateExecutionPayloadBid(
|
|
|
187
160
|
|
|
188
161
|
// [IGNORE] this bid is the highest value bid seen for the tuple
|
|
189
162
|
// `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
|
|
190
|
-
// As a DoS prevention measure, the bid must also exceed the current highest bid by a minimum
|
|
191
|
-
// increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
|
|
192
|
-
// from builders submitting numerous bids with minimal value increments.
|
|
193
163
|
const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
|
|
194
|
-
if (bestBid !== null && bid.value
|
|
164
|
+
if (bestBid !== null && bid.value <= bestBid.signedBid.message.value) {
|
|
195
165
|
throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
|
|
196
166
|
code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
|
|
197
167
|
bidValue: bid.value,
|