Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
41a85ff
draft implementation
Feb 6, 2026
a1e405c
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
Feb 6, 2026
cc740d5
fix changes | final design
Feb 8, 2026
d4dd026
fix network tests
Feb 8, 2026
b7fab2d
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
Feb 9, 2026
9d788d3
fix format
Feb 9, 2026
a844855
redisign CompactSignedPromise
Feb 11, 2026
d8b64b8
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
Feb 11, 2026
ac2519e
remove Eip191Hash struct
Feb 11, 2026
dfaa7d1
fix unused deps | small refactoring in consensus
Feb 11, 2026
8c7829c
self review fixes
Feb 11, 2026
3afe82b
update submodules
Feb 12, 2026
e5c49ed
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Feb 12, 2026
9ace2a6
initial pull request | main functionality
Feb 23, 2026
5a974ec
complete functionality in processor
Feb 24, 2026
26a48e9
fix small compile error
Feb 24, 2026
94b27ea
all tests run correctly
Feb 25, 2026
52447b2
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
Feb 25, 2026
b182951
compute service produce event with promise
Feb 25, 2026
9a27c72
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
ecol-master Feb 25, 2026
3b9affb
only producer provides promises from compute service
Feb 25, 2026
bd3f009
small refactoring
Feb 26, 2026
e4f07c0
implement the builder for compute service
Feb 26, 2026
8414659
make compute service builder implementation much prettier
Feb 26, 2026
5829c5e
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
Feb 26, 2026
a97cf4c
transfer promise for signing to consensus service
Feb 26, 2026
51ede2a
return tests in compute service
Feb 26, 2026
4d62e9a
redesign to PromisePolicy enum
Feb 26, 2026
08c8bae
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
Feb 27, 2026
6b11846
refactoring inside ethexe/runtime | remove unresolved TODOs
Feb 27, 2026
7f9f46c
AnnouncePromisesStream inside compute service
Feb 27, 2026
9c01711
stabilize the AnnouncePromisesStream implementation
Mar 2, 2026
db7b81b
implement test with early break
Mar 2, 2026
b500072
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
Mar 2, 2026
f19f762
fix clippy
Mar 2, 2026
c0d12ae
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
ecol-master Mar 2, 2026
ba0df70
up limits for test
Mar 2, 2026
4095212
add guard for promise channel drop
Mar 3, 2026
f0cd844
self review small fixes
Mar 4, 2026
e2897ea
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
ecol-master Mar 4, 2026
d1586f8
Merge branch 'master' into kuzmindev/feat/return-promise-as-they-proc…
ecol-master Mar 5, 2026
91e7802
fix for limited vec in injected transaction
Mar 5, 2026
0d19463
Merge branch 'kuzmindev/feat/return-promise-as-they-processed' into k…
Mar 6, 2026
e9d71b3
small redesign for CompactSignedPromise
Mar 6, 2026
78fa1bd
RPC redesign | PromiseEmissionMode
Mar 9, 2026
c79e07b
remove store promise in db from service to rpc
Mar 9, 2026
5d884e4
feat(ethexe/rpc): add method to get injected transaction (#5233)
osipov-mit Mar 19, 2026
448492c
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
Apr 9, 2026
af5babc
small log fixes
Apr 9, 2026
c0ac4e5
feat: implement PromiseEmissionMode
Apr 10, 2026
fa63a2a
Merge branch 'kuzmindev/feat/producer-send-promises-hashes' of https:…
Apr 10, 2026
40678d2
fix: all tests works correctly
Apr 10, 2026
9bc28c1
feat: add docs | make implementation clear
Apr 10, 2026
f479b76
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 10, 2026
e5b8497
fix: claude review
Apr 10, 2026
ebc38a8
feat: fix bug with compact promise store in db
Apr 10, 2026
d320375
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 13, 2026
46ad9a9
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 15, 2026
4b47308
Merge branch 'kuzmindev/feat/producer-send-promises-hashes' of https:…
ecol-master Apr 15, 2026
0976d04
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 16, 2026
d811e45
fix: claude small review comments
ecol-master Apr 16, 2026
5a185c9
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 16, 2026
77e05e9
fix: CompactSignedPromise -> SignedCompactPromise | fix tests | updat…
ecol-master Apr 17, 2026
fdd4bc5
Merge branch 'kuzmindev/feat/producer-send-promises-hashes' of https:…
ecol-master Apr 17, 2026
5fd60d9
chore: fix doc in rpc/src/apis/injected/mod.rs
ecol-master Apr 17, 2026
0962a7c
fix promise emission for not computed chain
ecol-master Apr 17, 2026
93b7658
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 20, 2026
4d33197
feat: add metrics to new server
ecol-master Apr 20, 2026
30d4f3a
chore: add TODO comments for future refactoring
ecol-master Apr 20, 2026
2324d56
Merge branch 'master' into kuzmindev/feat/producer-send-promises-hashes
ecol-master Apr 21, 2026
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
1 change: 1 addition & 0 deletions Cargo.lock

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

20 changes: 18 additions & 2 deletions ethexe/common/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
//! Common db types and traits.

use crate::{
Announce, BlockHeader, CodeBlobInfo, Digest, HashOf, ProgramStates, ProtocolTimelines,
Address, Announce, BlockHeader, CodeBlobInfo, Digest, HashOf, ProgramStates, ProtocolTimelines,
Schedule, SimpleBlockData, ValidatorsVec,
events::BlockEvent,
gear::StateTransition,
injected::{InjectedTransaction, SignedInjectedTransaction},
injected::{InjectedTransaction, Promise, SignedInjectedTransaction},
};
use alloc::{
collections::{BTreeSet, VecDeque},
Expand All @@ -34,6 +34,7 @@ use gear_core::{
ids::{ActorId, CodeId},
};
use gprimitives::H256;
use gsigner::secp256k1::Signature;
use parity_scale_codec::{Decode, Encode};

/// Ethexe metadata associated with an on-chain block.
Expand Down Expand Up @@ -134,11 +135,26 @@ pub trait InjectedStorageRO {
&self,
hash: HashOf<InjectedTransaction>,
) -> Option<SignedInjectedTransaction>;

/// Returns the promise by its transaction hash.
fn promise(&self, hash: HashOf<InjectedTransaction>) -> Option<Promise>;
Comment thread
ecol-master marked this conversation as resolved.

///
fn promise_signature(&self, hash: HashOf<InjectedTransaction>) -> Option<(Signature, Address)>;
}

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

fn set_promise(&self, promise: Promise);

fn set_promise_signature(
&self,
hash: HashOf<InjectedTransaction>,
address: Address,
signature: Signature,
);
}

