Skip to content

Commit

Permalink
zero out pending validators on voluntary exits + enable exitRequested…
Browse files Browse the repository at this point in the history
… automatically
  • Loading branch information
noahfigueras committed Nov 30, 2023
1 parent b1a2aa2 commit 13edad7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/oracle/epoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { setTimeout } from "timers/promises";
import { Oracle } from './oracle';
import { DB } from '../db';
import { Validator } from '../types';
import { Contract, utils } from 'ethers';
import { Contract, utils, BigNumber } from 'ethers';
import { filterLogs, existsHead } from "../utils";
import {
verifyValidator,
Expand Down Expand Up @@ -226,8 +226,12 @@ async function voluntaryExits(data: any, db: DB) {
const index = exit.message.validator_index;
const validator = await db.get(index);
if(validator) {
validator.deactivated = true;
validator.active = false;
if(!validator.firstBlockProposed) {
// Zero out validator
validator.rewards = BigNumber.from("0");
logger.info(`Zero out - validator_index=${validator.index}`);
}
validator.exitRequested = true;
await db.insert(index, validator);
logger.info(`Voluntary exit - validator_index=${index}`);
}
Expand Down

0 comments on commit 13edad7

Please sign in to comment.