Skip to content

Commit

Permalink
solana-ibc: remove connection id from client store (#131)
Browse files Browse the repository at this point in the history
Connections can be fetched from client ids by traversing through the
connections array. There is no need of storing the connection ids
again in the client_store present in the private storage.

* removed storing connection ids in client store

* fmt

* Update solana/solana-ibc/programs/solana-ibc/src/execution_context.rs

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

* Update solana/solana-ibc/programs/solana-ibc/src/execution_context.rs

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
  • Loading branch information
dhruvja and mina86 authored Nov 28, 2023
1 parent 91c4f63 commit 4f5e5d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 9 additions & 4 deletions solana/solana-ibc/programs/solana-ibc/src/execution_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,23 @@ impl ibc::ExecutionContext for IbcStorage<'_, '_, '_> {
Ok(())
}

/// Does nothing in the current implementation.
///
/// Connections are stored in a vector with client id which can be traversed
/// to fetch connections from client_id or vice versa (using client store).
#[allow(unused_variables)]
fn store_connection_to_client(
&mut self,
path: &ibc::path::ClientConnectionPath,
conn_id: ibc::ConnectionId,
) -> Result {
msg!("store_connection_to_client({}, {:?})", path, conn_id);
let conn_id = ids::ConnectionIdx::try_from(&conn_id)?;
self.borrow_mut().private.client_mut(&path.0, false)?.connection_id =
Some(conn_id);
Ok(())
}

/// Does nothing in the current implementation.
///
/// Connections are stored in a vector in an order, so the length of the
/// array specifies the number of connections.
fn increase_connection_counter(&mut self) -> Result { Ok(()) }

fn store_packet_commitment(
Expand Down
2 changes: 0 additions & 2 deletions solana/solana-ibc/programs/solana-ibc/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ impl SequenceTriple {
#[derive(Clone, Debug, borsh::BorshSerialize, borsh::BorshDeserialize)]
pub struct ClientStore {
pub client_id: ibc::ClientId,
pub connection_id: Option<ids::ConnectionIdx>,

pub client_state: Serialised<AnyClientState>,
pub consensus_states: BTreeMap<ibc::Height, Serialised<AnyConsensusState>>,
Expand All @@ -86,7 +85,6 @@ impl ClientStore {
fn new(client_id: ibc::ClientId) -> Self {
Self {
client_id,
connection_id: Default::default(),
client_state: Serialised::empty(),
consensus_states: Default::default(),
processed_times: Default::default(),
Expand Down

0 comments on commit 4f5e5d4

Please sign in to comment.