#[derive(Debug, Clone, Default, Encode, Decode, PartialEq, Eq, Hash)]
Expand Down
73 changes: 71 additions & 2 deletions ethexe/common/src/injected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::{Address, HashOf, ToDigest, ecdsa::SignedMessage};
use alloc::string::{String, ToString};
use crate::{Address, Announce, HashOf, ToDigest, ecdsa::SignedMessage};
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::hash::Hash;
use gear_core::rpc::ReplyInfo;
use gprimitives::{ActorId, H256, MessageId};
use gsigner::Signature;
#[cfg(feature = "std")]
use gsigner::{
PrivateKey, PublicKey, SignerError,
secp256k1::{Secp256k1SignerExt, Signer},
};
use parity_scale_codec::{Decode, Encode};
use sha3::{Digest, Keccak256};
use sp_core::Bytes;
Expand Down Expand Up @@ -150,6 +159,66 @@ impl ToDigest for Promise {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct PromisesNetworkBundle {
/// The hash of [`Announce`] for which promises was created.
pub announce: HashOf<Announce>,
/// The hashes of transactions with signatures
pub promises: Vec<CompactSignedPromise>,
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)]
pub struct CompactSignedPromise {
/// The hash of transaction, for which promise was created.
tx_hash: HashOf<InjectedTransaction>,
Comment thread
ecol-master marked this conversation as resolved.
Outdated
/// The address converted from public key of block producer.
address: Address,
/// The signature over the [`Promise`] for `tx_hash`.
signature: Signature,
}

