• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oasisprotocol / oasis-core / #4648

18 Mar 2024 05:44PM UTC coverage: 46.914% (-0.7%) from 47.607%
#4648

Pull #5602

kostko
go/oasis-test-runner: Stop any compute workers before taking a dump

Otherwise runtime state may progress after taking the dump which would
result in rollback and that is not allowed, so when the network starts
again, the compute nodes would refuse to initialize.
Pull Request #5602: Implement ROFL (Runtime OFf-chain Logic)

3 of 128 new or added lines in 9 files covered. (2.34%)

3 existing lines in 3 files now uncovered.

3383 of 7211 relevant lines covered (46.91%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/runtime/src/host.rs
1
//! Host interface.
2
use async_trait::async_trait;
3
use thiserror::Error;
4

5
use crate::{
6
    common::{crypto::signature::PublicKey, namespace::Namespace},
7
    protocol::Protocol,
8
    types::{self, Body},
9
};
10

11
/// Errors.
12
#[derive(Error, Debug)]
13
pub enum Error {
14
    #[error("bad response from host")]
15
    BadResponse,
16
    #[error("{0}")]
17
    Other(#[from] types::Error),
18
}
19

20
/// Transaction submission options.
21
#[derive(Clone, Default, Debug)]
22
pub struct SubmitTxOpts {
23
    /// Target runtime identifier. If not specified, own runtime identifier is used.
24
    pub runtime_id: Option<Namespace>,
25
    /// Whether the call should wait until the transaction is included in a block.
26
    pub wait: bool,
27
    /// Whether the response should include a proof of transaction being included in a block.
28
    pub prove: bool,
29
}
30

31
/// Notification registration options.
32
#[derive(Clone, Default, Debug)]
33
pub struct RegisterNotifyOpts {
34
    /// Subscribe to runtime block notifications.
35
    pub runtime_block: bool,
36
    /// Subscribe to runtime event notifications.
37
    pub runtime_event: Option<Vec<Vec<u8>>>,
38
}
39

40
/// Interface to the (untrusted) host node.
41
#[async_trait]
42
pub trait Host: Send + Sync {
43
    /// Returns the identity of the host node.
44
    async fn identity(&self) -> Result<PublicKey, Error>;
45

46
    /// Submit a transaction.
47
    async fn submit_tx(&self, opts: SubmitTxOpts, data: Vec<u8>) -> Result<(), Error>;
48

49
    /// Register for receiving notifications.
50
    async fn register_notify(&self, opts: RegisterNotifyOpts) -> Result<(), Error>;
51
}
52

53
#[async_trait]
54
impl Host for Protocol {
55
    async fn identity(&self) -> Result<PublicKey, Error> {
×
56
        match self.call_host_async(Body::HostIdentityRequest {}).await? {
×
57
            Body::HostIdentityResponse { node_id } => Ok(node_id),
×
58
            _ => Err(Error::BadResponse),
×
59
        }
60
    }
61

NEW
62
    async fn submit_tx(&self, opts: SubmitTxOpts, data: Vec<u8>) -> Result<(), Error> {
×
NEW
63
        match self
×
NEW
64
            .call_host_async(Body::HostSubmitTxRequest {
×
NEW
65
                runtime_id: opts.runtime_id.unwrap_or_else(|| self.get_runtime_id()),
×
NEW
66
                data,
×
NEW
67
                wait: opts.wait,
×
NEW
68
                prove: opts.prove,
×
69
            })
NEW
70
            .await?
×
71
        {
NEW
72
            Body::HostSubmitTxResponse { .. } => Ok(()),
×
NEW
73
            _ => Err(Error::BadResponse),
×
74
        }
75
    }
76

NEW
77
    async fn register_notify(&self, opts: RegisterNotifyOpts) -> Result<(), Error> {
×
NEW
78
        match self
×
NEW
79
            .call_host_async(Body::HostRegisterNotifyRequest {
×
NEW
80
                runtime_block: opts.runtime_block,
×
NEW
81
                runtime_event: opts
×
82
                    .runtime_event
NEW
83
                    .map(|tags| types::RegisterNotifyRuntimeEvent { tags }),
×
84
            })
NEW
85
            .await?
×
86
        {
NEW
87
            Body::Empty {} => Ok(()),
×
NEW
88
            _ => Err(Error::BadResponse),
×
89
        }
90
    }
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc