Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5828ff1
Update ics23 crate
vmarkushin May 15, 2023
6b52358
revert removing proof.rs
vmarkushin May 15, 2023
ee31170
More cosmos fixes
vmarkushin May 16, 2023
e1a3e42
Fix cosmos::query_connection_channels, make channel_whitelist a set, …
vmarkushin May 17, 2023
03a774f
Trying to fix everything
vmarkushin May 19, 2023
f03d212
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 6, 2023
f6c7894
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 6, 2023
d0638ab
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 6, 2023
b74fd9b
Fix timeout underflow
vmarkushin Jun 16, 2023
3c23340
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 16, 2023
c28299c
Submit missing packets when skipping updates
vmarkushin Jun 17, 2023
06e9e83
build docker image for the branch
vmarkushin Jun 17, 2023
55030e3
do not panic on mismatch between number of events and updates
vmarkushin Jun 17, 2023
f83a37f
Fix submitting undelivered sequences, optimize proof query, altering …
vmarkushin Jun 18, 2023
c091407
Optimize finality notifications streams
vmarkushin Jun 18, 2023
4e31334
add a log for delay
vmarkushin Jun 18, 2023
a0fb46b
fix stuck on query light block
vmarkushin Jun 19, 2023
d8fe8cc
refactor process_finality_event macro
vmarkushin Jun 19, 2023
7c6ed1d
clean up
vmarkushin Jun 19, 2023
1b17f12
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 19, 2023
1b9f704
clean up
vmarkushin Jun 19, 2023
69eddce
fix tests
vmarkushin Jun 19, 2023
ebb61d4
Add more logs
vmarkushin Jun 19, 2023
1af7ed1
undo proof search optimization
vmarkushin Jun 20, 2023
a9f362e
Merge branch 'master' into vmarkushin/cosmos-skip-client-updates
vmarkushin Jun 22, 2023
5f224fe
fix errors
vmarkushin Jun 22, 2023
2522b4b
change ci
vmarkushin Jun 22, 2023
ee2c582
fix connection to websocket
vmarkushin Jun 22, 2023
0ab40d9
Revert "oak-audit: fix issues 2 and 12; and fix misbehaviour check (#…
blasrodri Jun 22, 2023
4844ed1
compilation and publish
blasrodri Jun 22, 2023
498b071
be more nice to the cosmos node
vmarkushin Jun 23, 2023
024447c
optimize stuff
vmarkushin Jun 23, 2023
01a2e20
fix errors
vmarkushin Jun 23, 2023
81a9e81
fix query timeout proof
vmarkushin Jun 24, 2023
04e5695
fix query packets
vmarkushin Jun 25, 2023
14e5199
ignore already handled sequences in queries
vmarkushin Jun 25, 2023
f5df8b9
fix query_send_packets for cosmos
vmarkushin Jun 25, 2023
723e688
More granular filtering in connection & channel creation
vmarkushin Jun 25, 2023
bb2fd43
refactor event filtering
vmarkushin Jun 26, 2023
5c3413c
add a comment
vmarkushin Jun 26, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/hyperspace-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- main

jobs:
build-and-publish:
Expand Down
47 changes: 21 additions & 26 deletions Cargo.lock

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

27 changes: 0 additions & 27 deletions algorithms/grandpa/primitives/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,33 +257,6 @@ where
Ok(())
}

/// The function checks if the given chain is canonical:
/// - the chain is not empty
/// - all the header hashes from `base_header` to `header.last()` form a chain
/// - height of the blocks increase sequentially by 1
/// And returns the first and last hashes of the chain
pub fn validate_chain<H: HeaderT>(
mut base_header_hash: H::Hash,
mut base_header_number: H::Number,
headers: &[H],
) -> Result<(&H, &H), anyhow::Error> {
if headers.is_empty() {
return Err(anyhow!("Empty chain"))
}
for header in headers {
if base_header_number + 1u32.into() != *header.number() {
return Err(anyhow!("Invalid block number in the chain"))
}
let current_hash = base_header_hash;
if header.parent_hash() != &current_hash {
return Err(anyhow!("Invalid block hash in the chain"))
}
base_header_hash = header.hash();
base_header_number = *header.number();
}
Ok(headers.first().zip(headers.last()).expect("headers are not empty; qed"))
}

