Skip to content

Commit

Permalink
Cast block in processSyncCommittee spec test
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jun 3, 2021
1 parent e83cd27 commit 4951a92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-state-transition/src/altair/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export function processBlock(
processRandao(state as CachedBeaconState<allForks.BeaconState>, block, verifySignatures);
processEth1Data(state as CachedBeaconState<allForks.BeaconState>, block.body);
processOperations(state, block.body, verifySignatures);
processSyncCommittee(state, block.body.syncAggregate, verifySignatures);
processSyncCommittee(state, block, verifySignatures);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ import {BitList, isTreeBacked, TreeBacked} from "@chainsafe/ssz";

export function processSyncCommittee(
state: CachedBeaconState<altair.BeaconState>,
syncAggregate: altair.SyncAggregate,
block: altair.BeaconBlock,
verifySignatures = true
): void {
const {syncParticipantReward, syncProposerReward} = state.epochCtx;
const participantIndices = getParticipantIndices(state, syncAggregate);
const participantIndices = getParticipantIndices(state, block.body.syncAggregate);

// different from the spec but not sure how to get through signature verification for default/empty SyncAggregate in the spec test
if (verifySignatures) {
// This is to conform to the spec - we want the signature to be verified
const block = {slot: state.slot, body: {syncAggregate}} as altair.BeaconBlock;
const signatureSet = getSyncCommitteeSignatureSet(state, block, participantIndices);
// When there's no participation we consider the signature valid and just ignore i
if (signatureSet !== null && !verifySignatureSet(signatureSet)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ describeDirectorySpecTest<IProcessSyncCommitteeTestCase, altair.BeaconState>(
config,
testcase.pre as TreeBacked<altair.BeaconState>
) as CachedBeaconState<altair.BeaconState>;
altair.processSyncCommittee(
wrappedState,
config.types.altair.SyncAggregate.createTreeBackedFromStruct(testcase["sync_aggregate"])
);

const block = config.types.altair.BeaconBlock.defaultValue();

// processSyncCommittee() needs the full block to get the slot
block.slot = wrappedState.slot;
block.body.syncAggregate = config.types.altair.SyncAggregate.createTreeBackedFromStruct(testcase["sync_aggregate"]);

altair.processSyncCommittee(wrappedState, block);
return wrappedState;
},
{
Expand Down

0 comments on commit 4951a92

Please sign in to comment.