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

chore: review devnet-5 branch #7365

Merged
merged 6 commits into from
Jan 15, 2025
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/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export function deserializeExecutionRequests(serialized: ExecutionRequestsRpc):
prefixedRequests = prefixedRequests.slice(2);
}

const currentRequestType = Number(prefixedRequests.substring(0, 2));
const currentRequestType = parseInt(prefixedRequests.substring(0, 2), 16);

if (!isExecutionRequestType(currentRequestType)) {
throw Error(`Invalid request type currentRequestType=${prefixedRequests.substring(0, 2)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ function getBatchHandlers(modules: ValidatorFnsModules, options: GossipHandlerOp
// Node may be subscribe to extra subnets (long-lived random subnets). For those, validate the messages
// but don't add to attestation pool, to save CPU and RAM
if (aggregatorTracker.shouldAggregate(subnet, indexedAttestation.data.slot)) {
// TODO: modify after we change attestationPool due to SingleAttestation
const insertOutcome = chain.attestationPool.add(
committeeIndex,
attestation,
Expand Down
24 changes: 13 additions & 11 deletions packages/beacon-node/src/util/sszBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ export function getAttDataFromAttestationSerialized(data: Uint8Array): AttDataBa
* This is used for GossipQueue.
*/
export function getBeaconAttestationGossipIndex(fork: ForkName, data: Uint8Array): AttDataBase64 | null {
const forkSeq = ForkSeq[fork];
return forkSeq >= ForkSeq.electra
return ForkSeq[fork] >= ForkSeq.electra
? getAttDataFromSingleAttestationSerialized(data)
: getAttDataFromAttestationSerialized(data);
}
Expand All @@ -120,8 +119,7 @@ export function getBeaconAttestationGossipIndex(fork: ForkName, data: Uint8Array
* Extract slot from `beacon_attestation` gossip message serialized bytes.
*/
export function getSlotFromBeaconAttestationSerialized(fork: ForkName, data: Uint8Array): Slot | null {
const forkSeq = ForkSeq[fork];
return forkSeq >= ForkSeq.electra
return ForkSeq[fork] >= ForkSeq.electra
? getSlotFromSingleAttestationSerialized(data)
: getSlotFromAttestationSerialized(data);
}
Expand All @@ -130,8 +128,7 @@ export function getSlotFromBeaconAttestationSerialized(fork: ForkName, data: Uin
* Extract block root from `beacon_attestation` gossip message serialized bytes.
*/
export function getBlockRootFromBeaconAttestationSerialized(fork: ForkName, data: Uint8Array): BlockRootHex | null {
const forkSeq = ForkSeq[fork];
return forkSeq >= ForkSeq.electra
return ForkSeq[fork] >= ForkSeq.electra
? getBlockRootFromSingleAttestationSerialized(data)
: getBlockRootFromAttestationSerialized(data);
}
Expand Down Expand Up @@ -181,7 +178,6 @@ export function getSlotFromSingleAttestationSerialized(data: Uint8Array): Slot |
/**
* Extract committee index from SingleAttestation serialized bytes.
* Return null if data is not long enough to extract slot.
* TODO Electra: Rename getSlotFromOffset to reflect generic usage
*/
export function getCommitteeIndexFromSingleAttestationSerialized(
fork: ForkName,
Expand All @@ -192,27 +188,26 @@ export function getCommitteeIndexFromSingleAttestationSerialized(
return null;
}

return getSlotFromOffset(data, SINGLE_ATTESTATION_COMMITTEE_INDEX_OFFSET);
return getIndexFromOffset(data, SINGLE_ATTESTATION_COMMITTEE_INDEX_OFFSET);
}

if (data.length < VARIABLE_FIELD_OFFSET + SLOT_SIZE + COMMITTEE_INDEX_SIZE) {
return null;
}

return getSlotFromOffset(data, VARIABLE_FIELD_OFFSET + SLOT_SIZE);
return getIndexFromOffset(data, VARIABLE_FIELD_OFFSET + SLOT_SIZE);
}

/**
* Extract attester index from SingleAttestation serialized bytes.
* Return null if data is not long enough to extract index.
* TODO Electra: Rename getSlotFromOffset to reflect generic usage
*/
export function getAttesterIndexFromSingleAttestationSerialized(data: Uint8Array): ValidatorIndex | null {
if (data.length !== SINGLE_ATTESTATION_SIZE) {
return null;
}

return getSlotFromOffset(data, SINGLE_ATTESTATION_ATTESTER_INDEX_OFFSET);
return getIndexFromOffset(data, SINGLE_ATTESTATION_ATTESTER_INDEX_OFFSET);
}

/**
Expand Down Expand Up @@ -409,6 +404,13 @@ function getSlotFromOffset(data: Uint8Array, offset: number): Slot | null {
return checkSlotHighBytes(data, offset) ? getSlotFromOffsetTrusted(data, offset) : null;
}

/**
* Alias of `getSlotFromOffset` for readability
*/
function getIndexFromOffset(data: Uint8Array, offset: number): (ValidatorIndex | CommitteeIndex) | null {
return getSlotFromOffset(data, offset);
}

/**
* Read only the first 4 bytes of Slot, max value is 4,294,967,295 will be reached 1634 years after genesis
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const generateLighthouseBeaconNode: BeaconNodeGenerator<BeaconClient.Ligh
const cliParams: Record<string, unknown> = {
"testnet-dir": rootDirMounted,
datadir: rootDirMounted,
// Enable the RESTful HTTP API server. Disabled by default.
http: null,
"http-address": "0.0.0.0",
"http-port": ports.beacon.httpPort,
Expand Down
Loading