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

Ensure that hashing across account data and resize area works #3889

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

seanyoung
Copy link

Problem

The account data and resize area are separate regions with direct mapping. So, ensure that hashing data across it works.

Copy link

mergify bot commented Dec 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.

@seanyoung seanyoung force-pushed the hashers branch 2 times, most recently from d5f28a1 to 0434fc2 Compare December 3, 2024 21:12
@seanyoung seanyoung marked this pull request as ready for review December 4, 2024 09:23
@seanyoung seanyoung requested a review from a team as a code owner December 4, 2024 09:23
for item in chunk_iter {
let (region, src_addr, chunk_len) = item?;

let addr = Result::from(region.vm_to_host(src_addr, chunk_len as u64))?;
Copy link

Choose a reason for hiding this comment

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

BTW, why do we do the translation at the callsite and not have it in the iterator?

Copy link
Author

Choose a reason for hiding this comment

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

In fn iter_memory_pair_chunks() we may want to iterate in reverse, in which case we want to use the last address in the chunk rather than the first.

We could have an fn iter_memory_chunks() which does this.

n_bytes: u64,
accounts: &[SerializedAccountMetadata],
memory_mapping: &MemoryMapping,
mut fun: F,
Copy link

Choose a reason for hiding this comment

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

This could be a &mut dyn FnMut, instead of a generic.

Copy link
Author

Choose a reason for hiding this comment

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

Do we really want &mut dyn FnMut?

  • It's such a short function, code bloat shouldn't be an issue (I think)
  • fn iter_memory_pair_chunks() is also generic (so then both should be changed)

generic is "better inlining and optimization, but larger code" and dyn is "shorter slower code, indirect calling is expensive and fewer optimizations possible".

wdty?

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