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

add support for different finality gadgets #1057

Draft
wants to merge 15 commits into
base: feat-substrate
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ docs/
data/
scripts/
testnets/
two-chains/
two-chains/
go-export/target
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ build-akash-docker:
build-osmosis-docker:
docker build -t osmosis-labs/osmosis:$(OSMOSIS_VERSION) --build-arg VERSION=$(OSMOSIS_VERSION) -f ./docker/osmosis/Dockerfile .

build-trie-lib-docker:
docker run -it -v $(CURDIR)/go-export:/proj -v $(CURDIR)/scripts:/scripts rust:alpine sh scripts/build_trie_docker.sh

build-trie-lib:
cd go-export
cargo +nightly build -r -p go-export
cp target/release/*.a ../lib/
cp target/release/*.d ../lib/
cp target/.h ../lib/

test-trie-lib:
cd go-export
cargo +nightly miri test -p go-export

###############################################################################
# Tests / CI
###############################################################################
Expand Down
8 changes: 5 additions & 3 deletions cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -111,9 +111,11 @@ $ %s k r cosmoshub faucet-key "[mnemonic-words]"`, appName, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
keyName := args[1]

chain, ok := a.Config.Chains[args[0]]
chainName := args[0]
fmt.Println("Restoring key for chain", chainName)
chain, ok := a.Config.Chains[chainName]
if !ok {
return errChainNotFound(args[0])
return errChainNotFound(chainName)
}

if chain.ChainProvider.KeyExists(keyName) {
Expand Down
23 changes: 23 additions & 0 deletions go-export/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "go-export"
version = "0.1.0"
edition = "2021"
build = "build.rs"

[lib]
crate-type = ["cdylib", "staticlib"]

[dependencies]
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
light-client-common = { git = "https://github.com/ComposableFi/centauri", branch = "master" }

[dev-dependencies]
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
hex-literal = "0.3.4"
hex = "0.4.3"
rand = "0.8.5"

[build-dependencies]
cbindgen = "0.24.3"
35 changes: 35 additions & 0 deletions go-export/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
extern crate cbindgen;

use cbindgen::{Config, Language};
use std::{env, path::PathBuf};

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

let package_name = env::var("CARGO_PKG_NAME").unwrap();
let output_file = target_dir()
.join(format!("{}.h", package_name))
.display()
.to_string();

let config = Config {
namespace: Some(String::from("ffi")),
language: Language::C,
..Default::default()
};

cbindgen::generate_with_config(&crate_dir, config)
.unwrap()
.write_to_file(&output_file);
}

/// Find the location of the `target/` directory. Note that this may be
/// overridden by `cmake`, so we also need to check the `CARGO_TARGET_DIR`
/// variable.
fn target_dir() -> PathBuf {
if let Ok(target) = env::var("CARGO_TARGET_DIR") {
PathBuf::from(target)
} else {
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("target")
}
}
Loading