Skip to content

Touchups#175

Draft
vzotova wants to merge 13 commits intomainfrom
touchups
Draft

Touchups#175
vzotova wants to merge 13 commits intomainfrom
touchups

Conversation

@vzotova
Copy link
Contributor

@vzotova vzotova commented Feb 10, 2026

No description provided.

Copy link
Contributor

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general! just some comments

Comment on lines +499 to +503
ApplicationInfo storage applicationStruct = applicationInfo[msg.sender];
require(
applicationStruct.status == ApplicationStatus.APPROVED,
"Application is not approved"
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this check? Given that TACoApp is trusted in this context, it seems a bit redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to get same logic as in another methods, and that part is already tested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. My concern was cost for a migration of dozens of stakers, but apparently since we do this in a batch TX, only the first access to applicationStruct.status would get the full SLOAD cost, and the rest will only be 100 gas.

Comment on lines 306 to 312
// Unstake
stakingProviderStruct.tStake -= authorization.deauthorizing;
decreaseStakeCheckpoint(stakingProvider, authorization.deauthorizing);
emit Unstaked(stakingProvider, authorization.deauthorizing);
token.safeTransfer(stakingProviderStruct.owner, authorization.deauthorizing);

authorization.deauthorizing = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the goal of these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unstake the rest, everything over minimum


require(authorization.authorized >= amount, "Not enough authorization");

decreaseStakeCheckpoint(stakingProvider, stakingProviderStruct.tStake);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this line removed? In all cases, tStake tokens are leaving the contract, so this line should stay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, missed it through rearranging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

);
uint96 toUnstake = stakingProviderStruct.tStake;
stakingProviderStruct.tStake = 0;
decreaseStakeCheckpoint(stakingProvider, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
decreaseStakeCheckpoint(stakingProvider, 0);
decreaseStakeCheckpoint(stakingProvider, toUnstake);

The parameter here is the amount to decrease, so we want here to decrease all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

);
toUnstake -= amount;
authorization.authorized = 0;
if (amount > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make amount fixed, then this condition will always be true.

toUnstake -= amount;
authorization.authorized = 0;
if (amount > 0) {
token.safeTransfer(msg.sender, amount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that, technically, this amount is also Unstaked, at least from the Threshold Network perspective, so there should be an Unstaked event.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

await expect(tx)
.to.emit(tokenStaking, "Unstaked")
.withArgs(stakingProvider.address, amount.sub(amountToTransfer))
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add voting weight checks here as well. It should go to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

}

/// Migration
function migrateAndRelease(address stakingProvider, uint96 amount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think we should fix the amount to migrate as constant/immutable, because that reduces trust in the app implementation and makes the review process . Also it's a tiny gas reduction.

Co-authored-by: David Núñez <david@nucypher.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants