Skip to content

Commit

Permalink
refactor: shift usage to publishblock v2 endpoint, cleanup v1 post de…
Browse files Browse the repository at this point in the history
…neb (#6084)

refactor: cleanup publishblock v1 support and usage
  • Loading branch information
g11tech authored Nov 4, 2023
1 parent 5ff90ca commit bf5d92b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export type Api = {

publishBlockV2(
blockOrContents: allForks.SignedBeaconBlockOrContents,
opts: {broadcastValidation?: BroadcastValidation}
opts?: {broadcastValidation?: BroadcastValidation}
): Promise<
ApiClientResponse<
{
Expand Down Expand Up @@ -341,7 +341,7 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
getBlockRoot: blockIdOnlyReq,
publishBlock: reqOnlyBody(AllForksSignedBlockOrContents, Schema.Object),
publishBlockV2: {
writeReq: (item, {broadcastValidation}) => ({
writeReq: (item, {broadcastValidation} = {}) => ({
body: AllForksSignedBlockOrContents.toJson(item),
query: {broadcast_validation: broadcastValidation},
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/sim/multi_fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ await connectNewNode(unknownBlockSync, env.nodes);
await sleep(5000);

try {
ApiError.assert(await unknownBlockSync.beacon.api.beacon.publishBlock(headForUnknownBlockSync.response.data));
ApiError.assert(await unknownBlockSync.beacon.api.beacon.publishBlockV2(headForUnknownBlockSync.response.data));

env.tracker.record({
message: "Publishing unknown block should fail",
Expand Down
4 changes: 2 additions & 2 deletions packages/validator/src/services/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class BlockProposingService {
ApiError.assert(
isBlindedBeaconBlock(signedBlock.message)
? await this.api.beacon.publishBlindedBlock(signedBlock as allForks.SignedBlindedBeaconBlock)
: await this.api.beacon.publishBlock(signedBlock as allForks.SignedBeaconBlock)
: await this.api.beacon.publishBlockV2(signedBlock as allForks.SignedBeaconBlock)
);
} else {
ApiError.assert(
Expand All @@ -187,7 +187,7 @@ export class BlockProposingService {
signedBlindedBlock: signedBlock,
signedBlindedBlobSidecars: signedBlobSidecars,
} as allForks.SignedBlindedBlockContents)
: await this.api.beacon.publishBlock({signedBlock, signedBlobSidecars} as allForks.SignedBlockContents)
: await this.api.beacon.publishBlockV2({signedBlock, signedBlobSidecars} as allForks.SignedBlockContents)
);
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/validator/test/unit/services/block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("BlockDutiesService", function () {
ok: true,
status: HttpStatusCode.OK,
});
api.beacon.publishBlock.resolves();
api.beacon.publishBlockV2.resolves();

// Trigger block production for slot 1
const notifyBlockProductionFn = blockService["dutiesService"]["notifyBlockProductionFn"];
Expand All @@ -77,7 +77,7 @@ describe("BlockDutiesService", function () {
await sleep(20, controller.signal);

// Must have submitted the block received on signBlock()
expect(api.beacon.publishBlock.callCount).to.equal(1, "publishBlock() must be called once");
expect(api.beacon.publishBlock.getCall(0).args).to.deep.equal([signedBlock], "wrong publishBlock() args");
expect(api.beacon.publishBlockV2.callCount).to.equal(1, "publishBlock() must be called once");
expect(api.beacon.publishBlockV2.getCall(0).args).to.deep.equal([signedBlock], "wrong publishBlock() args");
});
});

0 comments on commit bf5d92b

Please sign in to comment.