/// Verifies the equivocation proof by making sure that both votes target
/// different blocks and that its signatures are valid.
pub fn check_equivocation_proof<Host, H, N>(
Expand Down
5 changes: 2 additions & 3 deletions algorithms/grandpa/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ pub trait HostFunctions: light_client_common::HostFunctions + 'static {

/// Verify an ed25519 signature
fn ed25519_verify(sig: &ed25519::Signature, msg: &[u8], pub_key: &ed25519::Public) -> bool;
/// Stores the given list of RelayChain header hashes in the light client's storage with
/// the given timestamp.
fn insert_relay_header_hashes(now_ms: u64, headers: &[<Self::Header as Header>::Hash]);
/// Stores the given list of RelayChain header hashes in the light client's storage.
fn insert_relay_header_hashes(headers: &[<Self::Header as Header>::Hash]);
/// Checks if a RelayChain header hash exists in the light client's storage.
fn contains_relay_header_hash(hash: <Self::Header as Header>::Hash) -> bool;
}
Expand Down
2 changes: 1 addition & 1 deletion algorithms/grandpa/prover/src/host_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl HostFunctions for HostFunctionsProvider {
pubkey.verify(&msg, sig)
}

fn insert_relay_header_hashes(_now: u64, _headers: &[<Self::Header as Header>::Hash]) {
fn insert_relay_header_hashes(_headers: &[<Self::Header as Header>::Hash]) {
unimplemented!()
}

Expand Down
10 changes: 4 additions & 6 deletions algorithms/grandpa/verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,16 @@ where
proof;

// 1. First validate unknown headers.
let headers = AncestryChain::new(&finality_proof.unknown_headers);
let headers = AncestryChain::<H>::new(&finality_proof.unknown_headers);

let target = finality_proof
.unknown_headers
.iter()
.max_by_key(|h| *h.number())
.ok_or_else(|| anyhow!("Unknown headers can't be empty!"))?;

let target_hash = target.hash();

// this is illegal
if target_hash != finality_proof.block {
if target.hash() != finality_proof.block {
Err(anyhow!("Latest finalized block should be highest block in unknown_headers"))?;
}

Expand All @@ -95,7 +93,7 @@ where
})?;
}

