Skip to content

Commit

Permalink
implement local private storage struct with witness
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvja committed Oct 25, 2024
1 parent 2c319b6 commit 6d43430
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
37 changes: 35 additions & 2 deletions hyperspace/rollup/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,11 @@ impl RollupClient {
(trie, false)
}

pub async fn get_ibc_storage(&self) -> PrivateStorage {
pub async fn get_ibc_storage(&self) -> PrivateStorageWithWitness {
let program = self.program();
let ibc_storage_key = self.get_ibc_storage_key();
let storage: PrivateStorage = program.account(ibc_storage_key).await.unwrap();
let mut account_data = self.rpc_client().get_account_data(&ibc_storage_key).await.unwrap();
let storage: PrivateStorageWithWitness = PrivateStorageWithWitness::deserialize(&mut &account_data[8..]).unwrap();
// let storage = tokio::task::spawn_blocking(move || {
// program.account(ibc_storage_key).unwrap()
// }).await.unwrap();
Expand Down Expand Up @@ -1253,3 +1254,35 @@ pub async fn get_accounts(
// let tx = sol_rpc_client.get_transaction(&signature, UiTransactionEncoding::Json).unwrap();
// println!("This is tx {:?}", tx);
// }

#[derive(Debug, borsh::BorshSerialize, borsh::BorshDeserialize)]
/// The private IBC storage, i.e. data which doesn’t require proofs.
pub struct PrivateStorageWithWitness {
/// Per-client information.
///
/// Entry at index `N` corresponds to the client with IBC identifier
/// `client-<N>`.
pub clients: Vec<solana_ibc::storage::ClientStore>,

/// Information about the counterparty on given connection.
///
/// Entry at index `N` corresponds to the connection with IBC identifier
/// `connection-<N>`.
pub connections: Vec<solana_ibc::storage::Serialised<ibc_core_connection_types::ConnectionEnd>>,

/// Information about a each `(port, channel)` endpoint.
pub port_channel: solana_ibc::storage::map::Map<trie_ids::PortChannelPK, solana_ibc::storage::PortChannelStore>,

pub channel_counter: u32,

pub fee_collector: Pubkey,

pub new_fee_collector_proposal: Option<Pubkey>,

pub assets: solana_ibc::storage::map::Map<CryptoHash, solana_ibc::storage::Asset>,

// Fee to be charged for each transfer
pub fee_in_lamports: u64,

pub local_consensus_state: std::collections::VecDeque<(u64, u64, CryptoHash)>,
}
4 changes: 2 additions & 2 deletions hyperspace/rollup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1821,8 +1821,8 @@ impl Chain for RollupClient {
let client = PubsubClient::new(&ws_url).await.unwrap();
let (mut stream, _receiver) = client
.block_subscribe(
RpcBlockSubscribeFilter::All,
// RpcBlockSubscribeFilter::MentionsAccountOrProgram(program_id.to_string()),
// RpcBlockSubscribeFilter::All,
RpcBlockSubscribeFilter::MentionsAccountOrProgram(program_id.to_string()),
Some(RpcBlockSubscribeConfig {
commitment: Some(CommitmentConfig::finalized()),
..Default::default()
Expand Down
26 changes: 13 additions & 13 deletions hyperspace/testsuite/tests/solana_rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ pub struct Args {
impl Default for Args {
fn default() -> Self {
let solana = std::env::var("SOLANA_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
let rollup = std::env::var("ROLLUP_HOST").unwrap_or_else(|_| "34.140.169.227".to_string());
let rollup = std::env::var("ROLLUP_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());

Args {
// chain_a: format!("https://devnet.helius-rpc.com/?api-key=bc5c0cfc-46df-4781-978f-af6ca7a202c2"),
// chain_a: format!("http://{solana}:9000"),
chain_a: format!("https://devnet.helius-rpc.com/?api-key=5ae782d8-6bf6-489c-b6df-ef7e6289e193"),
// chain_b: format!("http://{rollup}:8899"),
chain_b: format!("https://mantis-rollup.composable-shared-artifacts.composablenodes.tech/rpc"),
chain_a: format!("http://{solana}:9000"),
// chain_a: format!("https://devnet.helius-rpc.com/?api-key=5ae782d8-6bf6-489c-b6df-ef7e6289e193"),
chain_b: format!("http://{rollup}:8899"),
// chain_b: format!("https://mantis-rollup.composable-shared-artifacts.composablenodes.tech/rpc"),
connection_prefix_a: "ibc".to_string(),
connection_prefix_b: "ibc".to_string(),
// solana_ws: format!("ws://{solana}:9001"),
solana_ws: format!("wss://devnet.helius-rpc.com/?api-key=5ae782d8-6bf6-489c-b6df-ef7e6289e193"),
solana_ws: format!("ws://{solana}:9001"),
// solana_ws: format!("wss://devnet.helius-rpc.com/?api-key=5ae782d8-6bf6-489c-b6df-ef7e6289e193"),
// solana_ws:
// format!("wss://devnet.helius-rpc.com/?api-key=bc5c0cfc-46df-4781-978f-af6ca7a202c2"),
// rollup_ws: format!("ws://{rollup}:8900"),
rollup_ws: format!("wss://mantis-rollup.composable-shared-artifacts.composablenodes.tech/ws"),
rollup_ws: format!("ws://{rollup}:8900"),
// rollup_ws: format!("wss://mantis-rollup.composable-shared-artifacts.composablenodes.tech/ws"),
// rollup_ws: format!("ws://{solana}:8900"),
// rollup_trie_db_rpc: format!("http://{rollup}:42069")
rollup_trie_db_rpc: format!("http://{rollup}:42069")
Expand All @@ -82,7 +82,7 @@ async fn setup_clients() -> (AnyChain, AnyChain) {
name: "solana".to_string(),
client_id: None,
connection_id: None,
commitment_prefix: args.connection_prefix_a.clone().as_bytes().to_vec(),
commitment_prefix: args.connection_prefix_a.clone().into_bytes(),
wasm_checksum: None,
rpc_url: args.chain_a.clone().parse().unwrap(),
ws_url: args.solana_ws.clone().parse().unwrap(),
Expand All @@ -107,8 +107,8 @@ async fn setup_clients() -> (AnyChain, AnyChain) {
153, 230, 192, 225, 51, 119, 216, 14, 69, 225, 73, 7, 204, 144, 39, 213, 91, 255, 136,
38, 95, 131, 197, 4, 101, 186,
],
solana_ibc_program_id: "8o54PU8EcKtf4AqkFfqNhCWBqwpvFki64WEVNWAUP84c".to_string(),
write_program_id: "9tjGWBMR6u6mBzEiW7j6A72KyxzEmcEsW3oV7ijBLmFb".to_string(),
solana_ibc_program_id: "2HLLVco5HvwWriNbUhmVwA2pCetRkpgrqwnjcsZdyTKT".to_string(),
write_program_id: "FufGpHqMQgGVjtMH9AV8YMrJYq8zaK6USRsJkZP4yDjo".to_string(),
signature_verifier_program_id: "C6r1VEbn3mSpecgrZ7NdBvWUtYVJWrDPv4uU9Xs956gc".to_string(),
trie_db_path: "../../../solana-ibc-indexer/indexer.db3".to_string(),
transaction_sender: "RPC".to_string(),
Expand All @@ -118,7 +118,7 @@ async fn setup_clients() -> (AnyChain, AnyChain) {
name: "mantis".to_string(),
client_id: None,
connection_id: None,
commitment_prefix: args.connection_prefix_b.as_bytes().to_vec(),
commitment_prefix: args.connection_prefix_a.clone().into_bytes(),
wasm_checksum: None,
rpc_url: args.chain_b.clone().parse().unwrap(),
ws_url: args.rollup_ws.clone().parse().unwrap(),
Expand Down

0 comments on commit 6d43430

Please sign in to comment.