Skip to content

Adjustments of loader-v4 (part 3)#2821

Merged
Lichtso merged 2 commits into
anza-xyz:masterfrom
Lichtso:refactor/loader-v4
Sep 5, 2024
Merged

Adjustments of loader-v4 (part 3)#2821
Lichtso merged 2 commits into
anza-xyz:masterfrom
Lichtso:refactor/loader-v4

Conversation

@Lichtso
Copy link
Copy Markdown

@Lichtso Lichtso commented Sep 3, 2024

Problem

Continuation of #2750.

Summary of Changes

  • Removes load_and_finalize_program() and load_program() in loader utils.
  • Adds instructions_to_load_program_of_loader_v4() and load_program_of_loader_v4() to loader utils.
  • Fixes incorrect program runtime environment in deployment verification check.
  • Introduces minimum of 1 lamport to avoid program account from being deleted if rent is disabled.

@mergify
Copy link
Copy Markdown

mergify Bot commented Sep 3, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@Lichtso Lichtso requested a review from pgarg66 September 3, 2024 17:56
Comment thread runtime/src/loader_utils.rs Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Was this function unused?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes they were for the loaders-v1 and v2, which we deprecated.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So these are pure deletion of the code. The new functions are not related to these.
(trying to avoid comparing two independent functions).

Copy link
Copy Markdown
Author

@Lichtso Lichtso Sep 4, 2024

Choose a reason for hiding this comment

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

Yes, implementation / code wise they are unrelated. Conceptually they are related because these are their replacements but for the newest loader. However, loader-v4 is closest to loader-v3 so comparing the new functions against load_upgradeable_program_and_advance_slot() makes more sense.

Comment thread runtime/src/loader_utils.rs Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some documentation will be helpful here, as to why we are doing signers[index.min(signers.len() - 1)]. I am able to understand it right now, but may not be obvious for the future maintainers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I reimplemented it using iterators instead of indices, hopefully that makes it self explanatory.

Comment thread programs/loader-v4/src/lib.rs Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we split this in its own PR?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This should have been in #2750 already but I missed it. Only noticed as I was working on the tests in #2796.

@pgarg66
Copy link
Copy Markdown

pgarg66 commented Sep 4, 2024

The code looks good to me. Can we add some tests?

@Lichtso
Copy link
Copy Markdown
Author

Lichtso commented Sep 5, 2024

Can we add some tests?

The tests will come in #2796. However we can't merge that until #2182, which depends on SIMD-0162.

…loader_v4().

Removes load_and_finalize_program() and load_program().
@Lichtso Lichtso marked this pull request as ready for review September 5, 2024 18:17
@Lichtso Lichtso merged commit 7f2013d into anza-xyz:master Sep 5, 2024
@Lichtso Lichtso deleted the refactor/loader-v4 branch September 5, 2024 18:18
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
* Fixes two bugs in loader-v4.

* Adds instructions_to_load_program_of_loader_v4() and load_program_of_loader_v4().
Removes load_and_finalize_program() and load_program().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants