@lodestar/state-transition 1.39.1 → 1.40.0-dev.193b2e2047
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/block/index.d.ts +1 -0
- package/lib/block/index.d.ts.map +1 -1
- package/lib/block/index.js +1 -0
- package/lib/block/index.js.map +1 -1
- package/lib/block/isValidIndexedAttestation.d.ts +4 -5
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +9 -10
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js.map +1 -1
- package/lib/block/processAttestationPhase0.d.ts.map +1 -1
- package/lib/block/processAttestationPhase0.js +1 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +2 -2
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.d.ts +3 -2
- package/lib/block/processAttesterSlashing.d.ts.map +1 -1
- package/lib/block/processAttesterSlashing.js +3 -3
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processBlsToExecutionChange.d.ts +3 -1
- package/lib/block/processBlsToExecutionChange.d.ts.map +1 -1
- package/lib/block/processBlsToExecutionChange.js +7 -11
- package/lib/block/processBlsToExecutionChange.js.map +1 -1
- package/lib/block/processConsolidationRequest.d.ts +1 -2
- package/lib/block/processConsolidationRequest.d.ts.map +1 -1
- package/lib/block/processConsolidationRequest.js +2 -2
- package/lib/block/processConsolidationRequest.js.map +1 -1
- package/lib/block/processDepositRequest.d.ts +8 -2
- package/lib/block/processDepositRequest.d.ts.map +1 -1
- package/lib/block/processDepositRequest.js +81 -8
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadBid.js +16 -29
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +26 -25
- package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
- package/lib/block/processOperations.js +2 -2
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts +5 -2
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +8 -6
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processSyncCommittee.d.ts +1 -2
- package/lib/block/processSyncCommittee.d.ts.map +1 -1
- package/lib/block/processSyncCommittee.js +5 -5
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.d.ts +1 -1
- package/lib/block/processVoluntaryExit.d.ts.map +1 -1
- package/lib/block/processVoluntaryExit.js +45 -3
- package/lib/block/processVoluntaryExit.js.map +1 -1
- package/lib/block/processWithdrawalRequest.js +1 -1
- package/lib/block/processWithdrawalRequest.js.map +1 -1
- package/lib/block/processWithdrawals.d.ts +1 -0
- package/lib/block/processWithdrawals.d.ts.map +1 -1
- package/lib/block/processWithdrawals.js +121 -66
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/cache/epochCache.d.ts +8 -28
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +40 -180
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/epochTransitionCache.d.ts +5 -12
- package/lib/cache/epochTransitionCache.d.ts.map +1 -1
- package/lib/cache/epochTransitionCache.js +4 -14
- package/lib/cache/epochTransitionCache.js.map +1 -1
- package/lib/cache/stateCache.d.ts.map +1 -1
- package/lib/cache/stateCache.js +1 -2
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/epoch/processBuilderPendingPayments.d.ts.map +1 -1
- package/lib/epoch/processBuilderPendingPayments.js +1 -4
- package/lib/epoch/processBuilderPendingPayments.js.map +1 -1
- package/lib/epoch/processProposerLookahead.d.ts.map +1 -1
- package/lib/epoch/processProposerLookahead.js +3 -6
- package/lib/epoch/processProposerLookahead.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/rewards/blockRewards.d.ts +2 -1
- package/lib/rewards/blockRewards.d.ts.map +1 -1
- package/lib/rewards/blockRewards.js +3 -2
- package/lib/rewards/blockRewards.js.map +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
- package/lib/rewards/syncCommitteeRewards.js +10 -11
- package/lib/rewards/syncCommitteeRewards.js.map +1 -1
- package/lib/signatureSets/attesterSlashings.d.ts +3 -4
- package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
- package/lib/signatureSets/attesterSlashings.js +6 -6
- package/lib/signatureSets/attesterSlashings.js.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.d.ts +4 -5
- package/lib/signatureSets/blsToExecutionChange.d.ts.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js +2 -2
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/executionPayloadBid.d.ts +4 -0
- package/lib/signatureSets/executionPayloadBid.d.ts.map +1 -0
- package/lib/signatureSets/executionPayloadBid.js +8 -0
- package/lib/signatureSets/executionPayloadBid.js.map +1 -0
- package/lib/signatureSets/executionPayloadEnvelope.d.ts +4 -0
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -0
- package/lib/signatureSets/executionPayloadEnvelope.js +8 -0
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -0
- package/lib/signatureSets/index.d.ts +3 -2
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +10 -8
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.d.ts +3 -4
- package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedAttestation.js +6 -6
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/indexedPayloadAttestation.d.ts +5 -4
- package/lib/signatureSets/indexedPayloadAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedPayloadAttestation.js +3 -3
- package/lib/signatureSets/indexedPayloadAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +3 -3
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +12 -12
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.d.ts +2 -3
- package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
- package/lib/signatureSets/proposerSlashings.js +6 -6
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +1 -1
- package/lib/signatureSets/randao.d.ts.map +1 -1
- package/lib/signatureSets/randao.js +4 -4
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +2 -2
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +6 -6
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/util/electra.d.ts.map +1 -1
- package/lib/util/electra.js +1 -2
- package/lib/util/electra.js.map +1 -1
- package/lib/util/epochShuffling.d.ts +1 -34
- package/lib/util/epochShuffling.d.ts.map +1 -1
- package/lib/util/epochShuffling.js +1 -1
- package/lib/util/epochShuffling.js.map +1 -1
- package/lib/util/gloas.d.ts +46 -5
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +91 -5
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/index.d.ts +2 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +2 -2
- package/lib/util/index.js.map +1 -1
- package/lib/util/shuffling.d.ts +58 -0
- package/lib/util/shuffling.d.ts.map +1 -0
- package/lib/util/shuffling.js +175 -0
- package/lib/util/shuffling.js.map +1 -0
- package/lib/util/signatureSets.d.ts +38 -5
- package/lib/util/signatureSets.d.ts.map +1 -1
- package/lib/util/signatureSets.js +48 -6
- package/lib/util/signatureSets.js.map +1 -1
- package/lib/util/validator.d.ts +6 -1
- package/lib/util/validator.d.ts.map +1 -1
- package/lib/util/validator.js +26 -16
- package/lib/util/validator.js.map +1 -1
- package/package.json +7 -7
- package/src/block/index.ts +1 -0
- package/src/block/isValidIndexedAttestation.ts +18 -12
- package/src/block/isValidIndexedPayloadAttestation.ts +4 -1
- package/src/block/processAttestationPhase0.ts +2 -1
- package/src/block/processAttestationsAltair.ts +2 -8
- package/src/block/processAttesterSlashing.ts +16 -4
- package/src/block/processBlsToExecutionChange.ts +13 -14
- package/src/block/processConsolidationRequest.ts +2 -3
- package/src/block/processDepositRequest.ts +101 -8
- package/src/block/processExecutionPayloadBid.ts +20 -42
- package/src/block/processExecutionPayloadEnvelope.ts +34 -30
- package/src/block/processOperations.ts +2 -2
- package/src/block/processProposerSlashing.ts +22 -12
- package/src/block/processSyncCommittee.ts +3 -6
- package/src/block/processVoluntaryExit.ts +60 -5
- package/src/block/processWithdrawalRequest.ts +1 -1
- package/src/block/processWithdrawals.ts +168 -70
- package/src/cache/epochCache.ts +52 -214
- package/src/cache/epochTransitionCache.ts +9 -34
- package/src/cache/stateCache.ts +1 -2
- package/src/epoch/processBuilderPendingPayments.ts +1 -5
- package/src/epoch/processProposerLookahead.ts +3 -7
- package/src/index.ts +0 -2
- package/src/rewards/blockRewards.ts +6 -3
- package/src/rewards/syncCommitteeRewards.ts +10 -13
- package/src/signatureSets/attesterSlashings.ts +3 -7
- package/src/signatureSets/blsToExecutionChange.ts +5 -6
- package/src/signatureSets/executionPayloadBid.ts +14 -0
- package/src/signatureSets/executionPayloadEnvelope.ts +13 -0
- package/src/signatureSets/index.ts +8 -9
- package/src/signatureSets/indexedAttestation.ts +2 -7
- package/src/signatureSets/indexedPayloadAttestation.ts +9 -7
- package/src/signatureSets/proposer.ts +8 -12
- package/src/signatureSets/proposerSlashings.ts +4 -7
- package/src/signatureSets/randao.ts +4 -8
- package/src/signatureSets/voluntaryExits.ts +5 -10
- package/src/types.ts +1 -0
- package/src/util/electra.ts +1 -4
- package/src/util/epochShuffling.ts +2 -43
- package/src/util/gloas.ts +116 -10
- package/src/util/index.ts +2 -2
- package/src/util/shuffling.ts +234 -0
- package/src/util/signatureSets.ts +84 -8
- package/src/util/validator.ts +31 -16
- package/lib/util/calculateCommitteeAssignments.d.ts +0 -12
- package/lib/util/calculateCommitteeAssignments.d.ts.map +0 -1
- package/lib/util/calculateCommitteeAssignments.js +0 -26
- package/lib/util/calculateCommitteeAssignments.js.map +0 -1
- package/lib/util/shufflingDecisionRoot.d.ts +0 -20
- package/lib/util/shufflingDecisionRoot.d.ts.map +0 -1
- package/lib/util/shufflingDecisionRoot.js +0 -76
- package/lib/util/shufflingDecisionRoot.js.map +0 -1
- package/src/util/calculateCommitteeAssignments.ts +0 -43
- package/src/util/shufflingDecisionRoot.ts +0 -81
|
@@ -2,10 +2,10 @@ import { DOMAIN_PTC_ATTESTER } from "@lodestar/params";
|
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { computeSigningRoot, createAggregateSignatureSetFromComponents } from "../util/index.js";
|
|
4
4
|
export function getIndexedPayloadAttestationSignatureSet(state, indexedPayloadAttestation) {
|
|
5
|
-
return createAggregateSignatureSetFromComponents(indexedPayloadAttestation.attestingIndices
|
|
5
|
+
return createAggregateSignatureSetFromComponents(indexedPayloadAttestation.attestingIndices, getPayloadAttestationDataSigningRoot(state.config, state.slot, indexedPayloadAttestation.data), indexedPayloadAttestation.signature);
|
|
6
6
|
}
|
|
7
|
-
export function getPayloadAttestationDataSigningRoot(
|
|
8
|
-
const domain =
|
|
7
|
+
export function getPayloadAttestationDataSigningRoot(config, stateSlot, data) {
|
|
8
|
+
const domain = config.getDomain(stateSlot, DOMAIN_PTC_ATTESTER);
|
|
9
9
|
return computeSigningRoot(ssz.gloas.PayloadAttestationData, data, domain);
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=indexedPayloadAttestation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexedPayloadAttestation.js","sourceRoot":"","sources":["../../src/signatureSets/indexedPayloadAttestation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexedPayloadAttestation.js","sourceRoot":"","sources":["../../src/signatureSets/indexedPayloadAttestation.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAc,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAgB,kBAAkB,EAAE,yCAAyC,EAAC,MAAM,kBAAkB,CAAC;AAE9G,MAAM,UAAU,wCAAwC,CACtD,KAA6B,EAC7B,yBAA0D;IAE1D,OAAO,yCAAyC,CAC9C,yBAAyB,CAAC,gBAAgB,EAC1C,oCAAoC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,yBAAyB,CAAC,IAAI,CAAC,EAC9F,yBAAyB,CAAC,SAAS,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,MAAoB,EACpB,SAAe,EACf,IAAkC;IAElC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAEhE,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, phase0 } from "@lode
|
|
|
3
3
|
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
4
4
|
import { ISignatureSet } from "../util/signatureSets.js";
|
|
5
5
|
export declare function verifyProposerSignature(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock): boolean;
|
|
6
|
-
export declare function getBlockProposerSignatureSet(config: BeaconConfig,
|
|
7
|
-
export declare function getBlockHeaderProposerSignatureSetByParentStateSlot(config: BeaconConfig,
|
|
8
|
-
export declare function getBlockHeaderProposerSignatureSetByHeaderSlot(config: BeaconConfig,
|
|
6
|
+
export declare function getBlockProposerSignatureSet(config: BeaconConfig, signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock): ISignatureSet;
|
|
7
|
+
export declare function getBlockHeaderProposerSignatureSetByParentStateSlot(config: BeaconConfig, parentStateSlot: Slot, signedBlockHeader: phase0.SignedBeaconBlockHeader): ISignatureSet;
|
|
8
|
+
export declare function getBlockHeaderProposerSignatureSetByHeaderSlot(config: BeaconConfig, signedBlockHeader: phase0.SignedBeaconBlockHeader): ISignatureSet;
|
|
9
9
|
//# sourceMappingURL=proposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposer.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,wBAAwB,EAAE,IAAI,EAAwB,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,aAAa,EAAuC,MAAM,0BAA0B,CAAC;AAE7F,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAAG,wBAAwB,GACxD,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,
|
|
1
|
+
{"version":3,"file":"proposer.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,wBAAwB,EAAE,IAAI,EAAwB,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,aAAa,EAAuC,MAAM,0BAA0B,CAAC;AAE7F,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAAG,wBAAwB,GACxD,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,iBAAiB,GAAG,wBAAwB,GACxD,aAAa,CAgBf;AAED,wBAAgB,mDAAmD,CACjE,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,IAAI,EACrB,iBAAiB,EAAE,MAAM,CAAC,uBAAuB,iBAGlD;AAED,wBAAgB,8CAA8C,CAC5D,MAAM,EAAE,YAAY,EACpB,iBAAiB,EAAE,MAAM,CAAC,uBAAuB,iBAGlD"}
|
|
@@ -3,10 +3,10 @@ import { isBlindedBeaconBlock, ssz } from "@lodestar/types";
|
|
|
3
3
|
import { computeSigningRoot } from "../util/index.js";
|
|
4
4
|
import { SignatureSetType, verifySignatureSet } from "../util/signatureSets.js";
|
|
5
5
|
export function verifyProposerSignature(config, index2pubkey, signedBlock) {
|
|
6
|
-
const signatureSet = getBlockProposerSignatureSet(config,
|
|
7
|
-
return verifySignatureSet(signatureSet);
|
|
6
|
+
const signatureSet = getBlockProposerSignatureSet(config, signedBlock);
|
|
7
|
+
return verifySignatureSet(signatureSet, index2pubkey);
|
|
8
8
|
}
|
|
9
|
-
export function getBlockProposerSignatureSet(config,
|
|
9
|
+
export function getBlockProposerSignatureSet(config, signedBlock) {
|
|
10
10
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
11
11
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
12
12
|
const blockSlot = signedBlock.message.slot;
|
|
@@ -15,23 +15,23 @@ export function getBlockProposerSignatureSet(config, index2pubkey, signedBlock)
|
|
|
15
15
|
? config.getPostBellatrixForkTypes(signedBlock.message.slot).BlindedBeaconBlock
|
|
16
16
|
: config.getForkTypes(signedBlock.message.slot).BeaconBlock;
|
|
17
17
|
return {
|
|
18
|
-
type: SignatureSetType.
|
|
19
|
-
|
|
18
|
+
type: SignatureSetType.indexed,
|
|
19
|
+
index: signedBlock.message.proposerIndex,
|
|
20
20
|
signingRoot: computeSigningRoot(blockType, signedBlock.message, domain),
|
|
21
21
|
signature: signedBlock.signature,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
export function getBlockHeaderProposerSignatureSetByParentStateSlot(config,
|
|
25
|
-
return getBlockHeaderProposerSignatureSet(config,
|
|
24
|
+
export function getBlockHeaderProposerSignatureSetByParentStateSlot(config, parentStateSlot, signedBlockHeader) {
|
|
25
|
+
return getBlockHeaderProposerSignatureSet(config, signedBlockHeader, parentStateSlot);
|
|
26
26
|
}
|
|
27
|
-
export function getBlockHeaderProposerSignatureSetByHeaderSlot(config,
|
|
28
|
-
return getBlockHeaderProposerSignatureSet(config,
|
|
27
|
+
export function getBlockHeaderProposerSignatureSetByHeaderSlot(config, signedBlockHeader) {
|
|
28
|
+
return getBlockHeaderProposerSignatureSet(config, signedBlockHeader, signedBlockHeader.message.slot);
|
|
29
29
|
}
|
|
30
|
-
function getBlockHeaderProposerSignatureSet(config,
|
|
30
|
+
function getBlockHeaderProposerSignatureSet(config, signedBlockHeader, domainSlot) {
|
|
31
31
|
const domain = config.getDomain(domainSlot, DOMAIN_BEACON_PROPOSER, signedBlockHeader.message.slot);
|
|
32
32
|
return {
|
|
33
|
-
type: SignatureSetType.
|
|
34
|
-
|
|
33
|
+
type: SignatureSetType.indexed,
|
|
34
|
+
index: signedBlockHeader.message.proposerIndex,
|
|
35
35
|
signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeader, signedBlockHeader.message, domain),
|
|
36
36
|
signature: signedBlockHeader.signature,
|
|
37
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposer.js","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAoD,oBAAoB,EAAU,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAErH,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAgB,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE7F,MAAM,UAAU,uBAAuB,CACrC,MAAoB,EACpB,YAA+B,EAC/B,WAAyD;IAEzD,MAAM,YAAY,GAAG,4BAA4B,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"proposer.js","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAoD,oBAAoB,EAAU,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAErH,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAgB,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE7F,MAAM,UAAU,uBAAuB,CACrC,MAAoB,EACpB,YAA+B,EAC/B,WAAyD;IAEzD,MAAM,YAAY,GAAG,4BAA4B,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvE,OAAO,kBAAkB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,MAAoB,EACpB,WAAyD;IAEzD,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,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EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC;QAChG,SAAS,EAAE,iBAAiB,CAAC,SAAS;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { BeaconConfig } from "@lodestar/config";
|
|
2
2
|
import { SignedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
3
|
-
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
4
3
|
import { ISignatureSet } from "../util/index.js";
|
|
5
4
|
/**
|
|
6
5
|
* Extract signatures to allow validating all block signatures at once
|
|
7
6
|
*/
|
|
8
|
-
export declare function getProposerSlashingSignatureSets(config: BeaconConfig,
|
|
9
|
-
export declare function getProposerSlashingsSignatureSets(config: BeaconConfig,
|
|
7
|
+
export declare function getProposerSlashingSignatureSets(config: BeaconConfig, stateSlot: Slot, proposerSlashing: phase0.ProposerSlashing): ISignatureSet[];
|
|
8
|
+
export declare function getProposerSlashingsSignatureSets(config: BeaconConfig, signedBlock: SignedBeaconBlock): ISignatureSet[];
|
|
10
9
|
//# sourceMappingURL=proposerSlashings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"proposerSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,aAAa,EAAuC,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,IAAI,EACf,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,GACxC,aAAa,EAAE,CAejB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,iBAAiB,GAC7B,aAAa,EAAE,CAOjB"}
|
|
@@ -4,24 +4,24 @@ import { SignatureSetType, computeSigningRoot } from "../util/index.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Extract signatures to allow validating all block signatures at once
|
|
6
6
|
*/
|
|
7
|
-
export function getProposerSlashingSignatureSets(config,
|
|
8
|
-
const
|
|
7
|
+
export function getProposerSlashingSignatureSets(config, stateSlot, proposerSlashing) {
|
|
8
|
+
const proposerIndex = proposerSlashing.signedHeader1.message.proposerIndex;
|
|
9
9
|
// In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
|
|
10
10
|
// clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
|
|
11
11
|
return [proposerSlashing.signedHeader1, proposerSlashing.signedHeader2].map((signedHeader) => {
|
|
12
12
|
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot));
|
|
13
13
|
return {
|
|
14
|
-
type: SignatureSetType.
|
|
15
|
-
|
|
14
|
+
type: SignatureSetType.indexed,
|
|
15
|
+
index: proposerIndex,
|
|
16
16
|
signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeaderBigint, signedHeader.message, domain),
|
|
17
17
|
signature: signedHeader.signature,
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
export function getProposerSlashingsSignatureSets(config,
|
|
21
|
+
export function getProposerSlashingsSignatureSets(config, signedBlock) {
|
|
22
22
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
23
23
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
24
24
|
const blockSlot = signedBlock.message.slot;
|
|
25
|
-
return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) => getProposerSlashingSignatureSets(config,
|
|
25
|
+
return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) => getProposerSlashingSignatureSets(config, blockSlot, proposerSlashing));
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=proposerSlashings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAkC,GAAG,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"proposerSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAkC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAgB,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAoB,EACpB,SAAe,EACf,gBAAyC;IAEzC,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC;IAE3E,kHAAkH;IAClH,iHAAiH;IACjH,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,EAAiB,EAAE;QAC1G,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,sBAAsB,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAc,CAAC,CAAC,CAAC;QAEhH,OAAO;YACL,IAAI,EAAE,gBAAgB,CAAC,OAAO;YAC9B,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,uBAAuB,EAAE,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC;YACjG,SAAS,EAAE,YAAY,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,MAAoB,EACpB,WAA8B;IAE9B,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAC7E,gCAAgC,CAAC,MAAM,EAAE,SAAS,EAAE,gBAAgB,CAAC,CACtE,CAAC;AACJ,CAAC"}
|
|
@@ -6,5 +6,5 @@ export declare function verifyRandaoSignature(config: BeaconConfig, index2pubkey
|
|
|
6
6
|
/**
|
|
7
7
|
* Extract signatures to allow validating all block signatures at once
|
|
8
8
|
*/
|
|
9
|
-
export declare function getRandaoRevealSignatureSet(config: BeaconConfig,
|
|
9
|
+
export declare function getRandaoRevealSignatureSet(config: BeaconConfig, block: BeaconBlock): ISignatureSet;
|
|
10
10
|
//# sourceMappingURL=randao.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randao.d.ts","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAM,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,WAAW,GACjB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"randao.d.ts","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAM,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,WAAW,GACjB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,CAanG"}
|
|
@@ -2,20 +2,20 @@ import { DOMAIN_RANDAO } from "@lodestar/params";
|
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { SignatureSetType, computeEpochAtSlot, computeSigningRoot, verifySignatureSet, } from "../util/index.js";
|
|
4
4
|
export function verifyRandaoSignature(config, index2pubkey, block) {
|
|
5
|
-
return verifySignatureSet(getRandaoRevealSignatureSet(config,
|
|
5
|
+
return verifySignatureSet(getRandaoRevealSignatureSet(config, block), index2pubkey);
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Extract signatures to allow validating all block signatures at once
|
|
9
9
|
*/
|
|
10
|
-
export function getRandaoRevealSignatureSet(config,
|
|
10
|
+
export function getRandaoRevealSignatureSet(config, block) {
|
|
11
11
|
// should not get epoch from epochCtx
|
|
12
12
|
const epoch = computeEpochAtSlot(block.slot);
|
|
13
13
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
14
14
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
15
15
|
const domain = config.getDomain(block.slot, DOMAIN_RANDAO, block.slot);
|
|
16
16
|
return {
|
|
17
|
-
type: SignatureSetType.
|
|
18
|
-
|
|
17
|
+
type: SignatureSetType.indexed,
|
|
18
|
+
index: block.proposerIndex,
|
|
19
19
|
signingRoot: computeSigningRoot(ssz.Epoch, epoch, domain),
|
|
20
20
|
signature: block.body.randaoReveal,
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randao.js","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAEL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,qBAAqB,CACnC,MAAoB,EACpB,YAA+B,EAC/B,KAAkB;IAElB,OAAO,kBAAkB,CAAC,2BAA2B,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"randao.js","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAEL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,qBAAqB,CACnC,MAAoB,EACpB,YAA+B,EAC/B,KAAkB;IAElB,OAAO,kBAAkB,CAAC,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAoB,EAAE,KAAkB;IAClF,qCAAqC;IACrC,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7C,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvE,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,OAAO;QAC9B,KAAK,EAAE,KAAK,CAAC,aAAa;QAC1B,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;QACzD,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,6 @@ export declare function verifyVoluntaryExitSignature(config: BeaconConfig, index
|
|
|
6
6
|
/**
|
|
7
7
|
* Extract signatures to allow validating all block signatures at once
|
|
8
8
|
*/
|
|
9
|
-
export declare function getVoluntaryExitSignatureSet(config: BeaconConfig,
|
|
10
|
-
export declare function getVoluntaryExitsSignatureSets(config: BeaconConfig,
|
|
9
|
+
export declare function getVoluntaryExitSignatureSet(config: BeaconConfig, stateSlot: Slot, signedVoluntaryExit: phase0.SignedVoluntaryExit): ISignatureSet;
|
|
10
|
+
export declare function getVoluntaryExitsSignatureSets(config: BeaconConfig, signedBlock: SignedBeaconBlock): ISignatureSet[];
|
|
11
11
|
//# sourceMappingURL=voluntaryExits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voluntaryExits.d.ts","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,GAC9C,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,
|
|
1
|
+
{"version":3,"file":"voluntaryExits.d.ts","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,GAC9C,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,IAAI,EACf,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,GAC9C,aAAa,CAUf;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,GAAG,aAAa,EAAE,CAOpH"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { ssz } from "@lodestar/types";
|
|
2
2
|
import { SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch, verifySignatureSet, } from "../util/index.js";
|
|
3
3
|
export function verifyVoluntaryExitSignature(config, index2pubkey, stateSlot, signedVoluntaryExit) {
|
|
4
|
-
return verifySignatureSet(getVoluntaryExitSignatureSet(config,
|
|
4
|
+
return verifySignatureSet(getVoluntaryExitSignatureSet(config, stateSlot, signedVoluntaryExit), index2pubkey);
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Extract signatures to allow validating all block signatures at once
|
|
8
8
|
*/
|
|
9
|
-
export function getVoluntaryExitSignatureSet(config,
|
|
9
|
+
export function getVoluntaryExitSignatureSet(config, stateSlot, signedVoluntaryExit) {
|
|
10
10
|
const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
11
11
|
const domain = config.getDomainForVoluntaryExit(stateSlot, messageSlot);
|
|
12
12
|
return {
|
|
13
|
-
type: SignatureSetType.
|
|
14
|
-
|
|
13
|
+
type: SignatureSetType.indexed,
|
|
14
|
+
index: signedVoluntaryExit.message.validatorIndex,
|
|
15
15
|
signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
|
|
16
16
|
signature: signedVoluntaryExit.signature,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export function getVoluntaryExitsSignatureSets(config,
|
|
19
|
+
export function getVoluntaryExitsSignatureSets(config, signedBlock) {
|
|
20
20
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
21
21
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
22
22
|
const blockSlot = signedBlock.message.slot;
|
|
23
|
-
return signedBlock.message.body.voluntaryExits.map((voluntaryExit) => getVoluntaryExitSignatureSet(config,
|
|
23
|
+
return signedBlock.message.body.voluntaryExits.map((voluntaryExit) => getVoluntaryExitSignatureSet(config, blockSlot, voluntaryExit));
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=voluntaryExits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voluntaryExits.js","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEr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;IACjG,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CACnE,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAC/D,CAAC;AACJ,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { EpochCache } from "./cache/epochCache.js";
|
|
2
2
|
export type { EpochTransitionCache } from "./cache/epochTransitionCache.js";
|
|
3
3
|
export type { CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateBellatrix, CachedBeaconStateCapella, CachedBeaconStateDeneb, CachedBeaconStateElectra, CachedBeaconStateExecutions, CachedBeaconStateFulu, CachedBeaconStateGloas, CachedBeaconStatePhase0, } from "./cache/stateCache.js";
|
|
4
|
-
export type { BeaconStateAllForks, BeaconStateAltair, BeaconStateBellatrix, BeaconStateCapella, BeaconStateDeneb, BeaconStateElectra, BeaconStateExecutions, BeaconStateFulu, BeaconStateGloas, BeaconStatePhase0, } from "./cache/types.js";
|
|
4
|
+
export type { BeaconStateAllForks, BeaconStateAltair, BeaconStateBellatrix, BeaconStateCapella, BeaconStateDeneb, BeaconStateElectra, BeaconStateExecutions, BeaconStateFulu, BeaconStateGloas, BeaconStatePhase0, ShufflingGetter, } from "./cache/types.js";
|
|
5
5
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAC1E,YAAY,EACV,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAC1E,YAAY,EACV,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electra.d.ts","sourceRoot":"","sources":["../../src/util/electra.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAM,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAC,wBAAwB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"electra.d.ts","sourceRoot":"","sources":["../../src/util/electra.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAM,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAC,wBAAwB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAG7E,wBAAgB,kCAAkC,CAAC,qBAAqB,EAAE,UAAU,GAAG,OAAO,CAE7F;AAED,wBAAgB,gCAAgC,CAAC,qBAAqB,EAAE,UAAU,GAAG,OAAO,CAI3F;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,wBAAwB,GAAG,sBAAsB,EACxD,KAAK,EAAE,cAAc,GACpB,IAAI,CAcN;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,wBAAwB,GAAG,sBAAsB,EACxD,KAAK,EAAE,cAAc,GACpB,IAAI,CAkBN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,wBAAwB,GAAG,sBAAsB,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAEnH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,wBAAwB,GAAG,sBAAsB,EACxD,KAAK,EAAE,cAAc,GAAG,IAAI,GAC3B,KAAK,IAAI,cAAc,CAEzB"}
|
package/lib/util/electra.js
CHANGED
|
@@ -2,9 +2,8 @@ import { COMPOUNDING_WITHDRAWAL_PREFIX, GENESIS_SLOT, MIN_ACTIVATION_BALANCE } f
|
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { G2_POINT_AT_INFINITY } from "../constants/constants.js";
|
|
4
4
|
import { hasEth1WithdrawalCredential } from "./capella.js";
|
|
5
|
-
import { hasBuilderWithdrawalCredential } from "./gloas.js";
|
|
6
5
|
export function hasCompoundingWithdrawalCredential(withdrawalCredentials) {
|
|
7
|
-
return
|
|
6
|
+
return withdrawalCredentials[0] === COMPOUNDING_WITHDRAWAL_PREFIX;
|
|
8
7
|
}
|
|
9
8
|
export function hasExecutionWithdrawalCredential(withdrawalCredentials) {
|
|
10
9
|
return (hasCompoundingWithdrawalCredential(withdrawalCredentials) || hasEth1WithdrawalCredential(withdrawalCredentials));
|
package/lib/util/electra.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electra.js","sourceRoot":"","sources":["../../src/util/electra.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,YAAY,EAAE,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAiB,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAC,2BAA2B,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"electra.js","sourceRoot":"","sources":["../../src/util/electra.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,YAAY,EAAE,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAiB,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAC,2BAA2B,EAAC,MAAM,cAAc,CAAC;AAEzD,MAAM,UAAU,kCAAkC,CAAC,qBAAiC;IAClF,OAAO,qBAAqB,CAAC,CAAC,CAAC,KAAK,6BAA6B,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,qBAAiC;IAChF,OAAO,CACL,kCAAkC,CAAC,qBAAqB,CAAC,IAAI,2BAA2B,CAAC,qBAAqB,CAAC,CAChH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAwD,EACxD,KAAqB;IAErB,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE9C,mFAAmF;IACnF,mFAAmF;IACnF,uEAAuE;IACvE,MAAM,wBAAwB,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAC9D,SAAS,CAAC,qBAAqB,EAC/B,CAAC,EACD,SAAS,CAAC,qBAAqB,CAAC,MAAM,CACvC,CAAC;IACF,wBAA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}
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import { BeaconConfig } from "@lodestar/config";
|
|
2
2
|
import { Epoch, RootHex, ValidatorIndex } from "@lodestar/types";
|
|
3
|
-
import { GaugeExtra, Logger, NoLabels } from "@lodestar/utils";
|
|
4
3
|
import { BeaconStateAllForks } from "../types.js";
|
|
5
|
-
export interface ShufflingBuildProps {
|
|
6
|
-
state: BeaconStateAllForks;
|
|
7
|
-
activeIndices: Uint32Array;
|
|
8
|
-
}
|
|
9
|
-
export interface PublicShufflingCacheMetrics {
|
|
10
|
-
shufflingCache: {
|
|
11
|
-
nextShufflingNotOnEpochCache: GaugeExtra<NoLabels>;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface IShufflingCache {
|
|
15
|
-
metrics: PublicShufflingCacheMetrics | null;
|
|
16
|
-
logger: Logger | null;
|
|
17
|
-
/**
|
|
18
|
-
* Gets a cached shuffling via the epoch and decision root. If the state and
|
|
19
|
-
* activeIndices are passed and a shuffling is not available it will be built
|
|
20
|
-
* synchronously. If the state is not passed and the shuffling is not available
|
|
21
|
-
* nothing will be returned.
|
|
22
|
-
*
|
|
23
|
-
* NOTE: If a shuffling is already queued and not calculated it will build and resolve
|
|
24
|
-
* the promise but the already queued build will happen at some later time
|
|
25
|
-
*/
|
|
26
|
-
getSync<T extends ShufflingBuildProps | undefined>(epoch: Epoch, decisionRoot: RootHex, buildProps?: T): T extends ShufflingBuildProps ? EpochShuffling : EpochShuffling | null;
|
|
27
|
-
/**
|
|
28
|
-
* Gets a cached shuffling via the epoch and decision root. Returns a promise
|
|
29
|
-
* for the shuffling if it hs not calculated yet. Returns null if a build has
|
|
30
|
-
* not been queued nor a shuffling was calculated.
|
|
31
|
-
*/
|
|
32
|
-
get(epoch: Epoch, decisionRoot: RootHex): Promise<EpochShuffling | null>;
|
|
33
|
-
/**
|
|
34
|
-
* Queue asynchronous build for an EpochShuffling
|
|
35
|
-
*/
|
|
36
|
-
build(epoch: Epoch, decisionRoot: RootHex, state: BeaconStateAllForks, activeIndices: Uint32Array): void;
|
|
37
|
-
}
|
|
38
4
|
/**
|
|
39
5
|
* Readonly interface for EpochShuffling.
|
|
40
6
|
*/
|
|
@@ -72,6 +38,7 @@ export type EpochShuffling = {
|
|
|
72
38
|
export declare function computeCommitteeCount(activeValidatorCount: number): number;
|
|
73
39
|
export declare function computeEpochShuffling(state: BeaconStateAllForks, activeIndices: Uint32Array, epoch: Epoch): EpochShuffling;
|
|
74
40
|
export declare function computeEpochShufflingAsync(state: BeaconStateAllForks, activeIndices: Uint32Array, epoch: Epoch): Promise<EpochShuffling>;
|
|
41
|
+
export declare function calculateDecisionRoot(state: BeaconStateAllForks, epoch: Epoch): RootHex;
|
|
75
42
|
/**
|
|
76
43
|
* Get the shuffling decision block root for the given epoch of given state
|
|
77
44
|
* - Special case close to genesis block, return the genesis block root
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochShuffling.d.ts","sourceRoot":"","sources":["../../src/util/epochShuffling.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAS9C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"epochShuffling.d.ts","sourceRoot":"","sources":["../../src/util/epochShuffling.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAS9C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAM,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAMhD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,aAAa,EAAE,WAAW,CAAC;IAE3B;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC;IAEvB;;;;;;;OAOG;IACH,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC;IAE5B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAI1E;AA2BD,wBAAgB,qBAAqB,CAEnC,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,WAAW,EAC1B,KAAK,EAAE,KAAK,GACX,cAAc,CAWhB;AAED,wBAAsB,0BAA0B,CAE9C,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,WAAW,EAC1B,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,cAAc,CAAC,CAWzB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAGvF;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,KAAK,GACX,OAAO,CAIT"}
|
|
@@ -59,7 +59,7 @@ state, activeIndices, epoch) {
|
|
|
59
59
|
committeesPerSlot: committees[0].length,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
function calculateDecisionRoot(state, epoch) {
|
|
62
|
+
export function calculateDecisionRoot(state, epoch) {
|
|
63
63
|
const pivotSlot = computeStartSlotAtEpoch(epoch - 1) - 1;
|
|
64
64
|
return toRootHex(getBlockRootAtSlot(state, pivotSlot));
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochShuffling.js","sourceRoot":"","sources":["../../src/util/epochShuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,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AK,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAC/G,CAAC"}
|
package/lib/util/gloas.d.ts
CHANGED
|
@@ -1,10 +1,51 @@
|
|
|
1
|
-
import { gloas } from "@lodestar/types";
|
|
1
|
+
import { BuilderIndex, Epoch, ValidatorIndex, gloas } from "@lodestar/types";
|
|
2
2
|
import { AttestationData } from "@lodestar/types/phase0";
|
|
3
|
-
import { CachedBeaconStateGloas } from "../types.
|
|
4
|
-
import { RootCache } from "./rootCache.
|
|
5
|
-
export declare function
|
|
3
|
+
import { CachedBeaconStateGloas } from "../types.js";
|
|
4
|
+
import { RootCache } from "./rootCache.js";
|
|
5
|
+
export declare function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean;
|
|
6
6
|
export declare function getBuilderPaymentQuorumThreshold(state: CachedBeaconStateGloas): number;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Check if a validator index represents a builder (has the builder flag set).
|
|
9
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-is_builder_index
|
|
10
|
+
*/
|
|
11
|
+
export declare function isBuilderIndex(validatorIndex: number): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Convert a builder index to a flagged validator index for use in Withdrawal containers.
|
|
14
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-convert_builder_index_to_validator_index
|
|
15
|
+
*/
|
|
16
|
+
export declare function convertBuilderIndexToValidatorIndex(builderIndex: BuilderIndex): ValidatorIndex;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a flagged validator index back to a builder index.
|
|
19
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-convert_validator_index_to_builder_index
|
|
20
|
+
*/
|
|
21
|
+
export declare function convertValidatorIndexToBuilderIndex(validatorIndex: ValidatorIndex): BuilderIndex;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a builder is active (deposited and not yet withdrawable).
|
|
24
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#isactivebuilder
|
|
25
|
+
*/
|
|
26
|
+
export declare function isActiveBuilder(builder: gloas.Builder, finalizedEpoch: Epoch): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get the total pending balance to withdraw for a builder (from withdrawals + payments).
|
|
29
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-get_pending_balance_to_withdraw_for_builder
|
|
30
|
+
*/
|
|
31
|
+
export declare function getPendingBalanceToWithdrawForBuilder(state: CachedBeaconStateGloas, builderIndex: BuilderIndex): number;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a builder has sufficient balance to cover a bid amount.
|
|
34
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-can_builder_cover_bid
|
|
35
|
+
*/
|
|
36
|
+
export declare function canBuilderCoverBid(state: CachedBeaconStateGloas, builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Initiate a builder exit by setting their withdrawable epoch.
|
|
39
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-initiate_builder_exit
|
|
40
|
+
*/
|
|
41
|
+
export declare function initiateBuilderExit(state: CachedBeaconStateGloas, builderIndex: BuilderIndex): void;
|
|
42
|
+
/**
|
|
43
|
+
* Find the index of a builder by their public key.
|
|
44
|
+
* Returns null if not found.
|
|
45
|
+
*
|
|
46
|
+
* May consider builder pubkey cache if performance becomes an issue.
|
|
47
|
+
*/
|
|
48
|
+
export declare function findBuilderIndexByPubkey(state: CachedBeaconStateGloas, pubkey: Uint8Array): BuilderIndex | null;
|
|
8
49
|
export declare function isAttestationSameSlot(state: CachedBeaconStateGloas, data: AttestationData): boolean;
|
|
9
50
|
export declare function isAttestationSameSlotRootCache(rootCache: RootCache, data: AttestationData): boolean;
|
|
10
51
|
export declare function isParentBlockFull(state: CachedBeaconStateGloas): boolean;
|
package/lib/util/gloas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gloas.d.ts","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gloas.d.ts","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,6BAA6B,CAAC,qBAAqB,EAAE,UAAU,GAAG,OAAO,CAExF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAMtF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,YAAY,EAAE,YAAY,GAAG,cAAc,CAE9F;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,cAAc,EAAE,cAAc,GAAG,YAAY,CAEhG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,GAAG,OAAO,CAEtF;AAED;;;GAGG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,sBAAsB,EAC7B,YAAY,EAAE,YAAY,GACzB,MAAM,CAoBR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,sBAAsB,EAC7B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAWnG;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CAO/G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAOnG;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAOnG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAExE"}
|
package/lib/util/gloas.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { byteArrayEquals } from "@chainsafe/ssz";
|
|
2
|
-
import { BUILDER_PAYMENT_THRESHOLD_DENOMINATOR, BUILDER_PAYMENT_THRESHOLD_NUMERATOR, BUILDER_WITHDRAWAL_PREFIX, EFFECTIVE_BALANCE_INCREMENT, SLOTS_PER_EPOCH, } from "@lodestar/params";
|
|
2
|
+
import { BUILDER_INDEX_FLAG, BUILDER_PAYMENT_THRESHOLD_DENOMINATOR, BUILDER_PAYMENT_THRESHOLD_NUMERATOR, BUILDER_WITHDRAWAL_PREFIX, EFFECTIVE_BALANCE_INCREMENT, FAR_FUTURE_EPOCH, MIN_DEPOSIT_AMOUNT, SLOTS_PER_EPOCH, } from "@lodestar/params";
|
|
3
3
|
import { getBlockRootAtSlot } from "./blockRoot.js";
|
|
4
4
|
import { computeEpochAtSlot } from "./epoch.js";
|
|
5
|
-
export function
|
|
5
|
+
export function isBuilderWithdrawalCredential(withdrawalCredentials) {
|
|
6
6
|
return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
|
|
7
7
|
}
|
|
8
8
|
export function getBuilderPaymentQuorumThreshold(state) {
|
|
@@ -10,10 +10,96 @@ export function getBuilderPaymentQuorumThreshold(state) {
|
|
|
10
10
|
BUILDER_PAYMENT_THRESHOLD_NUMERATOR;
|
|
11
11
|
return Math.floor(quorum / BUILDER_PAYMENT_THRESHOLD_DENOMINATOR);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Check if a validator index represents a builder (has the builder flag set).
|
|
15
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-is_builder_index
|
|
16
|
+
*/
|
|
17
|
+
export function isBuilderIndex(validatorIndex) {
|
|
18
|
+
return (validatorIndex & BUILDER_INDEX_FLAG) !== 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Convert a builder index to a flagged validator index for use in Withdrawal containers.
|
|
22
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-convert_builder_index_to_validator_index
|
|
23
|
+
*/
|
|
24
|
+
export function convertBuilderIndexToValidatorIndex(builderIndex) {
|
|
25
|
+
return builderIndex | BUILDER_INDEX_FLAG;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a flagged validator index back to a builder index.
|
|
29
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-convert_validator_index_to_builder_index
|
|
30
|
+
*/
|
|
31
|
+
export function convertValidatorIndexToBuilderIndex(validatorIndex) {
|
|
32
|
+
return validatorIndex & ~BUILDER_INDEX_FLAG;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if a builder is active (deposited and not yet withdrawable).
|
|
36
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#isactivebuilder
|
|
37
|
+
*/
|
|
38
|
+
export function isActiveBuilder(builder, finalizedEpoch) {
|
|
39
|
+
return builder.depositEpoch < finalizedEpoch && builder.withdrawableEpoch === FAR_FUTURE_EPOCH;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the total pending balance to withdraw for a builder (from withdrawals + payments).
|
|
43
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-get_pending_balance_to_withdraw_for_builder
|
|
44
|
+
*/
|
|
45
|
+
export function getPendingBalanceToWithdrawForBuilder(state, builderIndex) {
|
|
46
|
+
let pendingBalance = 0;
|
|
47
|
+
// Sum pending withdrawals
|
|
48
|
+
for (let i = 0; i < state.builderPendingWithdrawals.length; i++) {
|
|
49
|
+
const withdrawal = state.builderPendingWithdrawals.getReadonly(i);
|
|
50
|
+
if (withdrawal.builderIndex === builderIndex) {
|
|
51
|
+
pendingBalance += withdrawal.amount;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Sum pending payments
|
|
55
|
+
for (let i = 0; i < state.builderPendingPayments.length; i++) {
|
|
56
|
+
const payment = state.builderPendingPayments.getReadonly(i);
|
|
57
|
+
if (payment.withdrawal.builderIndex === builderIndex) {
|
|
58
|
+
pendingBalance += payment.withdrawal.amount;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return pendingBalance;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a builder has sufficient balance to cover a bid amount.
|
|
65
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-can_builder_cover_bid
|
|
66
|
+
*/
|
|
67
|
+
export function canBuilderCoverBid(state, builderIndex, bidAmount) {
|
|
68
|
+
const builder = state.builders.getReadonly(builderIndex);
|
|
69
|
+
const pendingBalance = getPendingBalanceToWithdrawForBuilder(state, builderIndex);
|
|
70
|
+
const minBalance = MIN_DEPOSIT_AMOUNT + pendingBalance;
|
|
71
|
+
if (builder.balance < minBalance) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return builder.balance - minBalance >= bidAmount;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Initiate a builder exit by setting their withdrawable epoch.
|
|
78
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-initiate_builder_exit
|
|
79
|
+
*/
|
|
80
|
+
export function initiateBuilderExit(state, builderIndex) {
|
|
81
|
+
const builder = state.builders.get(builderIndex);
|
|
82
|
+
// Return if builder already initiated exit
|
|
83
|
+
if (builder.withdrawableEpoch !== FAR_FUTURE_EPOCH) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Set builder exit epoch
|
|
15
87
|
const currentEpoch = computeEpochAtSlot(state.slot);
|
|
16
|
-
|
|
88
|
+
builder.withdrawableEpoch = currentEpoch + state.config.MIN_BUILDER_WITHDRAWABILITY_DELAY;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Find the index of a builder by their public key.
|
|
92
|
+
* Returns null if not found.
|
|
93
|
+
*
|
|
94
|
+
* May consider builder pubkey cache if performance becomes an issue.
|
|
95
|
+
*/
|
|
96
|
+
export function findBuilderIndexByPubkey(state, pubkey) {
|
|
97
|
+
for (let i = 0; i < state.builders.length; i++) {
|
|
98
|
+
if (byteArrayEquals(state.builders.getReadonly(i).pubkey, pubkey)) {
|
|
99
|
+
return i;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
17
103
|
}
|
|
18
104
|
export function isAttestationSameSlot(state, data) {
|
|
19
105
|
if (data.slot === 0)
|