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

protocol upgrade (v2): Burn slashed rewards (phase RD 1) + changes to system epoch info event #3739

Merged
merged 35 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ab64e72
initial changes
oliviasaa Oct 29, 2024
945abaa
add tests
oliviasaa Oct 29, 2024
fe8a51f
remove unused function
oliviasaa Oct 29, 2024
959eeb6
add snapshot related files
oliviasaa Oct 29, 2024
702935e
fix(node): regenerate baselines for tests
muXxer Nov 1, 2024
51452cf
fix(node): simplify `compute_adjusted_reward_distribution`
muXxer Nov 5, 2024
cc82ac9
fix(node): update framework manifest
muXxer Nov 5, 2024
36478bc
fix(node): add some checks and comments to the rewards tests
muXxer Nov 5, 2024
666eac6
Update crates/iota-framework/packages/iota-system/sources/validator_s…
oliviasaa Nov 5, 2024
97c22f9
fix(node): regenerate baselines for tests
muXxer Nov 5, 2024
0f8533a
add comments to reward distribution tests
oliviasaa Nov 27, 2024
fe94fdf
Merge branch 'develop' into protocol/burn_slashed_rewards-RD1
cyberphysic4l Dec 4, 2024
93ee46e
show correct burnt amount in SystemEpochInfoEventV1
cyberphysic4l Dec 4, 2024
c2523d1
remove parentheses
cyberphysic4l Dec 4, 2024
0a5646f
Add checks that slashed rewards are burned to tests
cyberphysic4l Dec 4, 2024
904b9ea
get burned and minted amounts directly from match function logic
cyberphysic4l Dec 5, 2024
245ef95
fix mixed up burned and minted amounts.
cyberphysic4l Dec 5, 2024
2db1618
Merge pull request #4352 from iotaledger/fix/system-epoch-info-event
cyberphysic4l Dec 5, 2024
527d462
update protocol config for v2
cyberphysic4l Dec 5, 2024
dcc6733
generate v2 framework snapshot
cyberphysic4l Dec 5, 2024
c132a15
Merge branch 'develop' into protocol/burn_slashed_rewards-RD1
cyberphysic4l Dec 5, 2024
1377b93
fix(iota-protocol-config): fixed resolving protocol version for simul…
valeriyr Nov 26, 2024
28d4830
update swarm-config snapshots
cyberphysic4l Dec 5, 2024
95c7685
generate snapshot for e2e tests
cyberphysic4l Dec 5, 2024
f20be52
update open-rpc
cyberphysic4l Dec 5, 2024
efde8a2
fix(iota-indexer): tests use protocol max version instead of 1
miker83z Dec 9, 2024
bb60ab4
update framework snapshot
cyberphysic4l Dec 9, 2024
13104ca
fix(iota-swarm-config): test baseline
miker83z Dec 9, 2024
35d84f7
fix(iota-e2e-tests): update snapshot for snapshot tests
miker83z Dec 9, 2024
9e8eea8
fix(iota-e2e-tests): update snapshot-tests object ids and tx digest
miker83z Dec 9, 2024
15b1160
Merge branch 'develop' into protocol/burn_slashed_rewards-RD1
miker83z Dec 10, 2024
1f70e9f
fix: add comment about protocol version 2
lzpap Dec 11, 2024
9dedda4
fix: fmt
lzpap Dec 11, 2024
0d00ae6
fix: update protocol config comment
miker83z Dec 11, 2024
dd4ae32
Merge branch 'develop' into protocol/burn_slashed_rewards-RD1
miker83z Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
source: crates/iota-e2e-tests/tests/snapshot_tests.rs
expression: "run_one(cmds, context).await?"
---
[
"iota client objects {ME}",
[
{
"data": {
"objectId": "0x239c0e67c1d0237586af6dec711bd7c6c9496e7ac8b35e3e6df24c27030559da",
"version": "1",
"digest": "8nL2C1HMRSjubtD8XeH9beBs3gHz2soBp6cZph8YAA8j",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"owner": {
"AddressOwner": "0x00a059cf7241f92b9c716dd5bc2077b32a180a784d907359d007f00cb76970e1"
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"fields": {
"balance": "30000000000000000",
"id": {
"id": "0x239c0e67c1d0237586af6dec711bd7c6c9496e7ac8b35e3e6df24c27030559da"
}
}
}
}
},
{
"data": {
"objectId": "0x4b1561b050cd8dab26de6daf853081c24490a0cdd42b066ceac3e280504e6735",
"version": "1",
"digest": "EKKFoQDJJ6pa2GmeNA1yNSzCP76pZX1o77svZTbFxEL7",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"owner": {
"AddressOwner": "0x00a059cf7241f92b9c716dd5bc2077b32a180a784d907359d007f00cb76970e1"
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"fields": {
"balance": "30000000000000000",
"id": {
"id": "0x4b1561b050cd8dab26de6daf853081c24490a0cdd42b066ceac3e280504e6735"
}
}
}
}
},
{
"data": {
"objectId": "0xaf5d50b4ba22b3386f32d58522096651967fc9170518d7138942240cccbd759a",
"version": "1",
"digest": "CpfG5nBqBarBk9vBV6mKUgEJ5REc99sBmQBrnsn2qE3P",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"owner": {
"AddressOwner": "0x00a059cf7241f92b9c716dd5bc2077b32a180a784d907359d007f00cb76970e1"
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"fields": {
"balance": "30000000000000000",
"id": {
"id": "0xaf5d50b4ba22b3386f32d58522096651967fc9170518d7138942240cccbd759a"
}
}
}
}
},
{
"data": {
"objectId": "0xb01af1f557df5884b12d0c8f64bf0b9e7c8a519673742434b0dd4024841de1a5",
"version": "1",
"digest": "4m7ojgZzqsHWQDXv7W8ia7jKar2zAuK4gHHXkCyX7UaN",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"owner": {
"AddressOwner": "0x00a059cf7241f92b9c716dd5bc2077b32a180a784d907359d007f00cb76970e1"
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"fields": {
"balance": "30000000000000000",
"id": {
"id": "0xb01af1f557df5884b12d0c8f64bf0b9e7c8a519673742434b0dd4024841de1a5"
}
}
}
}
},
{
"data": {
"objectId": "0xf314c9f8b3b997ad7a9454b590c71b1d50d7d67aa8c7b7a6cdc3d595b55e297f",
"version": "1",
"digest": "PZca4BJVr3gWLPYXLURmpNLmEHkMrDz5Td8kUZqv2Rv",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"owner": {
"AddressOwner": "0x00a059cf7241f92b9c716dd5bc2077b32a180a784d907359d007f00cb76970e1"
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x2::coin::Coin<0x2::iota::IOTA>",
"fields": {
"balance": "30000000000000000",
"id": {
"id": "0xf314c9f8b3b997ad7a9454b590c71b1d50d7d67aa8c7b7a6cdc3d595b55e297f"
}
}
}
}
}
],
"iota client objects 0x0000000000000000000000000000000000000000000000000000000000000000",
[],
"iota client object 0x5",
[
{
"data": {
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"version": "1",
"digest": "Hh6D3MbK7ufnUgrABumJ2qzKNrk9KG9VyBnWo2yYjiUN",
"type": "0x3::iota_system::IotaSystemState",
"owner": {
"Shared": {
"initial_shared_version": 1
}
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"content": {
"dataType": "moveObject",
"type": "0x3::iota_system::IotaSystemState",
"fields": {
"id": {
"id": "0x0000000000000000000000000000000000000000000000000000000000000005"
},
"version": "1"
}
}
}
}
],
"iota client object 0x5 --bcs",
[
{
"data": {
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"version": "1",
"digest": "Hh6D3MbK7ufnUgrABumJ2qzKNrk9KG9VyBnWo2yYjiUN",
"type": "0x3::iota_system::IotaSystemState",
"owner": {
"Shared": {
"initial_shared_version": 1
}
},
"previousTransaction": "DQa8r9XZcquYpjLpZ4DujsX3jFsy87iTLvC5AbR8Qfqq",
"storageRebate": "0",
"bcs": {
"dataType": "moveObject",
"type": "0x3::iota_system::IotaSystemState",
"version": 1,
"bcsBytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUBAAAAAAAAAA=="
}
}
}
],
"iota client object 0x0000000000000000000000000000000000000000000000000000000000000000",
[
{
"error": {
"code": "notExists",
"object_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
],
"iota client tx-block 5zibcom3dMckjyN16ygFwr5XNa9Exi1MmY3BQs984x1N",
"ErrorObject { code: InvalidParams, message: \"Could not find the referenced transaction [TransactionDigest(5zibcom3dMckjyN16ygFwr5XNa9Exi1MmY3BQs984x1N)].\", data: None }",
"iota client tx-block 11111111111111111111111111111111",
"ErrorObject { code: InvalidParams, message: \"Could not find the referenced transaction [TransactionDigest(11111111111111111111111111111111)].\", data: None }"
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions crates/iota-framework-snapshot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@
"0x000000000000000000000000000000000000000000000000000000000000000b",
"0x000000000000000000000000000000000000000000000000000000000000107a"
]
},
"2": {
"git_revision": "f20be52f200b",
"package_ids": [
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000002",
"0x0000000000000000000000000000000000000000000000000000000000000003",
"0x000000000000000000000000000000000000000000000000000000000000000b",
"0x000000000000000000000000000000000000000000000000000000000000107a"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,9 @@ module iota_system::iota_system_state_inner {
let storage_charge_value = storage_charge.value();
let computation_charge = computation_reward.value();

// Mints or burns tokens depending on the target reward.
// Since not all rewards are distributed in case of slashed validators,
// tokens might be minted here and burnt in the same epoch change.
let (mut total_validator_rewards, minted_tokens_amount, mut burnt_tokens_amount) = match_computation_reward_to_target_reward(
validator_target_reward,
computation_reward,
Expand All @@ -701,7 +704,7 @@ module iota_system::iota_system_state_inner {
let new_total_stake = self.validators.total_stake();

let remaining_validator_rewards_amount_after_distribution = total_validator_rewards.value();
let total_validator_rewards_distributed = total_validator_rewards_amount_before_distribution - remaining_validator_rewards_amount_after_distribution;
let total_stake_rewards_distributed = total_validator_rewards_amount_before_distribution - remaining_validator_rewards_amount_after_distribution;

self.protocol_version = next_protocol_version;

Expand Down Expand Up @@ -731,9 +734,9 @@ module iota_system::iota_system_state_inner {
storage_rebate: storage_rebate_amount,
storage_fund_balance: self.storage_fund.total_balance(),
total_gas_fees: computation_charge,
total_stake_rewards_distributed: total_validator_rewards_distributed,
total_stake_rewards_distributed,
burnt_tokens_amount,
minted_tokens_amount
minted_tokens_amount,
}
);
self.safe_mode = false;
Expand All @@ -751,24 +754,22 @@ module iota_system::iota_system_state_inner {
/// and the amount of computation fees burned in this epoch.
fun match_computation_reward_to_target_reward(
validator_target_reward: u64,
mut computation_reward: Balance<IOTA>,
mut computation_charges: Balance<IOTA>,
iota_treasury_cap: &mut iota::iota::IotaTreasuryCap,
ctx: &TxContext,
): (Balance<IOTA>, u64, u64) {
let mut burnt_tokens_amount = 0;
let mut minted_tokens_amount = 0;
if (computation_reward.value() < validator_target_reward) {
let tokens_to_mint = validator_target_reward - computation_reward.value();
let new_tokens = iota_treasury_cap.mint_balance(tokens_to_mint, ctx);
minted_tokens_amount = new_tokens.value();
computation_reward.join(new_tokens);
} else if (computation_reward.value() > validator_target_reward) {
let tokens_to_burn = computation_reward.value() - validator_target_reward;
let rewards_to_burn = computation_reward.split(tokens_to_burn);
burnt_tokens_amount = rewards_to_burn.value();
iota_treasury_cap.burn_balance(rewards_to_burn, ctx);
let burnt_tokens_amount = computation_charges.value();
let minted_tokens_amount = validator_target_reward;
if (burnt_tokens_amount < minted_tokens_amount) {
let actual_amount_to_mint = minted_tokens_amount - burnt_tokens_amount;
let balance_to_mint = iota_treasury_cap.mint_balance(actual_amount_to_mint, ctx);
computation_charges.join(balance_to_mint);
} else if (burnt_tokens_amount > minted_tokens_amount) {
let actual_amount_to_burn = burnt_tokens_amount - minted_tokens_amount;
let balance_to_burn = computation_charges.split(actual_amount_to_burn);
iota_treasury_cap.burn_balance(balance_to_burn, ctx);
};
(computation_reward, minted_tokens_amount, burnt_tokens_amount)
(computation_charges, minted_tokens_amount, burnt_tokens_amount)
}

/// Return the current epoch number. Useful for applications that need a coarse-grained concept of time,
Expand Down
Loading
Loading