Skip to content
Open
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
80 changes: 54 additions & 26 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ tap = "1.0.1"
ntest = "0.9.3"
dashmap = "5.5.3"
delegate = "0.13.5"
bon = "3.9.1"

# metrics
metrics = "0.24.0"
Expand Down
20 changes: 20 additions & 0 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use alloc::vec::Vec;
use gear_core_errors::ReplyCode;
use gprimitives::H256;
use parity_scale_codec::{Decode, Encode};
use scale_decode::DecodeAsType;
use scale_encode::EncodeAsType;
Expand Down Expand Up @@ -65,6 +66,25 @@ pub struct ReplyInfo {
pub code: ReplyCode,
}

impl ReplyInfo {
/// Calculates `blake2b` hash from [`ReplyInfo`].
Comment thread
ecol-master marked this conversation as resolved.
pub fn to_hash(&self) -> H256 {
let ReplyInfo {
payload,
value,
code,
} = self;

let bytes = [
payload.as_ref(),
value.to_be_bytes().as_ref(),
code.to_bytes().as_ref(),
]
.concat();
super::utils::hash(&bytes).into()
}
}

/// Serializer and deserializer for ReplyCode as 0x-prefixed hex string.
#[cfg(feature = "std")]
pub(crate) mod serialize_reply_code {
Expand Down
12 changes: 11 additions & 1 deletion ethexe/common/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
Schedule, SimpleBlockData, ValidatorsVec,
events::BlockEvent,
gear::StateTransition,
injected::{InjectedTransaction, SignedInjectedTransaction},
injected::{InjectedTransaction, Promise, SignedCompactPromise, SignedInjectedTransaction},
};
use alloc::{
collections::{BTreeSet, VecDeque},
Expand Down Expand Up @@ -117,11 +117,21 @@ pub trait InjectedStorageRO {
&self,
hash: HashOf<InjectedTransaction>,
) -> Option<SignedInjectedTransaction>;

/// Returns the promise by its transaction hash.
fn promise(&self, hash: HashOf<InjectedTransaction>) -> Option<Promise>;

/// Returns the compact promise by its transaction hash.
fn compact_promise(&self, hash: HashOf<InjectedTransaction>) -> Option<SignedCompactPromise>;
}

#[auto_impl::auto_impl(&)]
pub trait InjectedStorageRW: InjectedStorageRO {
fn set_injected_transaction(&self, tx: SignedInjectedTransaction);

fn set_promise(&self, promise: &Promise);

fn set_compact_promise(&self, promise: &SignedCompactPromise);
}

#[derive(Debug, Clone, Default, Encode, Decode, TypeInfo, PartialEq, Eq, Hash)]
Expand Down
Loading
Loading