Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.2: Minor refactor of AggregateAndProof #597

Merged
merged 1 commit into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eth2.0-params/src/presets/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const MIN_PER_EPOCH_CHURN_LIMIT = 2 ** 2; // 4
export const CHURN_LIMIT_QUOTIENT = 2 ** 16; // 65536
export const BASE_REWARDS_PER_EPOCH = 4;
export const SHUFFLE_ROUND_COUNT = 90;
export const MIN_GENESIS_ACTIVE_VALIDATOR_COUNT = 2 ** 16;
export const MIN_GENESIS_ACTIVE_VALIDATOR_COUNT = 2 ** 14;
export const MIN_GENESIS_TIME = 1578009600;

// Deposit contract
Expand Down
4 changes: 2 additions & 2 deletions packages/eth2.0-types/src/ssz/generators/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const SyncingStatus = (ssz: IBeaconSSZTypes): SimpleContainerType => ({

export const AggregateAndProof = (ssz: IBeaconSSZTypes): SimpleContainerType => ({
fields: [
["index", ssz.ValidatorIndex],
["selectionProof", ssz.BLSSignature],
["aggregatorIndex", ssz.ValidatorIndex],
["aggregate", ssz.Attestation],
["selectionProof", ssz.BLSSignature],
],
});
4 changes: 2 additions & 2 deletions packages/eth2.0-types/src/types/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface CommitteeAssignment {
}

export interface AggregateAndProof {
index: ValidatorIndex;
selectionProof: BLSSignature;
aggregatorIndex: ValidatorIndex;
aggregate: Attestation;
selectionProof: BLSSignature;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getIncomingAggregateAndProofHandler(validator: IGossipMessageVal
try {
const aggregateAndProof = deserializeGossipMessage<AggregateAndProof>(msg, this.config.types.AggregateAndProof);
this.logger.verbose(
`Received AggregateAndProof from validator #${aggregateAndProof.index}`+
`Received AggregateAndProof from validator #${aggregateAndProof.aggregatorIndex}`+
` for target ${toHex(aggregateAndProof.aggregate.data.target.root)}`
);
if (await validator.isValidIncomingAggregateAndProof(aggregateAndProof)) {
Expand All @@ -40,7 +40,7 @@ export async function publishAggregatedAttestation(this: Gossip, aggregateAndPro
)
]);
this.logger.verbose(
`Publishing AggregateAndProof for validator #${aggregateAndProof.index}`
`Publishing AggregateAndProof for validator #${aggregateAndProof.aggregatorIndex}`
+ ` for target ${toHex(aggregateAndProof.aggregate.data.target.root)}`
);
}
6 changes: 3 additions & 3 deletions packages/lodestar/src/network/gossip/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ export class GossipMessageValidator implements IGossipMessageValidator {
}
const attestorIndices = getAttestingIndices(this.config, state,
aggregationAndProof.aggregate.data, aggregationAndProof.aggregate.aggregationBits);
if (!attestorIndices.includes(aggregationAndProof.index)) {
if (!attestorIndices.includes(aggregationAndProof.aggregatorIndex)) {
return false;
}
if (!isAggregator(this.config, state, slot, aggregationAndProof.index, aggregationAndProof.selectionProof)) {
if (!isAggregator(this.config, state, slot, aggregationAndProof.aggregatorIndex, aggregationAndProof.selectionProof)) {
return false;
}
const validatorPubKey = state.validators[aggregationAndProof.index].pubkey;
const validatorPubKey = state.validators[aggregationAndProof.aggregatorIndex].pubkey;
const domain = getDomain(this.config, state, DomainType.BEACON_ATTESTER, computeEpochAtSlot(this.config, slot));
if (!verify(validatorPubKey,
hashTreeRoot(this.config.types.Slot, slot),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("gossip handlers - aggregate and proof", function () {

it("handle valid message", async function () {
const aggregate: AggregateAndProof = {
index: 0,
aggregatorIndex: 0,
selectionProof: Buffer.alloc(0),
aggregate: generateEmptyAttestation()
};
Expand Down
2 changes: 1 addition & 1 deletion packages/lodestar/test/utils/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function generateEmptyAttestation(): Attestation {
export function generateEmptyAggregateAndProof(): AggregateAndProof {
const attestation = generateEmptyAttestation();
return {
index: 0,
aggregatorIndex: 0,
selectionProof: Buffer.alloc(96),
aggregate: attestation,
}
Expand Down