Skip to content

Commit

Permalink
Merge pull request #1928 from oasisprotocol/kostko/feature/rofl-tx-su…
Browse files Browse the repository at this point in the history
…bmgr

runtime-sdk/modules/rofl: Add transaction submission manager
  • Loading branch information
kostko authored Aug 19, 2024
2 parents b444f4b + d203753 commit 5844bfe
Show file tree
Hide file tree
Showing 9 changed files with 443 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion contract-sdk/specs/access/oas173/Cargo.lock

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

2 changes: 1 addition & 1 deletion contract-sdk/specs/token/oas20/Cargo.lock

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

4 changes: 2 additions & 2 deletions runtime-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oasis-runtime-sdk"
version = "0.9.1"
version = "0.9.5"
authors = ["Oasis Protocol Foundation <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -38,7 +38,7 @@ rand = "0.8.5"
rand_core = { version = "0.6.4", default-features = false }
slog = "2.7.0"
tiny-keccak = { version = "2.0", features = ["tuple_hash"] }
tokio = { version = "1.38", features = ["rt"] }
tokio = { version = "1.38", features = ["rt", "rt-multi-thread", "sync", "time", "macros"] }
tokio-retry = "0.3.0"
zeroize = "1.8"
lru = "0.12.3"
Expand Down
79 changes: 79 additions & 0 deletions runtime-sdk/src/crypto/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,45 @@ pub trait Signer: Send + Sync {
fn sign_raw(&self, message: &[u8]) -> Result<Signature, Error>;
}

impl<T: Signer + ?Sized> Signer for std::sync::Arc<T> {
fn random(_rng: &mut impl RngCore) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn new_from_seed(_seed: &[u8]) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn from_bytes(_bytes: &[u8]) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn to_bytes(&self) -> Vec<u8> {
T::to_bytes(self)
}

fn public_key(&self) -> PublicKey {
T::public_key(self)
}

fn sign(&self, context: &[u8], message: &[u8]) -> Result<Signature, Error> {
T::sign(self, context, message)
}

fn sign_raw(&self, message: &[u8]) -> Result<Signature, Error> {
T::sign_raw(self, message)
}
}

impl<T: CoreSigner> Signer for &T {
fn random(_rng: &mut impl RngCore) -> Result<Self, Error>
where
Expand Down Expand Up @@ -446,6 +485,46 @@ impl<T: CoreSigner> Signer for &T {
}
}

impl Signer for crate::core::identity::Identity {
fn random(_rng: &mut impl RngCore) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn new_from_seed(_seed: &[u8]) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn from_bytes(_bytes: &[u8]) -> Result<Self, Error>
where
Self: Sized,
{
Err(Error::InvalidArgument)
}

fn to_bytes(&self) -> Vec<u8> {
vec![]
}

fn public_key(&self) -> PublicKey {
PublicKey::Ed25519(self.public().into())
}

fn sign(&self, context: &[u8], message: &[u8]) -> Result<Signature, Error> {
let raw_sig = CoreSigner::sign(self, context, message).map_err(|_| Error::SigningError)?;
Ok(Signature(raw_sig.as_ref().into()))
}

fn sign_raw(&self, _message: &[u8]) -> Result<Signature, Error> {
Err(Error::InvalidArgument)
}
}

/// A memory-backed signer.
pub enum MemorySigner {
Ed25519(ed25519::MemorySigner),
Expand Down
Loading

0 comments on commit 5844bfe

Please sign in to comment.