-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011406420 check. |
edfbc18
to
b181f2a
Compare
Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011594546 check. |
Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7011601971 check. |
Do we still need the |
contracts/staking/IStaking.sol
Outdated
/// 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
contracts/staking/IStaking.sol
Outdated
uint96 nuInTStake | ||
); | ||
/// @notice Returns staked amount of T for the specified staking provider. | ||
function tStake(address stakingProvider) external view returns (uint96); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
contracts/staking/TokenStaking.sol
Outdated
/// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Additionally, it serves as application manager for the apps | |
/// It serves as application manager for the apps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
contracts/staking/TokenStaking.sol
Outdated
@@ -108,7 +101,6 @@ contract TokenStaking is Initializable, IStaking, Checkpoints { | |||
uint256 public slashingQueueIndex; | |||
|
|||
event Staked( | |||
StakeType indexed stakeType, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, added back ✔️
contracts/staking/TokenStaking.sol
Outdated
address owner; | ||
uint96 keepInTStake; | ||
uint96 legacyKeepInTStake; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ✔️
Didn't find any usage so removed, @michalinacienciala could you check please that nothing needed was not removed? |
Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7021124328 check. |
There was a problem hiding this 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:
solidity-contracts/hardhat.config.ts
Lines 94 to 95 in 5fb485e
goerli: ["./external/goerli"], | |
sepolia: ["./external/sepolia"], |
Solidity API documentation preview available in the artifacts of the https://github.com/threshold-network/solidity-contracts/actions/runs/7036583518 check. |
hardhat.config.ts
Outdated
goerli: ["./external/goerli"], | ||
sepolia: ["./external/sepolia"], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! ✔️
There was a problem hiding this 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
?
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 |
213f0bb
to
fe1353a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i love it 🪓
Co-authored-by: David Núñez <[email protected]> Co-authored-by: Michalina <[email protected]>
…m governance contracts Co-authored-by: Michalina <[email protected]>
Co-authored-by: Michalina <[email protected]>
fe1353a
to
63bcfc3
Compare
/// @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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
docs/rfc-1-staking-contract.adoc
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the maximum application authorization | |
Returns the maximum application authorization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Co-authored-by: David Núñez <[email protected]>
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.