Skip to content

Commit

Permalink
Fix node balance accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewallmann committed Feb 11, 2025
1 parent 85442a1 commit bc358f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/contract/deposit/RocketDepositPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
emit FundsAssigned(head.receiver, ethRequired, block.timestamp);
linkedListStorage.dequeueItem(namespace);
// Account for node balance
nodeBalanceUsed += head.suppliedValue;
nodeBalanceUsed += head.suppliedValue * milliToWei;
totalSent += ethRequired;
// Update counts for next iteration
queueIndex ++;
Expand Down
8 changes: 6 additions & 2 deletions test/_helpers/megapool.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ export async function nodeDeposit(node, bondAmount = '4'.ether, useExpressTicket
rocketMegapoolManager.getValidatorCount(),
rocketDepositPool.getExpressQueueLength(),
rocketDepositPool.getStandardQueueLength(),
rocketDepositPool.getNodeBalance(),
]).then(
([ deployed, numExpressTickets, numGlobalValidators, expressQueueLength, standardQueueLength]) =>
({ deployed, numExpressTickets, numGlobalValidators, expressQueueLength, standardQueueLength, numValidators: 0n, assignedValue: 0n, nodeCapital: 0n, userCapital: 0n }),
([ deployed, numExpressTickets, numGlobalValidators, expressQueueLength, standardQueueLength, nodeBalance]) =>
({ deployed, numExpressTickets, numGlobalValidators, expressQueueLength, standardQueueLength, nodeBalance, numValidators: 0n, assignedValue: 0n, nodeCapital: 0n, userCapital: 0n }),
);

if (data.deployed) {
Expand Down Expand Up @@ -129,6 +130,7 @@ export async function nodeDeposit(node, bondAmount = '4'.ether, useExpressTicket
const userCapitalDelta = data2.userCapital - data1.userCapital;
const expressQueueLengthDelta = data2.expressQueueLength - data1.expressQueueLength;
const standardQueueLengthDelta = data2.standardQueueLength - data1.standardQueueLength;
const nodeBalanceDelta = data2.nodeBalance - data1.nodeBalance;

assertBN.equal(numValidatorsDelta, 1n, "Number of validators did not increase by 1");
assertBN.equal(numGlobalValidatorsDelta, 1n, "Number of global validators did not increase by 1");
Expand Down Expand Up @@ -157,12 +159,14 @@ export async function nodeDeposit(node, bondAmount = '4'.ether, useExpressTicket
assertBN.equal(nodeCapitalDelta, 0n, "Incorrect node capital");
assertBN.equal(userCapitalDelta, 0n, "Incorrect user capital");
assertBN.equal(assignedValueDelta, '31'.ether, "Incorrect assigned value");
assertBN.equal(nodeBalanceDelta, 0n, "Incorrect node balance value");
} else {
assert.equal(validatorInfo.inQueue, true, "Incorrect validator status");
assert.equal(validatorInfo.inPrestake, false, "Incorrect validator status");
assertBN.equal(nodeCapitalDelta, 0n, "Incorrect node capital");
assertBN.equal(userCapitalDelta, 0n, "Incorrect user capital");
assertBN.equal(assignedValueDelta, 0n, "Incorrect assigned value");
assertBN.equal(nodeBalanceDelta, bondAmount, "Incorrect node balance value");
}

assertBN.equal(validatorInfo.lastRequestedValue, '32'.ether / milliToWei, "Incorrect validator lastRequestedValue");
Expand Down

0 comments on commit bc358f3

Please sign in to comment.