Skip to content

Commit

Permalink
sbliff legacy passthrough (#1586)
Browse files Browse the repository at this point in the history
* placeholder todo for self-doc

* implement Sidechain pallet storage handler and merge all pallets into itp-pallet-storage

* make block confirmation work with pallet_sidechain SBliFF

* taplo fmt

* fix cargo test

* bump sdk patch revision

* bump node for CI

* std enable in itp-types
  • Loading branch information
brenzi authored Mar 15, 2024
1 parent 9a3b032 commit b0c86e2
Show file tree
Hide file tree
Showing 25 changed files with 223 additions and 170 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ jobs:
echo "PROJECT=${{ matrix.flavor_id }}-${{ matrix.demo_name }}" >> $GITHUB_ENV
echo "VERSION=dev.$version" >> $GITHUB_ENV
echo "WORKER_IMAGE_TAG=integritee-worker:dev.$version" >> $GITHUB_ENV
echo "INTEGRITEE_NODE=integritee-node:1.1.4.$version" >> $GITHUB_ENV
echo "INTEGRITEE_NODE=integritee-node:1.1.6.$version" >> $GITHUB_ENV
echo "CLIENT_IMAGE_TAG=integritee-cli:dev.$version" >> $GITHUB_ENV
if [[ ${{ matrix.sgx_mode }} == 'HW' ]]; then
echo "SGX_PROVISION=/dev/sgx/provision" >> $GITHUB_ENV
Expand Down Expand Up @@ -368,8 +368,8 @@ jobs:
fi
docker tag integritee-worker-${{ env.IMAGE_SUFFIX }} ${{ env.WORKER_IMAGE_TAG }}
docker tag integritee-cli-client-${{ env.IMAGE_SUFFIX }} ${{ env.CLIENT_IMAGE_TAG }}
docker pull integritee/integritee-node:1.1.4
docker tag integritee/integritee-node:1.1.4 ${{ env.INTEGRITEE_NODE }}
docker pull integritee/integritee-node:1.1.6
docker tag integritee/integritee-node:1.1.6 ${{ env.INTEGRITEE_NODE }}
docker images --all
##
Expand Down
37 changes: 15 additions & 22 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ dependencies = [

[[package]]
name = "integritee-cli"
version = "0.12.11"
version = "0.12.12"
dependencies = [
"array-bytes 6.1.0",
"base58",
Expand Down Expand Up @@ -2607,7 +2607,7 @@ dependencies = [

[[package]]
name = "integritee-service"
version = "0.12.11"
version = "0.12.12"
dependencies = [
"anyhow",
"async-trait",
Expand Down Expand Up @@ -3227,15 +3227,6 @@ dependencies = [
"sgx_types",
]

[[package]]
name = "itp-enclave-bridge-storage"
version = "0.9.0"
dependencies = [
"itp-storage",
"parity-scale-codec",
"sp-std",
]

[[package]]
name = "itp-enclave-metrics"
version = "0.9.0"
Expand Down Expand Up @@ -3349,6 +3340,16 @@ dependencies = [
"sp-std",
]

[[package]]
name = "itp-pallet-storage"
version = "0.9.0"
dependencies = [
"itp-storage",
"itp-types",
"parity-scale-codec",
"sp-std",
]

[[package]]
name = "itp-primitives-cache"
version = "0.9.0"
Expand Down Expand Up @@ -3543,23 +3544,14 @@ dependencies = [
"thiserror 1.0.9",
]

[[package]]
name = "itp-teerex-storage"
version = "0.9.0"
dependencies = [
"itp-storage",
"itp-types",
"sp-std",
]

[[package]]
name = "itp-test"
version = "0.9.0"
dependencies = [
"itp-enclave-bridge-storage",
"itp-node-api",
"itp-node-api-metadata-provider",
"itp-ocall-api",
"itp-pallet-storage",
"itp-sgx-crypto",
"itp-sgx-externalities",
"itp-stf-interface",
Expand Down Expand Up @@ -3649,6 +3641,7 @@ dependencies = [
"pallet-balances",
"parity-scale-codec",
"serde 1.0.193",
"sidechain-primitives",
"sp-core",
"sp-runtime",
"sp-std",
Expand Down Expand Up @@ -3927,8 +3920,8 @@ version = "0.9.0"
dependencies = [
"derive_more",
"itc-parentchain-test",
"itp-enclave-bridge-storage",
"itp-ocall-api",
"itp-pallet-storage",
"itp-test",
"itp-types",
"its-primitives",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"core-primitives/node-api/metadata-provider",
"core-primitives/nonce-cache",
"core-primitives/ocall-api",
"core-primitives/pallet-storage",
"core-primitives/primitives-cache",
"core-primitives/rpc",
"core-primitives/settings",
Expand All @@ -50,7 +51,6 @@ members = [
"core-primitives/substrate-sgx/environmental",
"core-primitives/substrate-sgx/externalities",
"core-primitives/substrate-sgx/sp-io",
"core-primitives/teerex-storage",
"core-primitives/test",
"core-primitives/time-utils",
"core-primitives/top-pool",
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "integritee-cli"
version = "0.12.11"
version = "0.12.12"
authors = ["Integritee AG <[email protected]>"]
edition = "2021"

Expand Down
31 changes: 0 additions & 31 deletions core-primitives/enclave-bridge-storage/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "itp-enclave-bridge-storage"
name = "itp-pallet-storage"
version = "0.9.0"
authors = ["Integritee AG <[email protected]>"]
edition = "2021"
Expand All @@ -10,11 +10,13 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/substr

#local deps
itp-storage = { path = "../storage", default-features = false }
itp-types = { path = "../types", default-features = false }

[features]
default = ["std"]
std = [
"codec/std",
"sp-std/std",
"itp-storage/std",
"itp-types/std",
"sp-std/std",
]
78 changes: 78 additions & 0 deletions core-primitives/pallet-storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::Encode;
use itp_storage::{storage_map_key, StorageHasher};
use itp_types::{AccountId, ShardIdentifier};
use sp_std::prelude::Vec;

// Separate the prefix from the rest because in our case we changed the storage prefix due to
// the rebranding. With the below implementation of the `TeerexStorageKeys`, we could simply
// define another struct `OtherStorage`, implement `StoragePrefix` for it, and get the
// `TeerexStorageKeys` implementation for free.
pub trait StoragePrefix {
fn prefix() -> &'static str;
}

pub struct EnclaveBridgeStorage;

impl StoragePrefix for EnclaveBridgeStorage {
fn prefix() -> &'static str {
"EnclaveBridge"
}
}

pub trait EnclaveBridgeStorageKeys {
fn shard_status<T: Encode>(shard: T) -> Vec<u8>;
}

impl<S: StoragePrefix> EnclaveBridgeStorageKeys for S {
fn shard_status<T: Encode>(shard: T) -> Vec<u8> {
storage_map_key(Self::prefix(), "ShardStatus", &shard, &StorageHasher::Blake2_128Concat)
}
}

pub struct TeeRexStorage;

impl StoragePrefix for TeeRexStorage {
fn prefix() -> &'static str {
"Teerex"
}
}

pub trait TeerexStorageKeys {
fn sovereign_enclaves(account: AccountId) -> Vec<u8>;
}

impl<S: StoragePrefix> TeerexStorageKeys for S {
fn sovereign_enclaves(account: AccountId) -> Vec<u8> {
storage_map_key(
Self::prefix(),
"SovereignEnclaves",
&account,
&StorageHasher::Blake2_128Concat,
)
}
}

pub struct SidechainPalletStorage;

impl StoragePrefix for SidechainPalletStorage {
fn prefix() -> &'static str {
"Sidechain"
}
}

pub trait SidechainPalletStorageKeys {
fn latest_sidechain_block_confirmation(shard: ShardIdentifier) -> Vec<u8>;
}

impl<S: StoragePrefix> SidechainPalletStorageKeys for S {
fn latest_sidechain_block_confirmation(shard: ShardIdentifier) -> Vec<u8> {
storage_map_key(
Self::prefix(),
"LatestSidechainBlockConfirmation",
&shard,
&StorageHasher::Blake2_128Concat,
)
}
}
20 changes: 0 additions & 20 deletions core-primitives/teerex-storage/Cargo.toml

This file was deleted.

36 changes: 0 additions & 36 deletions core-primitives/teerex-storage/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions core-primitives/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/su
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }

# local deps
itp-enclave-bridge-storage = { path = "../enclave-bridge-storage", default-features = false }
itp-node-api = { path = "../node-api", default-features = false }
itp-node-api-metadata-provider = { path = "../node-api/metadata-provider", default-features = false }
itp-ocall-api = { path = "../ocall-api", default-features = false }
itp-pallet-storage = { path = "../pallet-storage", default-features = false }
itp-sgx-crypto = { path = "../sgx/crypto", default-features = false }
itp-sgx-externalities = { default-features = false, path = "../substrate-sgx/externalities" }
itp-stf-interface = { path = "../stf-interface", default-features = false }
Expand All @@ -38,7 +38,7 @@ itp-types = { path = "../types", default-features = false, features = ["test"] }
default = ["std"]
std = [
"codec/std",
"itp-enclave-bridge-storage/std",
"itp-pallet-storage/std",
"itp-node-api-metadata-provider/std",
"itp-node-api/std",
"itp-ocall-api/std",
Expand Down
2 changes: 1 addition & 1 deletion core-primitives/test/src/mock/onchain_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

use codec::{Decode, Encode};
use core::fmt::Debug;
use itp_enclave_bridge_storage::{EnclaveBridgeStorage, EnclaveBridgeStorageKeys};
use itp_ocall_api::{
EnclaveAttestationOCallApi, EnclaveMetricsOCallApi, EnclaveOnChainOCallApi,
EnclaveSidechainOCallApi,
};
use itp_pallet_storage::{EnclaveBridgeStorage, EnclaveBridgeStorageKeys};
use itp_storage::Error::StorageValueUnavailable;
use itp_types::{
parentchain::ParentchainId, storage::StorageEntryVerified, AccountId, BlockHash,
Expand Down
15 changes: 8 additions & 7 deletions core-primitives/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,27 @@ sp-std = { default-features = false, git = "https://github.com/paritytech/substr

# integritee-node
enclave-bridge-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.11-polkadot-v0.9.42" }
sidechain-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.11-polkadot-v0.9.42" }
teeracle-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.11-polkadot-v0.9.42" }
teerex-primitives = { default-features = false, git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.11-polkadot-v0.9.42" }

[features]
default = ["std"]
std = [
"codec/std",
"enclave-bridge-primitives/std",
"frame-system/std",
"itp-sgx-runtime-primitives/std",
"itp-stf-primitives/std",
"itp-utils/std",
"substrate-api-client/std",
"teerex-primitives/std",
"teeracle-primitives/std",
"enclave-bridge-primitives/std",
# substrate
"frame-system/std",
"pallet-balances/std",
"serde/std",
"sp-std/std",
"sidechain-primitives/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"substrate-api-client/std",
"teeracle-primitives/std",
"teerex-primitives/std",
]
test = []
Loading

0 comments on commit b0c86e2

Please sign in to comment.