Skip to content

Commit

Permalink
[sui-framework] Remove "delegate" and replace with stake (#9059)
Browse files Browse the repository at this point in the history
This does a large rename of "delegation/delegate" (etc) to the
equivalent "stake" name, e.g., `request_add_delegation` becomes
`request_add_stake`.

## Move

### Entry functions renamed (all within `sui_system.move`):
```
request_add_delegation ~> request_add_stake
request_add_delegation_mul_coin ~> request_add_stake_mul_coin
request_add_delegation_with_locked_coin ~> request_add_stake_with_locked_coin
request_add_delegation_with_mul_locked_coin ~> request_add_stake_with_mul_locked_coin
request_withdraw_delegation ~> request_withdraw_stake
```

### Move Object fields

```
StakingPool::pending_delegation ~> pending_stake
StakedSui::delegation_activation_epoch ~> stake_activation_epoch 
```

### Sui types

This renames a couple sui types since they no longer made sense to be
called what they were:

```
DelegatedStake ~> Stake
DelegationStatus ~> StakeStatus
```

This then performs the core set of renamings to make the system happy
with this. So there are still a number of functions in Rust and
Typescript that will contain their old delegation name.

Note that on the typescript side we keep DelegatedStake since (1) there
was already a type called Stake (which meant something else) and in the
context that I could see it being used it appeared as though
DelegatedStake really did mean "this is my stake that I have delegated
to this validator."

## Test Plan 

Make sure existing tests still pass.

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [X] user-visible impact
- [X] breaking change for a client SDKs
- [X] breaking change for FNs (FN binary must upgrade)
- [X] breaking change for validators or node operators (must upgrade
binaries)
- [X] breaking change for on-chain data layout
- [X] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
tzakian authored Mar 10, 2023
1 parent 3ae0f88 commit 0a7b42a
Show file tree
Hide file tree
Showing 48 changed files with 790 additions and 787 deletions.
14 changes: 14 additions & 0 deletions .changeset/slimy-eels-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@mysten/bcs": minor
"@mysten/ledgerjs-hw-app-sui": minor
"@mysten/sui.js": minor
"@mysten/wallet-adapter-all-wallets": minor
"@mysten/wallet-adapter-base": minor
"@mysten/wallet-adapter-unsafe-burner": minor
"@mysten/wallet-adapter-wallet-standard": minor
"@mysten/wallet-kit": minor
"@mysten/wallet-kit-core": minor
"@mysten/wallet-standard": minor
---

This changes almost all occurences of "delegate", "delegation" (and various capitalizations/forms) to their equivalent "stake"-based name. Function names, function argument names, RPC endpoints, Move functions, and object fields have been updated with this new naming convention.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type StakeTxnCardProps = {
events: TransactionEvents;
};

const REQUEST_DELEGATION_EVENT = '0x2::validator_set::DelegationRequestEvent';
const REQUEST_DELEGATION_EVENT = '0x2::validator_set::StakingRequestEvent';

// TODO: moveEvents is will be changing
// For Staked Transaction use moveEvent Field to get the validator address, delegation amount, epoch
Expand Down
12 changes: 6 additions & 6 deletions apps/wallet/src/ui/app/redux/slices/sui-objects/Coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Coin {
}

/**
* Stake `amount` of Coin<T> to `validator`. Technically it means user delegates `amount` of Coin<T> to `validator`,
* Stake `amount` of Coin<T> to `validator`. Technically it means user stakes `amount` of Coin<T> to `validator`,
* such that `validator` will stake the `amount` of Coin<T> for the user.
*
* @param signer A signer with connection to fullnode
Expand All @@ -94,7 +94,7 @@ export class Coin {
const transaction = Sentry.startTransaction({ name: 'stake' });

const span = transaction.startChild({
op: 'request-add-delegation',
op: 'request-add-stake',
description: 'Staking move call',
});

Expand All @@ -106,7 +106,7 @@ export class Coin {
);
tx.add(
Transaction.Commands.MoveCall({
target: '0x2::sui_system::request_add_delegation',
target: '0x2::sui_system::request_add_stake',
arguments: [
tx.input(SUI_SYSTEM_STATE_OBJECT_ID),
stakeCoin,
Expand All @@ -123,7 +123,7 @@ export class Coin {

public static async unStakeCoin(
signer: SignerWithProvider,
delegation: ObjectId,
stake: ObjectId,
stakedSuiId: ObjectId
): Promise<SuiTransactionResponse> {
const transaction = Sentry.startTransaction({ name: 'unstake' });
Expand All @@ -132,10 +132,10 @@ export class Coin {
tx.setGasBudget(DEFAULT_GAS_BUDGET_FOR_STAKE);
tx.add(
Transaction.Commands.MoveCall({
target: '0x2::sui_system::request_withdraw_delegation',
target: '0x2::sui_system::request_withdraw_stake',
arguments: [
tx.input(SUI_SYSTEM_STATE_OBJECT_ID),
tx.input(delegation),
tx.input(stake),
tx.input(stakedSuiId),
],
})
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-benchmark/src/workloads/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use sui_core::test_utils::make_transfer_sui_transaction;
use sui_types::base_types::{ObjectRef, SuiAddress};
use sui_types::crypto::{get_key_pair, AccountKeyPair};
use sui_types::messages::VerifiedTransaction;
use test_utils::messages::make_delegation_transaction;
use test_utils::messages::make_staking_transaction;

#[derive(Debug)]
pub struct DelegationTestPayload {
Expand All @@ -31,7 +31,7 @@ impl Payload for DelegationTestPayload {
/// followup call creates delegation transaction itself
fn make_transaction(&self) -> VerifiedTransaction {
match self.coin {
Some(coin) => make_delegation_transaction(
Some(coin) => make_staking_transaction(
self.gas,
coin,
self.validator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ validators:
exchange_rates:
id: "0xe63945cec193ca7ac76960370028110a907ad1c22ff90b1fd57ea3c441c766b4"
size: 1
pending_delegation: 0
pending_stake: 0
pending_total_sui_withdraw: 0
pending_pool_token_withdraw: 0
commission_rate: 0
Expand Down
164 changes: 82 additions & 82 deletions crates/sui-framework/docs/staking_pool.md

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions crates/sui-framework/docs/sui_system.md

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions crates/sui-framework/docs/validator.md

Large diffs are not rendered by default.

88 changes: 44 additions & 44 deletions crates/sui-framework/docs/validator_set.md

Large diffs are not rendered by default.

Loading

0 comments on commit 0a7b42a

Please sign in to comment.