Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Nov 14, 2023
1 parent fd1bb3e commit d46fb87
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
27 changes: 26 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ dependencies = [
"log 0.4.19",
]

[[package]]
name = "binary-merkle-tree"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git#033d4e86cc7eff0066cd376b9375f815761d653c"
dependencies = [
"hash-db 0.16.0",
]

[[package]]
name = "bincode"
version = "1.3.3"
Expand Down Expand Up @@ -2767,6 +2775,7 @@ version = "0.12.0"
dependencies = [
"array-bytes 6.1.0",
"base58",
"binary-merkle-tree 4.0.0-dev (git+https://github.com/paritytech/substrate.git)",
"blake2-rfc",
"chrono 0.4.26",
"clap 3.2.25",
Expand Down Expand Up @@ -2800,6 +2809,7 @@ dependencies = [
"serde 1.0.188",
"serde_json 1.0.106",
"sgx_crypto_helper",
"simplyr-lib",
"sp-application-crypto",
"sp-core",
"sp-keyring",
Expand Down Expand Up @@ -3044,6 +3054,7 @@ dependencies = [
name = "ita-stf"
version = "0.9.0"
dependencies = [
"binary-merkle-tree 4.0.0-dev (git+https://github.com/paritytech/substrate.git)",
"derive_more",
"frame-support",
"frame-system",
Expand All @@ -3065,8 +3076,11 @@ dependencies = [
"pallet-sudo",
"parity-scale-codec",
"rlp",
"serde 1.0.188",
"serde_json 1.0.106",
"sgx_tstd",
"sha3",
"simplyr-lib",
"sp-application-crypto",
"sp-core",
"sp-io 7.0.0",
Expand Down Expand Up @@ -3172,7 +3186,7 @@ dependencies = [
name = "itc-parentchain-indirect-calls-executor"
version = "0.9.0"
dependencies = [
"binary-merkle-tree",
"binary-merkle-tree 4.0.0-dev (git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42)",
"bs58",
"env_logger",
"futures 0.3.28",
Expand Down Expand Up @@ -7638,6 +7652,17 @@ dependencies = [
"wide",
]

[[package]]
name = "simplyr-lib"
version = "0.1.0"
source = "git+https://github.com/BESTenergytrade/simplyr-lib.git?branch=cI/usize#ec8e1266141112a75b304cecfa2da35bfdde215c"
dependencies = [
"libm",
"parity-scale-codec",
"serde 1.0.188",
"serde_json 1.0.106",
]

[[package]]
name = "slab"
version = "0.4.2"
Expand Down
3 changes: 2 additions & 1 deletion app-libs/stf/src/best_energy_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{MerkleProofWithCodec, StfError};
use crate::MerkleProofWithCodec;
use binary_merkle_tree::merkle_proof;
use codec::Encode;
use itp_stf_primitives::error::StfError;
use simplyr_lib::{MarketOutput, Order};
use sp_core::H256;
use sp_runtime::traits::Keccak256;
Expand Down
8 changes: 4 additions & 4 deletions app-libs/stf/src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ use sp_runtime::traits::Verify;
use sp_std::vec;
use std::prelude::v1::*;

// Oli only
use itp_stf_primitives::types::{ActorId, Timestamp};
use std::time::Instant;

#[cfg(feature = "evm")]
use ita_sgx_runtime::{AddressMapping, HashedAddressMapping};

Expand All @@ -40,10 +44,6 @@ use sp_runtime::transaction_validity::{
TransactionValidityError, UnknownTransaction, ValidTransaction,
};

// Oli
use itp_stf_primitives::types::{ActorId, Timestamp};
use std::time::Instant;

/// Custom Merkle proof that implements codec
/// The difference to the original one is that implements the scale-codec and that the fields contain u32 instead of usize.
#[derive(Debug, PartialEq, Eq, Decode, Encode, Deserialize, Serialize)]
Expand Down
5 changes: 4 additions & 1 deletion app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ where
// Send proof of execution on chain.
// calls is in the scope from the outside
calls.push(OpaqueCall::from_tuple(&(
node_metadata_repo.get_from_metadata(|m| m.publish_hash_call_indexes())??,
node_metadata_repo
.get_from_metadata(|m| m.publish_hash_call_indexes())
.map_err(|_| StfError::InvalidMetadata)?
.map_err(|_| StfError::InvalidMetadata)?,
order_merkle_root,
Vec::<itp_types::H256>::new(), // you can ignore this for now. Clients could subscribe to the hashes here to be notified when a new hash is published.
b"Published merkle root of an order!".to_vec(),
Expand Down
12 changes: 7 additions & 5 deletions cli/src/trusted_base_cli/commands/get_market_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{

use crate::CliError;
use codec::Decode;
use ita_stf::{TrustedGetter, TrustedOperation};
use itp_stf_primitives::types::KeyPair;
use ita_stf::{Getter, TrustedCallSigned, TrustedGetter};
use itp_stf_primitives::types::{KeyPair, TrustedOperation};
use log::debug;
use simplyr_lib::MarketOutput;
use sp_core::Pair;
Expand Down Expand Up @@ -53,9 +53,11 @@ pub(crate) fn get_market_results(
debug!("arg_who = {:?}", arg_who);
let who = get_pair_from_str(trusted_args, arg_who);

let top: TrustedOperation = TrustedGetter::get_market_results(who.public().into(), timestamp)
.sign(&KeyPair::Sr25519(Box::new(who)))
.into();
let top: TrustedOperation<TrustedCallSigned, Getter> = Getter::trusted(
TrustedGetter::get_market_results(who.public().into(), timestamp)
.sign(&KeyPair::Sr25519(Box::new(who))),
)
.into();

let res = perform_trusted_operation(cli, trusted_args, &top).unwrap();

Expand Down
9 changes: 6 additions & 3 deletions cli/src/trusted_base_cli/commands/pay_as_bid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ use crate::{
Cli, CliError, CliResult, CliResultOk,
};
use codec::Decode;
use ita_stf::{Index, TrustedCall, TrustedGetter, TrustedOperation};
use itp_stf_primitives::types::KeyPair;
use ita_stf::{Getter, Index, TrustedCall, TrustedCallSigned};
use itp_stf_primitives::{
traits::TrustedCallSigning,
types::{KeyPair, TrustedOperation},
};
use log::debug;
use sp_core::Pair;

Expand Down Expand Up @@ -59,7 +62,7 @@ pub(crate) fn pay_as_bid(
let signer = get_pair_from_str(trusted_args, arg_who);
let (mrenclave, shard) = get_identifiers(trusted_args);
let nonce = get_layer_two_nonce!(signer, cli, trusted_args);
let top: TrustedOperation =
let top: TrustedOperation<TrustedCallSigned, Getter> =
TrustedCall::pay_as_bid(who.public().into(), orders_string.to_string())
.sign(&KeyPair::Sr25519(Box::new(signer)), nonce, &mrenclave, &shard)
.into_trusted_operation(trusted_args.direct);
Expand Down
11 changes: 6 additions & 5 deletions cli/src/trusted_base_cli/commands/pay_as_bid_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::{
};

use codec::Decode;
use ita_stf::{MerkleProofWithCodec, TrustedGetter, TrustedOperation};
use itp_stf_primitives::types::KeyPair;
use ita_stf::{Getter, MerkleProofWithCodec, TrustedCallSigned, TrustedGetter};
use itp_stf_primitives::types::{KeyPair, TrustedOperation};
use log::debug;
use sp_core::{Pair, H256};

Expand Down Expand Up @@ -64,10 +64,11 @@ pub(crate) fn pay_as_bid_proof(
debug!("arg_who = {:?}", arg_who);
let who = get_pair_from_str(trusted_args, arg_who);

let top: TrustedOperation =
let top: TrustedOperation<TrustedCallSigned, Getter> = Getter::trusted(
TrustedGetter::pay_as_bid_proof(who.public().into(), timestamp, actor_id)
.sign(&KeyPair::Sr25519(Box::new(who)))
.into();
.sign(&KeyPair::Sr25519(Box::new(who))),
)
.into();

let res = perform_trusted_operation(cli, trusted_args, &top).unwrap();

Expand Down

0 comments on commit d46fb87

Please sign in to comment.