-
Notifications
You must be signed in to change notification settings - Fork 317
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(ibc): remove dependency on penumbra-chain specific state keys #3528
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ab4ab20
refactor to use ChainStateReadExt for penumbra_chain fns
noot f847dad
implement StateDelta wrapper in app + tests which implements ChainSta…
noot bdab9de
fmt
noot 7a328af
add derive macros for StateRead and StateWrite
noot f1e3e03
improve derive macros to work with arc
noot 6bb289b
cleanup
noot 1a1e66c
macro cleanup
noot cba4382
update ibc rpc to take a generic storage that returns a snapshot impl…
noot 4c2eaa2
Merge branch 'main' of https://github.com/penumbra-zone/penumbra into…
noot c195abd
merge
noot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use anyhow::Result; | ||
use cnidarium::StateRead; | ||
use cnidarium::Storage; | ||
use cnidarium_component::ChainStateReadExt; | ||
use ibc_types::core::commitment::MerkleProof; | ||
// implemented by [`SnapshotWrapper`] | ||
use penumbra_chain::component::StateReadExt as _; | ||
|
||
#[derive(wrapper_derive::StateRead, wrapper_derive::ChainStateReadExt, Clone)] | ||
pub struct SnapshotWrapper<S: StateRead>(S); | ||
|
||
#[async_trait::async_trait] | ||
impl penumbra_ibc::component::rpc::Snapshot for SnapshotWrapper<cnidarium::Snapshot> { | ||
fn version(&self) -> u64 { | ||
self.0.version() | ||
} | ||
|
||
async fn get_with_proof(&self, key: Vec<u8>) -> Result<(Option<Vec<u8>>, MerkleProof)> { | ||
self.0.get_with_proof(key).await | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct StorageWrapper(pub Storage); | ||
|
||
impl penumbra_ibc::component::rpc::Storage<SnapshotWrapper<cnidarium::Snapshot>> | ||
for StorageWrapper | ||
{ | ||
fn latest_snapshot(&self) -> SnapshotWrapper<cnidarium::Snapshot> { | ||
SnapshotWrapper(self.0.latest_snapshot()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use cnidarium::StateRead; | ||
|
||
#[async_trait] | ||
pub trait ChainStateReadExt: StateRead { | ||
async fn get_chain_id(&self) -> Result<String>; | ||
async fn get_revision_number(&self) -> Result<u64>; | ||
async fn get_block_height(&self) -> Result<u64>; | ||
async fn get_block_timestamp(&self) -> Result<tendermint::Time>; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use anyhow::Result; | ||
use cnidarium::StateRead; | ||
use cnidarium::StateWrite; | ||
use cnidarium_component::ChainStateReadExt; | ||
use penumbra_chain::component::StateReadExt; | ||
|
||
#[derive( | ||
wrapper_derive::StateRead, wrapper_derive::StateWrite, wrapper_derive::ChainStateReadExt, | ||
)] | ||
pub(crate) struct StateDeltaWrapper<'a, S: StateRead + StateWrite>(pub(crate) &'a mut S); | ||
|
||
#[derive( | ||
wrapper_derive::StateRead, wrapper_derive::StateWrite, wrapper_derive::ChainStateReadExt, | ||
)] | ||
pub(crate) struct ArcStateDeltaWrapper<'a, S: StateRead + StateWrite>( | ||
pub(crate) &'a mut std::sync::Arc<S>, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should go in
cnidarium-component
, since this is really an IBC host chain interface, that should be named as such and go in the ibc crate, right?