@lodestar/state-transition 1.39.1 → 1.40.0-dev.059f489b0f
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 +3 -4
- 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/processBlockHeader.d.ts.map +1 -1
- package/lib/block/processBlockHeader.js +1 -2
- package/lib/block/processBlockHeader.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 +8 -13
- 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 +5 -4
- 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/processExecutionPayload.d.ts.map +1 -1
- package/lib/block/processExecutionPayload.js +1 -2
- package/lib/block/processExecutionPayload.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadBid.js +17 -31
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +27 -27
- 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/processPayloadAttestation.d.ts.map +1 -1
- package/lib/block/processPayloadAttestation.js +1 -1
- package/lib/block/processPayloadAttestation.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 +6 -6
- 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 +122 -68
- 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/processPendingAttestations.d.ts.map +1 -1
- package/lib/epoch/processPendingAttestations.js +1 -1
- package/lib/epoch/processPendingAttestations.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/slot/index.d.ts.map +1 -1
- package/lib/slot/index.js +1 -1
- package/lib/slot/index.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 +92 -6
- 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/interop.js +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/loadState/findModifiedInactivityScores.d.ts +1 -1
- package/lib/util/loadState/findModifiedInactivityScores.d.ts.map +1 -1
- package/lib/util/loadState/findModifiedInactivityScores.js +3 -2
- package/lib/util/loadState/findModifiedInactivityScores.js.map +1 -1
- package/lib/util/loadState/findModifiedValidators.d.ts +2 -2
- package/lib/util/loadState/findModifiedValidators.d.ts.map +1 -1
- package/lib/util/loadState/findModifiedValidators.js +4 -3
- package/lib/util/loadState/findModifiedValidators.js.map +1 -1
- package/lib/util/loadState/loadValidator.d.ts.map +1 -1
- package/lib/util/loadState/loadValidator.js +3 -2
- package/lib/util/loadState/loadValidator.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 +8 -8
- 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 +3 -10
- package/src/block/processAttesterSlashing.ts +16 -4
- package/src/block/processBlockHeader.ts +1 -2
- package/src/block/processBlsToExecutionChange.ts +14 -16
- package/src/block/processConsolidationRequest.ts +5 -5
- package/src/block/processDepositRequest.ts +101 -8
- package/src/block/processExecutionPayload.ts +1 -2
- package/src/block/processExecutionPayloadBid.ts +21 -44
- package/src/block/processExecutionPayloadEnvelope.ts +35 -32
- package/src/block/processOperations.ts +2 -2
- package/src/block/processPayloadAttestation.ts +1 -1
- package/src/block/processProposerSlashing.ts +22 -12
- package/src/block/processSyncCommittee.ts +4 -7
- package/src/block/processVoluntaryExit.ts +60 -5
- package/src/block/processWithdrawalRequest.ts +1 -1
- package/src/block/processWithdrawals.ts +169 -72
- 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/processPendingAttestations.ts +1 -1
- 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/slot/index.ts +1 -1
- 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 +117 -11
- package/src/util/index.ts +2 -2
- package/src/util/interop.ts +1 -1
- package/src/util/loadState/findModifiedInactivityScores.ts +4 -2
- package/src/util/loadState/findModifiedValidators.ts +4 -3
- package/src/util/loadState/loadValidator.ts +3 -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
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":"AAUA,OAAO,EAAC,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD,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,gC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T_THRESHOLD_DENOMINATOR, BUILDER_PAYMENT_THRESHOLD_NUMERATOR, BUILDER_WITHDRAWAL_PREFIX, EFFECTIVE_BALANCE_INCREMENT, FAR_FUTURE_EPOCH, MIN_DEPOSIT_AMOUNT, SLOTS_PER_EPOCH, } from "@lodestar/params";
|
|
2
|
+
import { byteArrayEquals } from "@lodestar/utils";
|
|
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)
|
package/lib/util/gloas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gloas.js","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"gloas.js","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qCAAqC,EACrC,mCAAmC,EACnC,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAG9C,MAAM,UAAU,6BAA6B,CAAC,qBAAiC;IAC7E,OAAO,qBAAqB,CAAC,CAAC,CAAC,KAAK,yBAAyB,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,KAA6B;IAC5E,MAAM,MAAM,GACV,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,4BAA4B,GAAG,2BAA2B,CAAC,GAAG,eAAe,CAAC;QACzG,mCAAmC,CAAC;IAEtC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,qCAAqC,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,cAAsB;IACnD,OAAO,CAAC,cAAc,GAAG,kBAAkB,CAAC,KAAK,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;AACd,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAA6B,EAAE,IAAqB;IACxF,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,mBAAmB,GAAG,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxG,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IAE5G,OAAO,mBAAmB,IAAI,kBAAkB,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,SAAoB,EAAE,IAAqB;IACxF,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,mBAAmB,GAAG,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3G,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IAE/G,OAAO,mBAAmB,IAAI,kBAAkB,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,OAAO,eAAe,CAAC,KAAK,CAAC,yBAAyB,CAAC,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;AAC3F,CAAC"}
|
package/lib/util/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from "./attesterStatus.js";
|
|
|
5
5
|
export * from "./balance.js";
|
|
6
6
|
export * from "./blindedBlock.js";
|
|
7
7
|
export * from "./blockRoot.js";
|
|
8
|
-
export * from "./calculateCommitteeAssignments.js";
|
|
9
8
|
export * from "./capella.js";
|
|
10
9
|
export * from "./computeAnchorCheckpoint.js";
|
|
11
10
|
export * from "./deposit.js";
|
|
@@ -16,11 +15,12 @@ export * from "./epochShuffling.js";
|
|
|
16
15
|
export * from "./execution.js";
|
|
17
16
|
export * from "./finality.js";
|
|
18
17
|
export * from "./genesis.js";
|
|
18
|
+
export * from "./gloas.js";
|
|
19
19
|
export * from "./interop.js";
|
|
20
20
|
export * from "./loadState/index.js";
|
|
21
21
|
export * from "./rootCache.js";
|
|
22
22
|
export * from "./seed.js";
|
|
23
|
-
export * from "./
|
|
23
|
+
export * from "./shuffling.js";
|
|
24
24
|
export * from "./signatureSets.js";
|
|
25
25
|
export * from "./signingRoot.js";
|
|
26
26
|
export * from "./slot.js";
|
package/lib/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
package/lib/util/index.js
CHANGED
|
@@ -5,7 +5,6 @@ export * from "./attesterStatus.js";
|
|
|
5
5
|
export * from "./balance.js";
|
|
6
6
|
export * from "./blindedBlock.js";
|
|
7
7
|
export * from "./blockRoot.js";
|
|
8
|
-
export * from "./calculateCommitteeAssignments.js";
|
|
9
8
|
export * from "./capella.js";
|
|
10
9
|
export * from "./computeAnchorCheckpoint.js";
|
|
11
10
|
export * from "./deposit.js";
|
|
@@ -16,11 +15,12 @@ export * from "./epochShuffling.js";
|
|
|
16
15
|
export * from "./execution.js";
|
|
17
16
|
export * from "./finality.js";
|
|
18
17
|
export * from "./genesis.js";
|
|
18
|
+
export * from "./gloas.js";
|
|
19
19
|
export * from "./interop.js";
|
|
20
20
|
export * from "./loadState/index.js";
|
|
21
21
|
export * from "./rootCache.js";
|
|
22
22
|
export * from "./seed.js";
|
|
23
|
-
export * from "./
|
|
23
|
+
export * from "./shuffling.js";
|
|
24
24
|
export * from "./signatureSets.js";
|
|
25
25
|
export * from "./signingRoot.js";
|
|
26
26
|
export * from "./slot.js";
|
package/lib/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
package/lib/util/interop.js
CHANGED
package/lib/util/interop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interop.js","sourceRoot":"","sources":["../../src/util/interop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"interop.js","sourceRoot":"","sources":["../../src/util/interop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE1D,IAAI,UAAkB,CAAC;AACvB,SAAS,aAAa;IACpB,IAAI,CAAC,UAAU;QAAE,UAAU,GAAG,MAAM,CAAC,+EAA+E,CAAC,CAAC;IACtH,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAAsB;IACtD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,cAAc,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACnD,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;IACpC,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,EAAE,CAAC,CAAC;IAClG,OAAO,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const INACTIVITY_SCORE_SIZE = 8;
|
|
2
2
|
/**
|
|
3
3
|
* As monitored on mainnet, inactivityScores are not changed much and they are mostly 0
|
|
4
|
-
* Using
|
|
4
|
+
* Using byteArrayEquals is the optimal way as noted in `./findModifiedValidators.ts`
|
|
5
5
|
* @returns output parameter modifiedValidators: validator indices that are modified
|
|
6
6
|
*/
|
|
7
7
|
export declare function findModifiedInactivityScores(inactivityScoresBytes: Uint8Array, inactivityScoresBytes2: Uint8Array, modifiedValidators: number[], validatorOffset?: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findModifiedInactivityScores.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedInactivityScores.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findModifiedInactivityScores.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedInactivityScores.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,qBAAqB,EAAE,UAAU,EACjC,sBAAsB,EAAE,UAAU,EAClC,kBAAkB,EAAE,MAAM,EAAE,EAC5B,eAAe,SAAI,GAClB,IAAI,CAiCN"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { byteArrayEquals } from "@lodestar/utils";
|
|
1
2
|
// UintNum64 = 8 bytes
|
|
2
3
|
export const INACTIVITY_SCORE_SIZE = 8;
|
|
3
4
|
/**
|
|
4
5
|
* As monitored on mainnet, inactivityScores are not changed much and they are mostly 0
|
|
5
|
-
* Using
|
|
6
|
+
* Using byteArrayEquals is the optimal way as noted in `./findModifiedValidators.ts`
|
|
6
7
|
* @returns output parameter modifiedValidators: validator indices that are modified
|
|
7
8
|
*/
|
|
8
9
|
export function findModifiedInactivityScores(inactivityScoresBytes, inactivityScoresBytes2, modifiedValidators, validatorOffset = 0) {
|
|
@@ -12,7 +13,7 @@ export function findModifiedInactivityScores(inactivityScoresBytes, inactivitySc
|
|
|
12
13
|
" vs " +
|
|
13
14
|
inactivityScoresBytes2.length);
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (byteArrayEquals(inactivityScoresBytes, inactivityScoresBytes2)) {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
if (inactivityScoresBytes.length === INACTIVITY_SCORE_SIZE) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findModifiedInactivityScores.js","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedInactivityScores.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,qBAAiC,EACjC,sBAAkC,EAClC,kBAA4B,EAC5B,eAAe,GAAG,CAAC;IAEnB,IAAI,qBAAqB,CAAC,MAAM,KAAK,sBAAsB,CAAC,MAAM,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,qBAAqB,CAAC,MAAM;YAC5B,MAAM;YACN,sBAAsB,CAAC,MAAM,CAChC,CAAC;IACJ,CAAC;IAED,IAAI,
|
|
1
|
+
{"version":3,"file":"findModifiedInactivityScores.js","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedInactivityScores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,sBAAsB;AACtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,qBAAiC,EACjC,sBAAkC,EAClC,kBAA4B,EAC5B,eAAe,GAAG,CAAC;IAEnB,IAAI,qBAAqB,CAAC,MAAM,KAAK,sBAAsB,CAAC,MAAM,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,iEAAiE;YAC/D,qBAAqB,CAAC,MAAM;YAC5B,MAAM;YACN,sBAAsB,CAAC,MAAM,CAChC,CAAC;IACJ,CAAC;IAED,IAAI,eAAe,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IAED,IAAI,qBAAqB,CAAC,MAAM,KAAK,qBAAqB,EAAE,CAAC;QAC3D,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,GAAG,qBAAqB,CAAC,CAAC;IACtF,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IACnD,4BAA4B,CAC1B,qBAAqB,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,qBAAqB,CAAC,EACxE,sBAAsB,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,qBAAqB,CAAC,EACzE,kBAAkB,EAClB,eAAe,CAChB,CAAC;IACF,4BAA4B,CAC1B,qBAAqB,CAAC,QAAQ,CAAC,aAAa,GAAG,qBAAqB,CAAC,EACrE,sBAAsB,CAAC,QAAQ,CAAC,aAAa,GAAG,qBAAqB,CAAC,EACtE,kBAAkB,EAClB,eAAe,GAAG,aAAa,CAChC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Find modified validators by comparing two validators bytes using
|
|
2
|
+
* Find modified validators by comparing two validators bytes using byteArrayEquals() recursively
|
|
3
3
|
* - As noted in packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts, serializing validators and compare Uint8Array is the fastest way
|
|
4
4
|
* - The performance is quite stable and can afford a lot of difference in validators (the benchmark tested up to 10k but it's not likely we have that difference in mainnet)
|
|
5
|
-
* -
|
|
5
|
+
* - byteArrayEquals() uses the optimal comparison method based on array size
|
|
6
6
|
*
|
|
7
7
|
* @returns output parameter modifiedValidators: validator indices that are modified
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findModifiedValidators.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedValidators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findModifiedValidators.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedValidators.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,UAAU,EAC3B,gBAAgB,EAAE,UAAU,EAC5B,kBAAkB,EAAE,MAAM,EAAE,EAC5B,eAAe,SAAI,GAClB,IAAI,CA8BN"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { byteArrayEquals } from "@lodestar/utils";
|
|
1
2
|
import { VALIDATOR_BYTES_SIZE } from "../sszBytes.js";
|
|
2
3
|
/**
|
|
3
|
-
* Find modified validators by comparing two validators bytes using
|
|
4
|
+
* Find modified validators by comparing two validators bytes using byteArrayEquals() recursively
|
|
4
5
|
* - As noted in packages/state-transition/test/perf/util/loadState/findModifiedValidators.test.ts, serializing validators and compare Uint8Array is the fastest way
|
|
5
6
|
* - The performance is quite stable and can afford a lot of difference in validators (the benchmark tested up to 10k but it's not likely we have that difference in mainnet)
|
|
6
|
-
* -
|
|
7
|
+
* - byteArrayEquals() uses the optimal comparison method based on array size
|
|
7
8
|
*
|
|
8
9
|
* @returns output parameter modifiedValidators: validator indices that are modified
|
|
9
10
|
*/
|
|
@@ -11,7 +12,7 @@ export function findModifiedValidators(validatorsBytes, validatorsBytes2, modifi
|
|
|
11
12
|
if (validatorsBytes.length !== validatorsBytes2.length) {
|
|
12
13
|
throw new Error("validatorsBytes.length !== validatorsBytes2.length " + validatorsBytes.length + " vs " + validatorsBytes2.length);
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
15
|
+
if (byteArrayEquals(validatorsBytes, validatorsBytes2)) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
if (validatorsBytes.length === VALIDATOR_BYTES_SIZE) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findModifiedValidators.js","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAA2B,EAC3B,gBAA4B,EAC5B,kBAA4B,EAC5B,eAAe,GAAG,CAAC;IAEnB,IAAI,eAAe,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CACb,qDAAqD,GAAG,eAAe,CAAC,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAClH,CAAC;IACJ,CAAC;IAED,IAAI,
|
|
1
|
+
{"version":3,"file":"findModifiedValidators.js","sourceRoot":"","sources":["../../../src/util/loadState/findModifiedValidators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAA2B,EAC3B,gBAA4B,EAC5B,kBAA4B,EAC5B,eAAe,GAAG,CAAC;IAEnB,IAAI,eAAe,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CACb,qDAAqD,GAAG,eAAe,CAAC,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAClH,CAAC;IACJ,CAAC;IAED,IAAI,eAAe,CAAC,eAAe,EAAE,gBAAgB,CAAC,EAAE,CAAC;QACvD,OAAO;IACT,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;QACpD,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACzC,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAC;IAC/E,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IACnD,sBAAsB,CACpB,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,oBAAoB,CAAC,EACjE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,oBAAoB,CAAC,EAClE,kBAAkB,EAClB,eAAe,CAChB,CAAC;IACF,sBAAsB,CACpB,eAAe,CAAC,QAAQ,CAAC,aAAa,GAAG,oBAAoB,CAAC,EAC9D,gBAAgB,CAAC,QAAQ,CAAC,aAAa,GAAG,oBAAoB,CAAC,EAC/D,kBAAkB,EAClB,eAAe,GAAG,aAAa,CAChC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadValidator.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/loadValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAoC,GAAG,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadValidator.d.ts","sourceRoot":"","sources":["../../../src/util/loadState/loadValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAoC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAItF;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,eAAe,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAC3D,iBAAiB,EAAE,UAAU,GAC5B,eAAe,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAU9C;AAuBD;;GAEG;AACH,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,cAAc,EAAE,GACjC,MAAM,EAAE,CAuBV"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deserializeContainerIgnoreFields, ssz } from "@lodestar/types";
|
|
2
|
+
import { byteArrayEquals } from "@lodestar/utils";
|
|
2
3
|
import { getStateTypeFromBytes } from "../sszBytes.js";
|
|
3
4
|
/**
|
|
4
5
|
* Load validator from bytes given a seed validator.
|
|
@@ -22,11 +23,11 @@ export function loadValidator(seedValidator, newValidatorBytes) {
|
|
|
22
23
|
function getSameFields(validator, validatorBytes) {
|
|
23
24
|
const ignoredFields = [];
|
|
24
25
|
const pubkey = validatorBytes.subarray(0, 48);
|
|
25
|
-
if (
|
|
26
|
+
if (byteArrayEquals(pubkey, validator.pubkey)) {
|
|
26
27
|
ignoredFields.push("pubkey");
|
|
27
28
|
}
|
|
28
29
|
const withdrawalCredentials = validatorBytes.subarray(48, 80);
|
|
29
|
-
if (
|
|
30
|
+
if (byteArrayEquals(withdrawalCredentials, validator.withdrawalCredentials)) {
|
|
30
31
|
ignoredFields.push("withdrawalCredentials");
|
|
31
32
|
}
|
|
32
33
|
return ignoredFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadValidator.js","sourceRoot":"","sources":["../../../src/util/loadState/loadValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,gCAAgC,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAC,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,aAA2D,EAC3D,iBAA6B;IAE7B,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IACtE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,iBAAiB,GAAG,gCAAgC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;QACnH,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,iBAAiB,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,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AG,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACxF,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,SAAmB,CAAC;IAE/D,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE,CAAC;QACrC,MAAM,cAAc,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,GAAG,aAAa,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;QACpG,IAAI,cAAc,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,KAAK,CAAC,mBAAmB,KAAK,eAAe,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACnE,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ForkName, ForkSeq } from "@lodestar/params";
|
|
2
|
+
import { Attestation, CommitteeIndex, Epoch, IndexedAttestation, Root, Slot, ValidatorIndex } from "@lodestar/types";
|
|
3
|
+
import { LodestarError } from "@lodestar/utils";
|
|
4
|
+
import { CachedBeaconStateAllForks } from "../cache/stateCache.js";
|
|
5
|
+
import { EpochShuffling } from "./epochShuffling.js";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the block root which decided the proposer shuffling for the current epoch. This root
|
|
8
|
+
* can be used to key this proposer shuffling.
|
|
9
|
+
*
|
|
10
|
+
* Returns `null` on the one-off scenario where the genesis block decides its own shuffling.
|
|
11
|
+
* It should be set to the latest block applied to this `state` or the genesis block root.
|
|
12
|
+
*/
|
|
13
|
+
export declare function proposerShufflingDecisionRoot(fork: ForkName, state: CachedBeaconStateAllForks): Root | null;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the block root which decided the attester shuffling for the given `requestedEpoch`.
|
|
16
|
+
* This root can be used to key that attester shuffling.
|
|
17
|
+
*
|
|
18
|
+
* Returns `null` on the one-off scenario where the genesis block decides its own shuffling.
|
|
19
|
+
* It should be set to the latest block applied to this `state` or the genesis block root.
|
|
20
|
+
*/
|
|
21
|
+
export declare function attesterShufflingDecisionRoot(state: CachedBeaconStateAllForks, requestedEpoch: Epoch): Root | null;
|
|
22
|
+
export interface AttesterDuty {
|
|
23
|
+
validatorIndex: ValidatorIndex;
|
|
24
|
+
committeeIndex: CommitteeIndex;
|
|
25
|
+
committeeLength: number;
|
|
26
|
+
committeesAtSlot: number;
|
|
27
|
+
validatorCommitteeIndex: number;
|
|
28
|
+
slot: Slot;
|
|
29
|
+
}
|
|
30
|
+
export declare function calculateCommitteeAssignments(epochShuffling: EpochShuffling, requestedValidatorIndices: ValidatorIndex[]): Map<ValidatorIndex, AttesterDuty>;
|
|
31
|
+
/**
|
|
32
|
+
* Return the indexed attestation corresponding to ``attestation``.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getIndexedAttestation(epochShuffling: EpochShuffling, fork: ForkSeq, attestation: Attestation): IndexedAttestation;
|
|
35
|
+
/**
|
|
36
|
+
* Return indices of validators who attestested in `attestation`
|
|
37
|
+
*/
|
|
38
|
+
export declare function getAttestingIndices(epochShuffling: EpochShuffling, fork: ForkSeq, attestation: Attestation): number[];
|
|
39
|
+
/**
|
|
40
|
+
* Return the beacon committee at slot for index.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getBeaconCommittee(epochShuffling: EpochShuffling, slot: Slot, index: CommitteeIndex): Uint32Array;
|
|
43
|
+
/**
|
|
44
|
+
* Return a Uint32Array[] representing committees validator indices
|
|
45
|
+
*/
|
|
46
|
+
export declare function getBeaconCommittees(epochShuffling: EpochShuffling, slot: Slot, indices: CommitteeIndex[]): Uint32Array[];
|
|
47
|
+
export declare enum ShufflingErrorCode {
|
|
48
|
+
COMMITTEE_INDEX_OUT_OF_RANGE = "SHUFFLING_ERROR_COMMITTEE_INDEX_OUT_OF_RANGE"
|
|
49
|
+
}
|
|
50
|
+
type ShufflingErrorType = {
|
|
51
|
+
code: ShufflingErrorCode.COMMITTEE_INDEX_OUT_OF_RANGE;
|
|
52
|
+
index: number;
|
|
53
|
+
maxIndex: number;
|
|
54
|
+
};
|
|
55
|
+
export declare class ShufflingError extends LodestarError<ShufflingErrorType> {
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=shuffling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,yBAAyB,GAAG,IAAI,GAAG,IAAI,CAM3G;AAaD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAMlH;AAsCD,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,C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