Skip to content

Commit

Permalink
debug resolver success callback
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed Aug 4, 2024
1 parent 74655ec commit 35dbc6d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export class Network {
blockNumber = BigInt(blockNumber.toString());
const before = this.nowMs();

const oldLatestBlockNumber = BigInt(this.latestBlockNumber);
const oldLatestBlockNumber = this.latestBlockNumber ? BigInt(this.latestBlockNumber) : null;
if (this.latestBlockNumber && blockNumber <= this.latestBlockNumber) {
return null;
}
Expand Down
20 changes: 17 additions & 3 deletions app/jobs/RandaoJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ export class RandaoJob extends AbstractJob {
this.failedIntervalEstimationsInARow = 0;
this.failedResolverEstimationsInARow = 0;
this.failedInitiateSlashingEstimationsInARow = 0;
this.applyClearResolverTimeouts();
super.applyWasExecuted();
}

public applyClearResolverTimeouts(): void {
this.clog('debug', 'applyClearResolverTimeouts()');
this._initiateSlashingPending = false;
this.t1 = 0;
this.b1 = 0n;
this.tn = 0;
Expand Down Expand Up @@ -375,6 +378,18 @@ export class RandaoJob extends AbstractJob {
}

protected async resolverSuccessCallback(triggeredByBlockNumber, invokeCalldata) {
this.clog(
'debug',
`resolverSuccessCallback kId=${this.agent.getKeeperId()}, akId: ${this.assignedKeeperId}, currentPeriod: ` +
`${this._getCurrentPeriodResolverJob()}, initiateSlashingPending: ${this._initiateSlashingPending}`,
);
const now = this.agent.nowS();
const period1 = (this.agent as IRandaoAgent).getPeriod1Duration();

if (this._initiateSlashingPending && this.agent.nowS() - this.tn > period1 * 5) {
this.applyClearResolverTimeouts();
}

if (this.agent.getKeeperId() === this.assignedKeeperId) {
// execute
await this.executeResolverJob(invokeCalldata);
Expand All @@ -387,12 +402,9 @@ export class RandaoJob extends AbstractJob {
await this.executeResolverJob(invokeCalldata);
} else if (!this._initiateSlashingPending) {
// initiateSlashing
const now = this.agent.nowS();
const latestBlock = this.agent.getNetwork().getLatestBlockNumber();
const period1 = (this.agent as IRandaoAgent).getPeriod1Duration();

this.tn = Number(this.agent.getNetwork().getLatestBlockTimestamp());
this.bn = latestBlock;

// reset t1 & b1 if the bn is more than two blocks behind
if (this.bn + 2n < latestBlock) {
Expand All @@ -401,6 +413,8 @@ export class RandaoJob extends AbstractJob {
this.b1 = this.bn;
}

this.bn = latestBlock;

if (this.t1) {
const left = this.t1 + period1 - now;
this.clog(
Expand Down

0 comments on commit 35dbc6d

Please sign in to comment.