#[cfg(feature = "std")]
impl CompactSignedPromise {
pub fn create(
signer: &Signer,
public_key: PublicKey,
promise: Promise,
) -> Result<Self, SignerError> {
let tx_hash = promise.tx_hash;
let (address, signature) = signer
.signed_message(public_key, promise, None)
.map(|message| (message.address(), message.into_parts().1))?;

Ok(Self {
tx_hash,
address,
signature,
})
}

pub fn create_from_private_key(
private_key: &PrivateKey,
promise: Promise,
) -> Result<Self, SignerError> {
let tx_hash = promise.tx_hash;
let signature = Signature::create(private_key, promise)?;
let address = private_key.public_key().to_address();
Ok(Self {
tx_hash,
signature,
address,
})
}

pub fn tx_hash(&self) -> HashOf<InjectedTransaction> {
self.tx_hash
}

pub fn into_parts(self) -> (HashOf<InjectedTransaction>, Address, Signature) {
(self.tx_hash, self.address, self.signature)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
21 changes: 19 additions & 2 deletions ethexe/common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ use crate::{
ecdsa::{PrivateKey, SignedMessage},
events::BlockEvent,
gear::{BatchCommitment, ChainCommitment, CodeCommitment, Message, StateTransition},
injected::{AddressedInjectedTransaction, InjectedTransaction},
injected::{AddressedInjectedTransaction, InjectedTransaction, Promise},
};
use alloc::{collections::BTreeMap, vec};
use gear_core::code::{CodeMetadata, InstrumentedCode};
use gear_core::{
code::{CodeMetadata, InstrumentedCode},
message::{ReplyCode, SuccessReplyReason},
rpc::ReplyInfo,
};
use gprimitives::{CodeId, H256};
use itertools::Itertools;
use std::collections::{BTreeSet, VecDeque};
Expand Down Expand Up @@ -650,3 +654,16 @@ impl Mock<HashOf<Announce>> for ComputedAnnounce {
}
}
}

impl Mock<HashOf<InjectedTransaction>> for Promise {
fn mock(tx_hash: HashOf<InjectedTransaction>) -> Self {
Self {
tx_hash,
reply: ReplyInfo {
payload: vec![],
value: 0,
code: ReplyCode::Success(SuccessReplyReason::Manual),
},
}
}
}
7 changes: 6 additions & 1 deletion ethexe/compute/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use ethexe_common::{
Announce, ComputedAnnounce, HashOf, SimpleBlockData,
db::{
AnnounceStorageRO, AnnounceStorageRW, BlockMetaStorageRO, CodesStorageRW,
LatestDataStorageRO, LatestDataStorageRW, OnChainStorageRO,
InjectedStorageRW, LatestDataStorageRO, LatestDataStorageRW, OnChainStorageRO,
},
events::BlockEvent,
};
Expand Down Expand Up @@ -201,6 +201,11 @@ impl<P: ProcessorExt> ComputeSubService<P> {
})
.ok_or(ComputeError::LatestDataNotFound)?;

// TODO: remove in this PR ComputedAnnounce struct.
Comment thread
ecol-master marked this conversation as resolved.
Outdated
promises.clone().into_iter().for_each(|promise| {
Comment thread
ecol-master marked this conversation as resolved.
Outdated
db.set_promise(promise);
});
Comment thread
ecol-master marked this conversation as resolved.
Outdated
Comment thread
ecol-master marked this conversation as resolved.
Outdated

