Closed clangenb closed 1 year ago
@clangenb I'm unable to resolve conflicts for lock
files. These conflicts appear again and again.
is there a way to skip conflicts for lock
files?
Yeah lock files are always a hassle, usually I just accept the other file, and regenerate the lock file after the merge/rebase process.
There is no need to go through the enclave for hash verification as mentioned by @clangenb
I'm rebasing in the following way:
// step 1
git remote add -f sdk-v0.11.0-polkadot-v0.9.37 https://github.com/integritee-network/worker.git
// step 2
git rebase cI/simplyR remotes/sdk-v0.11.0-polkadot-v0.9.37/sdk-v0.11.0-polkadot-v0.9.37
I'll accept the incoming changes for lock
files for now. and will regenerate afterward.
is that fine? @clangenb
after rebasing, cargo clippy
works fine.
However, the make
command gives following error:
error: linking with `cc` failed: exit status: 1
The error is the same even after cargo -update
.
any help how to fix it?
I suggest this is because you also need to use a new docker image: https://hub.docker.com/r/integritee/integritee-dev/tags if your version is <v0.1.11, this is the reason. Otherwise, I need more logging output.
I could finally compile it with v0.1.12.
@clangenb can you please check this commit for the implementation of pay_as_bid
algorithm?
As we are not returning anything from trusted_call
, the respective cli
is just executing the algorithm.
I'm converting orders
to a String
vector before encoding them. This is because let orders_encoded: Vec<Vec<u8>> = orders.into_iter().map(|o| o.encode()).collect();
gives the error method cannot be called on
simplyr_lib::Orderdue to unsatisfied trait bounds
. To fix the above error, I have derived Decode to Orderstruct and OrderType enum.
But this results in the following errors:
// line 53
pub cluster_index: Option<usize>,
// error
the trait `parity_scale_codec::Decode` is not implemented for `core::option::Option<usize>`
However, with the String
vector method the algorithm seems working.
Please also take a look at this commit for the implementation of pay_as_bid_proof
, it is in the error stage because of the mismatched types in the return statement:
fn execute(self) -> Option<Vec<u8>> {
expected `std::option::Option<std::vec::Vec<u8>>` because of return type
Ok(Some(merkle_proof))
^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
= note: expected enum `std::option::Option<std::vec::Vec<_>>`
found enum `std::result::Result<std::option::Option<MerkleProof<H256, std::vec::Vec<_>>>, _>`
I tried to decode
and unwrap
the proof, but it did not work.
Can you please guide me a little bit here? thanks
Yeah, usize
is the only type that is incompatible with scale-codec because it is of variable size dependeing on the architecture and as the codec is not self-descriptive, it can't contain data about it's length (except for dynamically sized types like vec, there the length is part of the encoding). . You need to use u32, or u64 instead.
Just remove the wrapping in Ok()
at the end.
I'll discuss this with Timo if can use u32
or u64
instead.
I already have tried removing Ok
wrapper but still getting the mismatched types
error:
error[E0308]: mismatched types
--> app-libs/stf/src/getter.rs:189:11
|
189 | Some(merkle_proof)
| ---- ^^^^^^^^^^^^ expected struct `std::vec::Vec`, found struct `binary_merkle_tree::MerkleProof`
| |
| arguments to this enum variant are incorrect
|
= note: expected struct `std::vec::Vec<_>`
found struct `binary_merkle_tree::MerkleProof<sp_core::H256, std::vec::Vec<_>>`
Ah sorry I did not catch this one, yeah this is because that the merkle proof needs to be encoded, sadly the merkle proof structure does not implement codec because it contains usize. So what I suggest here, is that we have to redefine the MerkleProof in our crate:
/// Custom Merkle proof that implements codec
///
/// The difference to the original one is that is implements the scale-codec and that the fields contain u32 instead of usize.
#[derive(Debug, PartialEq, Eq, Decode, Encode)]
pub struct MerkleProofWithCodec<H, L> {
/// Root hash of generated merkle tree.
pub root: H,
/// Proof items (does not contain the leaf hash, nor the root obviously).
///
/// This vec contains all inner node hashes necessary to reconstruct the root hash given the
/// leaf hash.
pub proof: Vec<H>,
/// Number of leaves in the original tree.
///
/// This is needed to detect a case where we have an odd number of leaves that "get promoted"
/// to upper layers.
pub number_of_leaves: u32,
/// Index of the leaf the proof is for (0-based).
pub leaf_index: u32,
/// Leaf content.
pub leaf: L,
}
/// Then we can also implement conversion of the two types to make the handling more ergonomic:
impl<H, L> From<MerkleProof<H, L> for MerkleProofWithCodec<H, L> {
fn from(source: MerkleProof<H, L>) -> Self {
Self {
root: source.root,
proof: source.proof,
number_of_leaves: source.number_of_leaves.try_into().expec("We don't have more than u32::MAX leaves; qed"),
leaf_index: source.leave_index.try_into().expect("Leave index is never bigger than U32::Max; qed");
leaf: source.leaf
}
}
}
In your getter you can do the following:
let proof: MerkleProofWithCodec<_, _> = merkle_proof<Keccak256, _, _>::(data).into();
// return the proof as follows:
Some(proof.encode())
note: the above might contain some typos, it has not been tested.
@clangenb can you please take a look at this commit for the implementation of pay_as_bid_proof
method?
I would say this is done
Preliminaries:
cargo update
. This rebase will also give you access to the newpublish_hash
transaction that you need for publishing the hash on the integritee parachain, see example of how it is used no in theshield_funds
trusted call: https://github.com/integritee-network/worker/pull/1174.In the trusted calls, I would expect something like this:
in the trusted Getters something like this:
For the verification, I am unsure if I understand your approach, was this just a test? I would assume that you don't need to go into the enclave to verify the proof, I would just do a regular CLI where you can supply the merkle proof and the client verifies it for you: