Skip to content

Commit

Permalink
Merge 737d0cd into c337f0e
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion authored Dec 19, 2022
2 parents c337f0e + 737d0cd commit 413c849
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,11 @@ export class BeaconChain implements IBeaconChain {
return await this.db.block.get(fromHexString(block.blockRoot));
}

async produceBlock(blockAttributes: BlockAttributes): Promise<allForks.BeaconBlock> {
produceBlock(blockAttributes: BlockAttributes): Promise<allForks.BeaconBlock> {
return this.produceBlockWrapper<BlockType.Full>(BlockType.Full, blockAttributes);
}

async produceBlindedBlock(blockAttributes: BlockAttributes): Promise<allForks.BlindedBeaconBlock> {
produceBlindedBlock(blockAttributes: BlockAttributes): Promise<allForks.BlindedBeaconBlock> {
return this.produceBlockWrapper<BlockType.Blinded>(BlockType.Blinded, blockAttributes);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/clock/LocalClock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {IBeaconClock} from "./interface.js";
export class LocalClock implements IBeaconClock {
private readonly config: IChainForkConfig;
private readonly genesisTime: number;
private timeoutId: NodeJS.Timeout;
private timeoutId: number | NodeJS.Timeout;
private readonly emitter: ChainEventEmitter;
private readonly signal: AbortSignal;
private _currentSlot: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type BlockProcessOpts = {
* will still issue fcU for block proposal
*/
disableImportExecutionFcU?: boolean;
/** For EIP4844 */
// TODO EIP-4844: to test without capella
disabledWithdrawals?: boolean;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ export async function produceBlockBody<T extends BlockType>(
// are pre-merge. We don't care the same for builder segment as the execution block
// will takeover if the builder flow was activated and errors
try {
// https://github.com/ethereum/consensus-specs/blob/dev/specs/eip4844/validator.md#constructing-the-beaconblockbody
const prepareRes = await prepareExecutionPayload(
this,
fork,
safeBlockHash,
finalizedBlockHash ?? ZERO_HASH_HEX,
currentState as CachedBeaconStateBellatrix,
currentState as CachedBeaconStateExecutions,
feeRecipient
);

if (prepareRes.isPremerge) {
(blockBody as allForks.ExecutionBlockBody).executionPayload = ssz.allForksExecution[
fork
Expand All @@ -208,6 +210,7 @@ export async function produceBlockBody<T extends BlockType>(
// See: https://discord.com/channels/595666850260713488/892088344438255616/1009882079632314469
await sleep(PAYLOAD_GENERATION_TIME_MS);
}

const payload = await this.executionEngine.getPayload(fork, payloadId);
(blockBody as allForks.ExecutionBlockBody).executionPayload = payload;

Expand Down
10 changes: 5 additions & 5 deletions packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {ChainEvent, IBeaconChain, IBeaconClock} from "../chain/index.js";
import {BlockInput, BlockInputType, getBlockInput} from "../chain/blocks/types.js";
import {INetworkOptions} from "./options.js";
import {INetwork} from "./interface.js";
import {ReqRespBeaconNode, ReqRespHandlers} from "./reqresp/ReqRespBeaconNode.js";
import {ReqRespBeaconNode, ReqRespHandlers} from "./reqresp/index.js";
import {Eth2Gossipsub, getGossipHandlers, GossipHandlers, GossipTopicTypeMap, GossipType} from "./gossip/index.js";
import {MetadataController} from "./metadata.js";
import {FORK_EPOCH_LOOKAHEAD, getActiveForks} from "./forks.js";
Expand Down Expand Up @@ -219,7 +219,7 @@ export class Network implements INetwork {
});

case BlockInputType.postEIP4844OldBlobs:
throw Error(`Attempting to broadcast old BlockImport slot ${blockInput.block.message.slot}`);
throw Error(`Attempting to broadcast old BlockInput slot ${blockInput.block.message.slot}`);
}
}

Expand Down Expand Up @@ -247,7 +247,7 @@ export class Network implements INetwork {
throw Error(`blocks.length ${blocks.length} != blobsSidecars.length ${blobsSidecars.length}`);
}

const blockInput: BlockInput[] = [];
const blockInputs: BlockInput[] = [];
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i];
const blobsSidecar = blobsSidecars[i];
Expand All @@ -257,9 +257,9 @@ export class Network implements INetwork {
throw Error(`blob does not match block slot ${block.message.slot} != ${blobsSidecar.beaconBlockSlot}`);
}

blockInput.push(getBlockInput.postEIP4844(this.config, block, blobsSidecar));
blockInputs.push(getBlockInput.postEIP4844(this.config, block, blobsSidecar));
}
return blockInput;
return blockInputs;
}

// Post EIP-4844 but old blobs
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/src/sync/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class BeaconSync implements IBeaconSync {
get state(): SyncState {
const currentSlot = this.chain.clock.currentSlot;
const headSlot = this.chain.forkChoice.getHead().slot;

if (
// Consider node synced IF
// Before genesis OR
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./array.js";
export * from "./attestation.js";
export * from "./attesterStatus.js";
export * from "./balance.js";
export * from "./blindedBlock.js";
export * from "./blobs.js";
export * from "./capella.js";
export * from "./execution.js";
Expand All @@ -23,4 +24,3 @@ export * from "./slot.js";
export * from "./syncCommittee.js";
export * from "./validator.js";
export * from "./weakSubjectivity.js";
export * from "./blindedBlock.js";
11 changes: 7 additions & 4 deletions packages/validator/test/unit/utils/params.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ const testCases: {name: string; items: [IChainConfig, Record<string, string>]}[]
{name: "nimbus", items: [networksChainConfig.ropsten, nimbusRopstenConfig]},
];

/* eslint-disable @typescript-eslint/naming-convention */

describe("utils / params / assertEqualParams", () => {
it("default == default", () => {
const chainConfigJson = chainConfigToJson(chainConfig);
assertEqualParams(chainConfig, chainConfigJson);
});

it("default != other", () => {
const chainConfigJson = chainConfigToJson(chainConfig);
const ALTAIR_FORK_EPOCH = 10;
const localConfig: typeof chainConfig = {...chainConfig, ALTAIR_FORK_EPOCH};
const chainConfigJson = chainConfigToJson(localConfig);

// Force ALTAIR_FORK_EPOCH value to be different
// eslint-disable-next-line @typescript-eslint/naming-convention
const otherConfig = {...chainConfigJson, ALTAIR_FORK_EPOCH: String(chainConfig.ALTAIR_FORK_EPOCH + 1)};
const otherConfig = {...chainConfigJson, ALTAIR_FORK_EPOCH: String(ALTAIR_FORK_EPOCH + 1)};

expect(() => assertEqualParams(chainConfig, otherConfig)).to.throw(NotEqualParamsError);
expect(() => assertEqualParams(localConfig, otherConfig)).to.throw(NotEqualParamsError);
});

it("should fill missing remote values with default and be equal", () => {
Expand Down

0 comments on commit 413c849

Please sign in to comment.