Ok(ComputedAnnounce {
announce_hash,
promises,
Expand Down
6 changes: 4 additions & 2 deletions ethexe/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ use anyhow::Result;
use ethexe_common::{
Announce, ComputedAnnounce, Digest, HashOf, SimpleBlockData,
consensus::{BatchCommitmentValidationReply, VerifiedAnnounce, VerifiedValidationRequest},
injected::{SignedInjectedTransaction, SignedPromise},
injected::{
PromisesNetworkBundle, SignedInjectedTransaction,
},
network::{AnnouncesRequest, AnnouncesResponse, SignedValidatorMessage},
};
use futures::{Stream, stream::FusedStream};
Expand Down Expand Up @@ -124,5 +126,5 @@ pub enum ConsensusEvent {
Warning(String),
/// Promises for [`ethexe_common::injected::InjectedTransaction`]s execution in some announce.
#[from]
Promises(Vec<SignedPromise>),
Promises(PromisesNetworkBundle),
}
26 changes: 17 additions & 9 deletions ethexe/consensus/src/validator/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ use crate::{
announces::{self, DBAnnouncesExt},
validator::DefaultProcessing,
};
use anyhow::{Context as _, Result, anyhow};
use anyhow::{ Result, anyhow};
use derive_more::{Debug, Display};
use ethexe_common::{
Announce, ComputedAnnounce, HashOf, SimpleBlockData, ValidatorsVec, db::BlockMetaStorageRO,
gear::BatchCommitment, network::ValidatorMessage,
Announce, ComputedAnnounce, HashOf, SimpleBlockData, ValidatorsVec,
db::BlockMetaStorageRO,
gear::BatchCommitment,
injected::{CompactSignedPromise, PromisesNetworkBundle},
network::ValidatorMessage,
};
use ethexe_service_utils::Timer;
use futures::{FutureExt, future::BoxFuture};
Expand Down Expand Up @@ -82,17 +85,22 @@ impl StateHandler for Producer {
if *expected == computed_data.announce_hash =>
{
if !computed_data.promises.is_empty() {
let signed_promises = computed_data
let promises = computed_data
.promises
.into_iter()
.map(|promise| {
self.ctx
.sign_message(promise)
.context("producer: failed to sign promise")
CompactSignedPromise::create(
&self.ctx.core.signer,
self.ctx.core.pub_key,
promise,
)
})
.collect::<Result<_, _>>()?;

self.ctx.output(ConsensusEvent::Promises(signed_promises));
let bundle = PromisesNetworkBundle {
announce: computed_data.announce_hash,
promises,
};
self.ctx.output(ConsensusEvent::Promises(bundle));
}

// Aggregate commitment for the block and use `announce_hash` as head for chain commitment.
Expand Down
2 changes: 1 addition & 1 deletion ethexe/contracts/lib/forge-std
Comment thread
ecol-master marked this conversation as resolved.
Submodule forge-std updated 61 files
+1 −1 .github/CODEOWNERS
+0 −6 .github/dependabot.yml
+17 −60 .github/workflows/ci.yml
+1 −6 .github/workflows/sync.yml
+2 −2 CONTRIBUTING.md
+9 −11 README.md
+0 −12 RELEASE_CHECKLIST.md
+14 −9 foundry.toml
+2 −2 package.json
+12 −2 scripts/vm.py
+2 −8 src/Base.sol
+0 −60 src/Config.sol
+0 −477 src/LibVariable.sol
+2 −2 src/Script.sol
+13 −28 src/StdAssertions.sol
+4 −13 src/StdChains.sol
+13 −9 src/StdCheats.sol
+0 −632 src/StdConfig.sol
+2 −2 src/StdConstants.sol
+2 −2 src/StdError.sol
+4 −2 src/StdInvariant.sol
+12 −4 src/StdJson.sol
+2 −6 src/StdMath.sol
+9 −11 src/StdStorage.sol
+2 −2 src/StdStyle.sol
+12 −4 src/StdToml.sol
+13 −5 src/StdUtils.sol
+4 −2 src/Test.sol
+49 −81 src/Vm.sol
+19 −10 src/console.sol
+2 −2 src/console2.sol
+2 −2 src/interfaces/IERC1155.sol
+2 −2 src/interfaces/IERC165.sol
+2 −2 src/interfaces/IERC20.sol
+2 −2 src/interfaces/IERC4626.sol
+2 −2 src/interfaces/IERC6909.sol
+2 −2 src/interfaces/IERC721.sol
+10 −4 src/interfaces/IERC7540.sol
+2 −2 src/interfaces/IERC7575.sol
+8 −3 src/interfaces/IMulticall3.sol
+1,380 −691 src/safeconsole.sol
+2 −2 test/CommonBase.t.sol
+0 −381 test/Config.t.sol
+0 −452 test/LibVariable.t.sol
+2 −2 test/StdAssertions.t.sol
+25 −25 test/StdChains.t.sol
+20 −19 test/StdCheats.t.sol
+2 −2 test/StdConstants.t.sol
+4 −3 test/StdError.t.sol
+2 −2 test/StdJson.t.sol
+8 −8 test/StdMath.t.sol
+27 −24 test/StdStorage.t.sol
+2 −2 test/StdStyle.t.sol
+2 −2 test/StdToml.t.sol
+13 −13 test/StdUtils.t.sol
+3 −3 test/Vm.t.sol
+4 −2 test/compilation/CompilationScript.sol
+4 −2 test/compilation/CompilationScriptBase.sol
+4 −2 test/compilation/CompilationTest.sol
+4 −2 test/compilation/CompilationTestBase.sol
+0 −81 test/fixtures/config.toml
2 changes: 1 addition & 1 deletion ethexe/contracts/lib/frost-secp256k1-evm
Submodule frost-secp256k1-evm updated 38 files
+12 −10 .github/workflows/ci.yml
+1 −1 .vscode/settings.json
+3 −13 README.md
+2 −2 foundry.lock
+1 −4 foundry.toml
+1 −1 lib/forge-std
+1 −1 offchain-signer/Cargo.toml
+3 −3 scripts/generate-transpiled.sh
+9 −10 src/FROST.sol
+4 −4 src/FROSTOffchain.sol
+17 −22 src/TranspiledFROST.sol
+7 −7 src/utils/Memory.sol
+4 −4 src/utils/cryptography/ChaChaRngOffchain.sol
+2 −2 src/utils/cryptography/ECDSA.sol
+2 −17 src/utils/cryptography/Hashes.sol
+1 −1 src/utils/cryptography/ModExp.sol
+5 −5 src/utils/cryptography/Schnorr.sol
+6 −7 src/utils/cryptography/Secp256k1.sol
+3 −91 src/utils/cryptography/Secp256k1Arithmetic.sol
+1 −1 test/FROST.t.sol
+2 −2 test/FROSTOffchain.t.sol
+1 −1 test/TranspiledFROST.t.sol
+1 −1 test/examples/FROSTCounter.sol
+3 −3 test/examples/FROSTCounter.t.sol
+3 −3 test/examples/FROSTCounterOptimized.sol
+3 −3 test/examples/FROSTCounterOptimized.t.sol
+1 −1 test/examples/FROSTVerifier.sol
+2 −2 test/examples/FROSTVerifier.t.sol
+3 −3 test/examples/FROSTWalletOptimized.sol
+3 −3 test/examples/FROSTWalletOptimized.t.sol
+1 −1 test/utils/Memory.t.sol
+1 −1 test/utils/cryptography/ChaChaRngOffchain.t.sol
+2 −2 test/utils/cryptography/ECDSA.t.sol
+3 −7 test/utils/cryptography/Hashes.t.sol
+2 −2 test/utils/cryptography/ModExp.t.sol
+2 −2 test/utils/cryptography/Schnorr.t.sol
+1 −1 test/utils/cryptography/Secp256k1.t.sol
+2 −55 test/utils/cryptography/Secp256k1Arithmetic.t.sol
1 change: 1 addition & 0 deletions ethexe/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ethexe-common = { workspace = true, features = ["std"] }
ethexe-runtime-common = { workspace = true, features = ["std"] }
gear-core = { workspace = true, features = ["std"] }
gprimitives = { workspace = true, features = ["std"] }
gsigner = {workspace = true, features = ["secp256k1", "codec"]}

anyhow.workspace = true
dashmap.workspace = true
Expand Down
56 changes: 50 additions & 6 deletions ethexe/db/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use crate::{
overlay::{CASOverlay, KVOverlay},
};
use ethexe_common::{
Announce, BlockHeader, CodeBlobInfo, HashOf, ProgramStates, ProtocolTimelines, Schedule,
ValidatorsVec,
Address, Announce, BlockHeader, CodeBlobInfo, HashOf, ProgramStates, ProtocolTimelines,
Schedule, ValidatorsVec,
db::{
AnnounceMeta, AnnounceStorageRO, AnnounceStorageRW, BlockMeta, BlockMetaStorageRO,
BlockMetaStorageRW, CodesStorageRO, CodesStorageRW, HashStorageRO, InjectedStorageRO,
Expand All @@ -33,9 +33,8 @@ use ethexe_common::{
},
events::BlockEvent,
gear::StateTransition,
injected::{InjectedTransaction, SignedInjectedTransaction},
injected::{InjectedTransaction, Promise, SignedInjectedTransaction},
};

use ethexe_runtime_common::state::{
Allocations, DispatchStash, Mailbox, MemoryPages, MemoryPagesRegion, MessageQueue,
ProgramState, Storage, UserMailbox, Waitlist,
Expand All @@ -47,6 +46,7 @@ use gear_core::{
memory::PageBuf,
};
use gprimitives::H256;
use gsigner::secp256k1::Signature;
use parity_scale_codec::{Decode, Encode};
use std::collections::BTreeSet;

Expand Down Expand Up @@ -76,7 +76,10 @@ enum Key {
Timelines = 15,

// TODO kuzmindev: temporal solution - must move into block meta or something else.
LatestEraValidatorsCommitted(H256),
LatestEraValidatorsCommitted(H256) = 16,

Promise(HashOf<InjectedTransaction>) = 17,
PromiseSignature(HashOf<InjectedTransaction>) = 18,
}

impl Key {
Expand All @@ -103,7 +106,9 @@ impl Key {
| Self::AnnounceSchedule(hash)
| Self::AnnounceMeta(hash) => [prefix.as_ref(), hash.inner().as_ref()].concat(),

Self::InjectedTransaction(hash) => [prefix.as_ref(), hash.inner().as_ref()].concat(),
Self::InjectedTransaction(hash)
| Self::Promise(hash)
| Self::PromiseSignature(hash) => [prefix.as_ref(), hash.inner().as_ref()].concat(),

Self::ProgramToCodeId(program_id) => [prefix.as_ref(), program_id.as_ref()].concat(),

Expand Down Expand Up @@ -619,6 +624,24 @@ impl InjectedStorageRO for Database {
.expect("Failed to decode data into `SignedInjectedTransaction`")
})
}

fn promise(&self, tx_hash: HashOf<InjectedTransaction>) -> Option<Promise> {
self.kv.get(&Key::Promise(tx_hash).to_bytes()).map(|data| {
Promise::decode(&mut data.as_slice()).expect("Failed to decode data into Promise")
})
}

fn promise_signature(
&self,
tx_hash: HashOf<InjectedTransaction>,
) -> Option<(Signature, Address)> {
self.kv
.get(&Key::PromiseSignature(tx_hash).to_bytes())
.map(|data| {
<(Signature, Address)>::decode(&mut data.as_slice())
.expect("Failed to decode data into `(Signature, Address)`")
})
}
}

impl InjectedStorageRW for Database {
Expand All @@ -629,6 +652,27 @@ impl InjectedStorageRW for Database {
self.kv
.put(&Key::InjectedTransaction(tx_hash).to_bytes(), tx.encode());
}

fn set_promise(&self, promise: Promise) {
tracing::trace!(promise_tx_hash = ?promise.tx_hash, "Set promise for injected transaction");

self.kv
.put(&Key::Promise(promise.tx_hash).to_bytes(), promise.encode())
}

fn set_promise_signature(
&self,
hash: HashOf<InjectedTransaction>,
address: Address,
signature: Signature,
) {
tracing::trace!(tx_hash = ?hash, ?signature, ?address, "Set `(Signature, Address)` for injected transaction promise");

self.kv.put(
&Key::PromiseSignature(hash).to_bytes(),
(signature, address).encode(),
);
}
}

impl AnnounceStorageRO for Database {
Expand Down
Loading
Loading