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

fix(genesis-builder): Always destroy allocation objects when picked #5028

Merged
merged 16 commits into from
Jan 29, 2025

Conversation

miker83z
Copy link
Contributor

Description of change

Fixes #5024 (it also adds a validation of the migrated objects after the genesis build)

Type of change

  • Bug fix (a non-breaking change which fixes an issue)

How the change has been tested

Change checklist

  • 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

@miker83z miker83z requested review from nonast and lzpap January 27, 2025 09:55
@miker83z miker83z requested review from a team and kodemartin as code owners January 27, 2025 09:55
Copy link

vercel bot commented Jan 27, 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 Jan 28, 2025 5:44pm
apps-ui-kit ⬜️ Ignored (Inspect) Visit Preview Jan 28, 2025 5:44pm
rebased-explorer ⬜️ Ignored (Inspect) Visit Preview Jan 28, 2025 5:44pm
wallet-dashboard ⬜️ Ignored (Inspect) Visit Preview Jan 28, 2025 5:44pm

@iota-ci iota-ci added sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team labels Jan 27, 2025
@miker83z miker83z requested a review from a team as a code owner January 28, 2025 11:12
Base automatically changed from vm-language/examine-genesis-checkpoint to develop January 28, 2025 11:41
@miker83z miker83z requested review from a team as code owners January 28, 2025 11:41
Comment on lines 168 to 174
Data::Move(_) => GasCoin::try_from(&object)
.map(|gas| gas.value())
.or_else(|_| TimeLock::<Balance>::try_from(&object).map(|t| t.locked().value()))
.or_else(|_| AliasOutput::try_from(&object).map(|a| a.balance.value()))
.or_else(|_| BasicOutput::try_from(&object).map(|b| b.balance.value()))
.or_else(|_| NftOutput::try_from(&object).map(|n| n.balance.value()))
.unwrap_or(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Any chance we can avoid this by checking a type byte or something?

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 object is encoded through a Move Struct, so unfortunately I don't see an easy change to support a type byte.

Copy link
Member

@lzpap lzpap left a comment

Choose a reason for hiding this comment

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

Yaay, it worked! 🎉

Total Number of Validators: 4
Total Number of Migration Objects: 4561398
Total Number of Objects/Packages: 4561441
Total Supply of Iota: 4600000000000000000 NANOS or 4600000000 IOTA
Total Amount of StakedIota: 45000000000000000 NANOS or 45000000 IOTA

@miker83z miker83z merged commit 45ad366 into develop Jan 29, 2025
39 of 40 checks passed
@miker83z miker83z deleted the vm-lang/fix-genesis-timelock-destroy branch January 29, 2025 09:01
lzpap pushed a commit that referenced this pull request Jan 29, 2025
…5028)

* fix: examine genesis checkpoint

* chore: clippy and fmt

* refactor: is_maybe to try_from

* chore: remove unused functions

* refactor: remove unwrap from func

* chore: remove unused to_bytes funcs

* chore: cargo fmt

* chore: correct spelling

* fix(genesis-inspector): consider  TimelockedStakedIota as a stake

* feat(genesis-builder): validate migration objects after build

* fix(genesis-builder): always destroy allocation objects when picked

* revert changes to pick_objects_for_allocation

* fix(iota-genesis-builder): destroy timelocks after split PTB

* fix(migration_tx_data): add timelock gas balance check

---------

Co-authored-by: nonast <29281463+nonast@users.noreply.github.com>
lzpap pushed a commit that referenced this pull request Jan 29, 2025
…5028)

* fix: examine genesis checkpoint

* chore: clippy and fmt

* refactor: is_maybe to try_from

* chore: remove unused functions

* refactor: remove unwrap from func

* chore: remove unused to_bytes funcs

* chore: cargo fmt

* chore: correct spelling

* fix(genesis-inspector): consider  TimelockedStakedIota as a stake

* feat(genesis-builder): validate migration objects after build

* fix(genesis-builder): always destroy allocation objects when picked

* revert changes to pick_objects_for_allocation

* fix(iota-genesis-builder): destroy timelocks after split PTB

* fix(migration_tx_data): add timelock gas balance check

---------

Co-authored-by: nonast <29281463+nonast@users.noreply.github.com>
lzpap added a commit that referenced this pull request Jan 29, 2025
…5028) (#5081)

* fix: examine genesis checkpoint

* chore: clippy and fmt

* refactor: is_maybe to try_from

* chore: remove unused functions

* refactor: remove unwrap from func

* chore: remove unused to_bytes funcs

* chore: cargo fmt

* chore: correct spelling

* fix(genesis-inspector): consider  TimelockedStakedIota as a stake

* feat(genesis-builder): validate migration objects after build

* fix(genesis-builder): always destroy allocation objects when picked

* revert changes to pick_objects_for_allocation

* fix(iota-genesis-builder): destroy timelocks after split PTB

* fix(migration_tx_data): add timelock gas balance check

---------

Co-authored-by: Mirko Zichichi <miker83z@proton.me>
Co-authored-by: nonast <29281463+nonast@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[genesis] Allocation does not destroy the migrated timelock/gas coin when it is a "surplus"
7 participants