let mut finalized = headers.ancestry(from, target_hash).map_err(|_| {
let mut finalized = headers.ancestry(from, target.hash()).map_err(|_| {
anyhow!("[verify_parachain_headers_with_grandpa_finality_proof] Invalid ancestry!")
})?;
finalized.sort();
Expand Down Expand Up @@ -141,7 +139,7 @@ where
}

// 4. set new client state, optionally rotating authorities
client_state.latest_relay_hash = target_hash;
client_state.latest_relay_hash = target.hash();
client_state.latest_relay_height = (*target.number()).into();
if let Some(max_height) = para_heights.into_iter().max() {
if max_height != latest_para_height {
Expand Down
4 changes: 2 additions & 2 deletions config/rococo-local-local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ para_id = 2000
parachain_rpc_url = "ws://127.0.0.1:9188"
relay_chain_rpc_url = "ws://127.0.0.1:9944"
client_id = "08-wasm-0"
connection_id = "connection-0"
connection_id = "connection-2"
commitment_prefix = "0x6962632f"
private_key = "//Alice"
ss58_version = 49
channel_whitelist = [["channel-0", "transfer"], ["channel-0", "transfer"], ["channel-0", "transfer"], ["channel-0", "transfer"], ["channel-0", "transfer"], ["channel-0", "transfer"]]
channel_whitelist = [["channel-2", "transfer"]]
finality_protocol = "Grandpa"
key_type = "sr25519"
1 change: 0 additions & 1 deletion contracts/pallet-ibc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ ibc-proto = { path = "../../ibc/proto", default-features = false }
tendermint = { git = "https://github.com/informalsystems/tendermint-rs", rev = "e81f7bf23d63ffbcd242381d1ce5e35da3515ff1", default-features = false } # cannot be defined as optional in workspace
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", rev = "e81f7bf23d63ffbcd242381d1ce5e35da3515ff1", default-features = false }
ics23 = { git = "https://github.com/cosmos/ics23", rev = "74ce807b7be39a7e0afb4e2efb8e28a57965f57b", default-features = false }
vec1 = { version = "1.10.1", default-features = false }

grandpa-client-primitives = { package = "grandpa-light-client-primitives", path = "../../algorithms/grandpa/primitives", default-features = false }
beefy-client-primitives = { package = "beefy-light-client-primitives", path = "../../algorithms/beefy/primitives", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion contracts/pallet-ibc/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct Proof {
}

/// Packet info
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize, Debug)]
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize, Debug, PartialOrd, Ord)]
pub struct PacketInfo {
/// Minimal height at which packet proof is available
pub height: Option<u64>,
Expand Down
11 changes: 3 additions & 8 deletions contracts/pallet-ibc/src/benchmarks/grandpa_benchmark_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ use grandpa_client_primitives::{
use ibc::{timestamp::Timestamp, Height};
use ics10_grandpa::{
client_message::{ClientMessage, Header as GrandpaHeader, RelayChainHeader},
client_state::{AuthoritiesChange, ClientState},
client_state::ClientState,
consensus_state::ConsensusState,
};
use sp_core::H256;
use sp_finality_grandpa::{AuthorityId, AuthoritySignature, KEY_TYPE};
use sp_runtime::{traits::BlakeTwo256, SaturatedConversion};
use sp_std::prelude::*;
use sp_trie::{generate_trie_proof, LayoutV0, MemoryDB, StorageProof, TrieDBMutBuilder, TrieMut};
use vec1::vec1;

pub const GRANDPA_UPDATE_TIMESTAMP: u64 = 1650894363;
/// Builds a grandpa client message that that contains the requested number of precommits
Expand Down Expand Up @@ -157,12 +156,8 @@ pub fn generate_finality_proof(
frozen_height: None,
latest_para_height,
para_id,
authorities_changes: vec1![AuthoritiesChange {
set_id,
authorities: authorities.into_iter().map(|authority| (authority, 100)).collect(),
height: 0,
timestamp: Timestamp::from_nanoseconds(1).unwrap(),
}],
current_set_id: set_id,
current_authorities: authorities.into_iter().map(|authority| (authority, 100)).collect(),
_phantom: Default::default(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ use ibc_proto::{cosmos::ics23::v1::CommitmentProof, ibc::core::commitment::v1::M
use ics07_tendermint::{
client_state::ClientState as TendermintClientState, consensus_state::ConsensusState,
};
use ics10_grandpa::client_state::AuthoritiesChange;
use ics11_beefy::{
client_state::ClientState as BeefyClientState,
consensus_state::ConsensusState as BeefyConsensusState,
Expand All @@ -69,7 +68,6 @@ use tendermint::{
};
use tendermint_light_client_verifier::types::Validator;
use tendermint_proto::Protobuf;
use vec1::vec1;

pub const TENDERMINT_TIMESTAMP: u64 = 1650894363;

Expand Down Expand Up @@ -319,12 +317,8 @@ pub(crate) fn create_mock_grandpa_client_state() -> (
frozen_height: None,
latest_para_height: 0,
para_id: 2087,
authorities_changes: vec1![AuthoritiesChange {
height: 0,
timestamp: Timestamp::from_nanoseconds(1).unwrap(),
set_id: 0,
authorities: vec![],
}],
current_set_id: 0,
current_authorities: vec![],
_phantom: Default::default(),
};

Expand Down
Loading