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

flamenco, vm: correctly set check_align in vm #2831

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

topointon-jump
Copy link
Contributor

@topointon-jump topointon-jump commented Aug 30, 2024

Correctly set check_align in the vm based on if the deprecated loader is used.

Also correctly sets alignment values for all the memory address translations in the vm.

Copy link
Contributor

@ibhatt-jumptrading ibhatt-jumptrading left a comment

Choose a reason for hiding this comment

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

lgtm

@topointon-jump topointon-jump added this pull request to the merge queue Sep 17, 2024
@@ -171,8 +171,7 @@ VM_SYCALL_CPI_UPDATE_CALLEE_ACC_FUNC( fd_vm_t * vm,
/* FIXME: double-check these permissions, especially the callee_acc_idx */

/* Translate and get the account data */
uchar const * caller_acc_data = FD_VM_MEM_HADDR_LD( vm, caller_acc_data_vm_addr,
sizeof(ulong), caller_acc_data_len );
uchar const * caller_acc_data = FD_VM_MEM_HADDR_LD( vm, caller_acc_data_vm_addr, sizeof(uchar), caller_acc_data_len );
Copy link
Contributor

Choose a reason for hiding this comment

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

align of, or better RUST_U8

@@ -237,7 +236,7 @@ VM_SYCALL_CPI_UPDATE_CALLEE_ACC_FUNC( fd_vm_t * vm,
smartly look up the right region and don't need to worry about
multiple region access.We just need to load in the bytes from
(original len, post_len]. */
uchar const * realloc_data = FD_VM_MEM_HADDR_LD( vm, caller_acc_data_vm_addr+original_len, alignof(ulong), realloc_bytes_used );
uchar const * realloc_data = FD_VM_MEM_HADDR_LD( vm, caller_acc_data_vm_addr+original_len, alignof(uchar), realloc_bytes_used );
Copy link
Contributor

Choose a reason for hiding this comment

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

FD_VM_ALIGN_RUST_U8

@@ -124,8 +124,8 @@ fd_vm_syscall_sol_create_program_address( /**/ void * _vm,
return FD_VM_SUCCESS;
}

fd_pubkey_t * out_haddr = FD_VM_MEM_HADDR_ST( vm, out_vaddr, FD_VM_ALIGN_RUST_PUBKEY, sizeof(fd_pubkey_t) );
memcpy( out_haddr, derived->uc, sizeof(fd_pubkey_t) );
fd_pubkey_t * out_haddr = FD_VM_MEM_HADDR_ST( vm, out_vaddr, FD_VM_ALIGN_RUST_U8, FD_PUBKEY_FOOTPRINT );
Copy link
Contributor

Choose a reason for hiding this comment

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

FD_VM_ALIGN_RUST_PUBKEY

@@ -174,7 +174,7 @@ fd_vm_syscall_sol_try_find_program_address( void * _vm,
int err = fd_vm_derive_pda( vm, program_id, seeds_vaddr, seeds_cnt, bump_seed, derived );
if ( FD_LIKELY( err == FD_VM_SUCCESS ) ) {
/* Stop looking if we have found a valid PDA */
fd_pubkey_t * out_haddr = FD_VM_MEM_HADDR_ST( vm, out_vaddr, FD_VM_ALIGN_RUST_PUBKEY, sizeof(fd_pubkey_t) );
fd_pubkey_t * out_haddr = FD_VM_MEM_HADDR_ST( vm, out_vaddr, FD_VM_ALIGN_RUST_U8, sizeof(fd_pubkey_t) );
Copy link
Contributor

Choose a reason for hiding this comment

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

FD_VM_ALIGN_RUST_PUBKEY, FD_PUBKEY_FOOTPRINT

Merged via the queue into main with commit f55c236 Sep 17, 2024
11 checks passed
@topointon-jump topointon-jump deleted the topointon/check_align_check_size branch September 17, 2024 07:37
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.

3 participants