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

feat(protocol): PCR-2 base changes #5270

Open
wants to merge 5 commits into
base: protocol/pcr2-clean
Choose a base branch
from

Conversation

cyberphysic4l
Copy link
Contributor

Description of change

  • Introduce a feature flag protocol_defined_base_fee and config parameter base_gas_price.
  • protocol_defined_base_fee enables the base fee defined by base_gas_price in the place of the reference gas price defined by the gas price survey in earlier protocol versions. This base_gas_price for each transaction is burned, and any additional gas price will be passed to the validators as a tip.
  • The advance_epoch function in the iota framework is updated to burn the base fee and pass additional fee to validators. The function now takes an additional call argument - computation_charge_burned - to allow the base fee component and tip to be distinguished.
  • Also in the iota framework, we introduce IotaSystemStateV2 and associated types to include a safe_mode_computation_charges_burned field. Some tests are updated to deal with this new system state version. Updates were carried out following the guide provided in crates/iota-framework/packages/iota-system/sources/iota_system.move
  • A ChangeEpochV2 transaction kind is introduced for the epoch change system transaction corresponding to the advance_epoch function changes mentioned above. The new feature flag, protocol_defined_base_fee is used to determined when the new ChangeEpochV2 transaction kind should be used and the additional call argument be passed to the advance_epoch function
  • We update to SystemEpochInfoEventV2 to include the tips_amount field specifying how much of user computation fees are passed to validators.

Links to any relevant issues

Fixes #3122

Should be merged along with iotaledger/iota-rust-sdk#22

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How the change has been tested

Existing tests pass. Added move tests for tips in rewards_distribution_tests.move

Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

@cyberphysic4l cyberphysic4l requested review from a team as code owners February 7, 2025 12:30
Copy link

vercel bot commented Feb 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
apps-backend ⬜️ Ignored (Inspect) Visit Preview Feb 12, 2025 5:30pm
apps-ui-kit ⬜️ Ignored (Inspect) Visit Preview Feb 12, 2025 5:30pm
rebased-explorer ⬜️ Ignored (Inspect) Visit Preview Feb 12, 2025 5:30pm
wallet-dashboard ⬜️ Ignored (Inspect) Visit Preview Feb 12, 2025 5:30pm

@cyberphysic4l cyberphysic4l changed the base branch from core-protocol/procotol-version-4 to protocol/pcr2-clean February 7, 2025 13:13
@cyberphysic4l cyberphysic4l changed the title PCR-2 base changes feat(protocol): PCR-2 base changes Feb 7, 2025
params: &AdvanceEpochParams,
) -> Result<ProgrammableTransaction, ExecutionError> {
let call_arg_vec = vec![
CallArg::IOTA_SYSTEM_MUT,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would either add a comment here, that construct_advance_epoch_pt_impl adds more parameters here in the front, so that you directly see that this matches the "advance epoch" function, or we move the code from construct_advance_epoch_pt_impl and duplicate it to _v1 and _v2, so that it is clearly visible?

Copy link
Contributor

Choose a reason for hiding this comment

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

But yeah, not a blocking issue from my side, PR approved.

Copy link
Contributor

@kodemartin kodemartin left a comment

Choose a reason for hiding this comment

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

Hey @cyberphysic4l , a few nitpicks and a proposal with more impact to discuss.

crates/iota-types/src/event.rs Outdated Show resolved Hide resolved
crates/iota-types/src/event.rs Outdated Show resolved Hide resolved
crates/iota-types/src/gas.rs Show resolved Hide resolved
crates/iota-types/src/gas_model/gas_v1.rs Show resolved Hide resolved
Comment on lines +78 to +82
pub safe_mode_computation_charges: u64,
/// Amount of burned computation charges accumulated during safe mode.
#[schemars(with = "BigInt<u64>")]
#[serde_as(as = "Readable<BigInt<u64>, _>")]
pub safe_mode_computation_charges_burned: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks backwards compatibility for the JSON-RPC API (both the rename and the addition of the new field).

If we could version this as well, it would allow more flexibility in handling versioning in the API as well.

An idea would be to restructure the parent module to

iota_system_state/
   v1/
   v2/

Another would be to split iota_system_state_summary into iota_system_state_summary::{v1,v2}.

And last we could introduce a new IotaSystemStateSummaryV2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Introducing a V2 would require an enum like we have for IotaSystemState as well, and changing IotaSystemStateTrait and quite a lot of other code. Is a new version the only way we can change types in the JSON-RPC API in general, just like with the move types and their rust versions?

Copy link
Contributor

@kodemartin kodemartin Feb 12, 2025

Choose a reason for hiding this comment

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

I am afraid so. If we want to maintain backward compatibility we need the same response type, or something that is compatible with the existing response type.

This is true for every API, application, or library that depends on the public API iota-types as well. Even switching from a struct to an enum would be a breaking change because it would require different handling in any dependent code.

So the only way to maintain backward compatibility in every component that is affected by these changes would be to use a different struct.

We could break backwards compatibility for iota-types on the premise that is likely only used in the parent workspace and internal libraries. If that is the case, an alternative would be to deal with the two versions on iota-json-rpc-types and refactor APIs dependent on iota-types. The downside is that we introduce additional representations and logic in our libraries for the same information.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the only way to maintain backward compatibility in every component that is affected by these changes would be to use a different struct.

Actually this is not precise. At the very least we must break the IotaSystemStateTrait API.

crates/iota-core/src/checkpoints/mod.rs Outdated Show resolved Hide resolved
crates/iota-core/src/authority.rs Outdated Show resolved Hide resolved
crates/iota-core/src/authority.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@valeriyr valeriyr left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants