Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second step to remove legacy #159

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Second step to remove legacy #159

wants to merge 5 commits into from

Conversation

vzotova
Copy link
Contributor

@vzotova vzotova commented Nov 27, 2023

Now when all legacy token unstaked we don't need any support of it.
All methods related to legacy were removed including new one to force unstake.

@vzotova vzotova self-assigned this Nov 27, 2023
Copy link

Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011406420 check.

@vzotova vzotova force-pushed the remove-legacy-step-2 branch 2 times, most recently from edfbc18 to b181f2a Compare November 27, 2023 22:48
Copy link

Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011594546 check.

Copy link

Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011601971 check.

@michalinacienciala
Copy link
Contributor

Do we still need the @keep-network/keep-core dependency in package.json?

/// amount to 0 and withdraws all liquid T from the stake to the
/// owner. Reverts if there is at least one non-zero authorization.
/// authorization higher than the remaining liquid T stake or
/// if the unstake amount is higher than the liquid T stake amount.
Copy link
Member

Choose a reason for hiding this comment

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

I think we can change "liquid T stake" (which doesn't make much sense now) into just "T stake" everywhere

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 nuInTStake
);
/// @notice Returns staked amount of T for the specified staking provider.
function tStake(address stakingProvider) external view returns (uint96);
Copy link
Member

Choose a reason for hiding this comment

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

What about stakeAmount, or even just stake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stake is used, I'm fine with stakeAmount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

/// that run on the Threshold Network. Note that legacy NU/KEEP staking
/// contracts see TokenStaking as an application (e.g., slashing is
/// requested by TokenStaking and performed by the legacy contracts).
/// Additionally, it serves as application manager for the apps
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Additionally, it serves as application manager for the apps
/// It serves as application manager for the apps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

@@ -108,7 +101,6 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
uint256 public slashingQueueIndex;

event Staked(
StakeType indexed stakeType,
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid we can't drop this. There's already a bunch of external apps (e.g., Dune queries) that consume events in their current form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, added back ✔️

address owner;
uint96 keepInTStake;
uint96 legacyKeepInTStake;
Copy link
Member

@cygnusv cygnusv Nov 28, 2023

Choose a reason for hiding this comment

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

Can we leave the old names? I ran the OZ upgrade tool on the new contract (see below), and so far the only thing it doesn't like is these 2 name changes. For contract variable names, there's a way to override this error, but for the moment not for struct members ( see https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#how-to-rename). For the moment, instead of changing the name we can leave a comment.

OZ output:

Error: ERROR processing /Users/david/dev/t/solidity-contracts/deploy/60_validate_upgrade_token_staking.ts:
Error: New storage layout is incompatible

contracts/staking/TokenStaking.sol:120: Upgraded `stakingProviders` to an incompatible type
  - In mapping(address => struct TokenStaking.StakingProviderInfo)
    - Bad upgrade to struct TokenStaking.StakingProviderInfo
  - In struct TokenStaking.StakingProviderInfo
    - Renamed `nuInTStake` to `legacyNuInTStake`
    - Renamed `keepInTStake` to `legacyKeepInTStake`

Side-note: I need to add this validation tool to CI, probably I'm doing it as part of #140. I also need to check why the tool doesn't complain about the change in the Staked event signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing of event can't break storage but renaming theoretically can (if we would use those variables) somewhere.
Renamed back ✔️

@vzotova
Copy link
Contributor Author

vzotova commented Nov 28, 2023

Do we still need the @keep-network/keep-core dependency in package.json?

Didn't find any usage so removed, @michalinacienciala could you check please that nothing needed was not removed?

Copy link

Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7021124328 check.

Copy link
Contributor

@michalinacienciala michalinacienciala left a comment

Choose a reason for hiding this comment

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

Do we still need the @keep-network/keep-core dependency in package.json?

Didn't find any usage so removed, @michalinacienciala could you check please that nothing needed was not removed?

I left two comments. I think we can also do a cleanup of Keep contracts in the ./external folder and remove these lines:

goerli: ["./external/goerli"],
sepolia: ["./external/sepolia"],
.

.github/workflows/contracts.yml Outdated Show resolved Hide resolved
.github/workflows/npm.yml Outdated Show resolved Hide resolved
Copy link

Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7036583518 check.

Comment on lines 94 to 83
goerli: ["./external/goerli"],
sepolia: ["./external/sepolia"],
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 also remove the corresponding folders?

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've noticed only now that I haven't finished with this PR, sorry.
Done! ✔️

manumonti
manumonti previously approved these changes Mar 13, 2024
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

Bye bye, legacy staking 👋

Please, lmk when the new version of the contract is deployed since it will require some update on subgraphs.

Just a question: why the struct StakingProviderInfo in TokenStaking.sol is still keeping nuInTStake and keepInTStake?

@vzotova
Copy link
Contributor Author

vzotova commented Mar 13, 2024

Bye bye, legacy staking 👋

Please, lmk when the new version of the contract is deployed since it will require some update on subgraphs.

Just a question: why the struct StakingProviderInfo in TokenStaking.sol is still keeping nuInTStake and keepInTStake?

otherwise data layout will be corrupted and other values would not be get correctly. knowing that those slots are 0 we can theoretically reuse them for something new but I'd avoid it too

theref
theref previously approved these changes Mar 13, 2024
Copy link
Member

@theref theref left a comment

Choose a reason for hiding this comment

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

i love it 🪓

manumonti
manumonti previously approved these changes Mar 26, 2024
/// @notice Returns staked amount of T, Keep and Nu for the specified
/// staking provider.
/// @dev All values are in T denomination
function stakes(address stakingProvider)
Copy link
Member

Choose a reason for hiding this comment

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

I just realized we will be breaking stuff that consumes Threshold staking information by removing this method. For example, here's the dashboard unpacking the result from stakes():
https://github.com/threshold-network/token-dashboard/blob/8264be8e00286f9d51674fd07ca67030a40ed168/src/threshold-ts/staking/index.ts#L220

What do you think about keeping this method, but marking it as deprecated? Still, I'd keep the stakeAmount() method. In the meantime, we can identify stuff that can be updated or removed in the dashboard after legacy support was dropped, which I think it's probably a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

@@ -369,27 +342,21 @@ each affected application.

Returns the authorized stake amount of the staking provider for the application.

==== `stakes(address stakingProvider) external view returns (uint96 tStake, uint96 keepInTStake, uint96 nuInTStake)`
Copy link
Member

Choose a reason for hiding this comment

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

See my comment above about leaving this method but marked as deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

the specified stake type is the minimum amount of stake of the given type needed
to satisfy the maximum application authorization given the staked amounts of the
T stake type for that staking provider.
Returns the maximum application authorization
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Returns the maximum application authorization
Returns the maximum application authorization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✔️

@vzotova vzotova dismissed stale reviews from manumonti and theref via 9d5daff September 9, 2024 19:30
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.

5 participants