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

refactor: zero copy vec #1469

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ on:
branches:
- main
paths:
- ".cargo/**"
- ".cargo/**"
- "programs/**"
- "program-libs/**"
- "sdk-libs/**"
- "**/*.rs"
- "**/Cargo.*"
- "prover/server/**"
- "prover/client/**"
- ".github/workflows/rust.yml"
pull_request:
branches:
- "*"
paths:
- ".cargo/**"
- "programs/**"
- "program-libs/**"
- "sdk-libs/**"
- "**/*.rs"
- "**/Cargo.*"
- "prover/server/**"
- "prover/client/**"
- ".github/workflows/rust.yml"

types:
Expand All @@ -33,8 +40,6 @@ jobs:
test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
container:
options: --memory=4g
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
33 changes: 30 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ bytemuck = { version = "1.17" }
# Math and crypto
num-bigint = "0.4.6"
num-traits = "0.2.19"
zerocopy = { version = "0.8.14"}

# HTTP client
reqwest = "0.11.26"
Expand Down
18 changes: 9 additions & 9 deletions forester-utils/src/address_merkle_tree_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use account_compression::{
QueueAccount, StateMerkleTreeAccount, StateMerkleTreeConfig,
};
use anchor_lang::Discriminator;
use light_batched_merkle_tree::merkle_tree::BatchedMerkleTreeMetadata;
use light_batched_merkle_tree::merkle_tree::BatchedMerkleTreeAccount;
use light_client::rpc::RpcConnection;
use light_hasher::{Discriminator as LightDiscriminator, Poseidon};
use num_traits::Zero;
Expand Down Expand Up @@ -151,7 +151,7 @@ pub async fn state_tree_ready_for_rollover<R: RpcConnection>(
rpc: &mut R,
merkle_tree: Pubkey,
) -> bool {
let account = rpc.get_account(merkle_tree).await.unwrap().unwrap();
let mut account = rpc.get_account(merkle_tree).await.unwrap().unwrap();
let rent_exemption = rpc
.get_minimum_balance_for_rent_exemption(account.data.len())
.await
Expand All @@ -169,15 +169,15 @@ pub async fn state_tree_ready_for_rollover<R: RpcConnection>(
.await;
(tree.next_index(), tree_meta_data, 26)
}
BatchedMerkleTreeMetadata::DISCRIMINATOR => {
let account = AccountZeroCopy::<BatchedMerkleTreeMetadata>::new(rpc, merkle_tree).await;

let tree_meta_data = account.deserialized();
BatchedMerkleTreeAccount::DISCRIMINATOR => {
let tree_meta_data =
BatchedMerkleTreeAccount::state_tree_from_bytes_mut(account.data.as_mut_slice())
.unwrap();

(
tree_meta_data.next_index as usize,
tree_meta_data.metadata,
tree_meta_data.height,
tree_meta_data.get_metadata().next_index as usize,
tree_meta_data.get_metadata().metadata,
tree_meta_data.get_metadata().height,
)
}
_ => panic!("Invalid discriminator"),
Expand Down
2 changes: 1 addition & 1 deletion forester/src/rollover/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub async fn get_tree_fullness<R: RpcConnection>(
.await?
.unwrap();
let queue_account = rpc
.get_anchor_account::<QueueAccount>(&account.metadata.associated_queue)
.get_anchor_account::<QueueAccount>(&account.metadata.associated_queue.into())
.await?
.unwrap();
let merkle_tree =
Expand Down
2 changes: 1 addition & 1 deletion forester/src/tree_data_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn create_tree_accounts(
) -> TreeAccounts {
let tree_accounts = TreeAccounts::new(
pubkey,
metadata.associated_queue,
metadata.associated_queue.into(),
tree_type,
metadata.rollover_metadata.rolledover_slot != u64::MAX,
);
Expand Down
6 changes: 1 addition & 5 deletions js/compressed-token/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,4 @@ const typesConfig = {
plugins: [dts()],
};

export default [
rolls('cjs', 'browser'),
rolls('cjs', 'node'),
typesConfig,
];
export default [rolls('cjs', 'browser'), rolls('cjs', 'node'), typesConfig];
Loading
Loading