Skip to content

Commit

Permalink
feat: add logs for builder validator registrations (#5986)
Browse files Browse the repository at this point in the history
* feat: add logs for builder validator registrations

* Throw error if builder is not enabled

* Update log messages

* Add epoch info to beacon log
  • Loading branch information
nflaig authored Sep 23, 2023
1 parent 3903dc1 commit 0f74435
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 10 additions & 1 deletion packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,10 @@ export function getValidatorApi({
},

async registerValidator(registrations) {
if (!chain.executionBuilder) {
throw Error("Execution builder not enabled");
}

// should only send active or pending validator to builder
// Spec: https://ethereum.github.io/builder-specs/#/Builder/registerValidator
const headState = chain.getHeadState();
Expand All @@ -838,7 +842,12 @@ export function getValidatorApi({
);
});

return chain.executionBuilder?.registerValidator(filteredRegistrations);
await chain.executionBuilder.registerValidator(filteredRegistrations);

logger.debug("Forwarded validator registrations to connected builder", {
epoch: currentEpoch,
count: filteredRegistrations.length,
});
},
};
}
5 changes: 4 additions & 1 deletion packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
}

async registerValidator(registrations: bellatrix.SignedValidatorRegistrationV1[]): Promise<void> {
ApiError.assert(await this.api.registerValidator(registrations));
ApiError.assert(
await this.api.registerValidator(registrations),
"Failed to forward validator registrations to connected builder"
);
}

async getHeader(
Expand Down
3 changes: 2 additions & 1 deletion packages/validator/src/services/prepareBeaconProposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ export function pollBuilderValidatorRegistration(
})
);
ApiError.assert(await api.validator.registerValidator(registrations));
logger.info("Published validator registrations to builder network", {epoch, count: registrations.length});
} catch (e) {
logger.error("Failed to register validator registrations with builder", {epoch}, e as Error);
logger.error("Failed to publish validator registrations to builder network", {epoch}, e as Error);
}
}
}
Expand Down

0 comments on commit 0f74435

Please sign in to comment.