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

oasisprotocol / oasis-core / #4695

26 Mar 2024 09:17AM UTC coverage: 47.483% (-0.7%) from 48.192%
#4695

Pull #5602

kostko
go/runtime: Improve manifest validation
Pull Request #5602: Implement ROFL (Runtime OFf-chain Logic)

3 of 133 new or added lines in 9 files covered. (2.26%)

3 existing lines in 3 files now uncovered.

3452 of 7270 relevant lines covered (47.48%)

1.08 hits per line

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

0.0
/runtime/src/rofl.rs
1
//! Runtime OFf-chain Logic (ROFL).
2
use std::sync::Arc;
3

4
use anyhow::{bail, Result};
5
use async_trait::async_trait;
6

7
use crate::{
8
    consensus::roothash,
9
    dispatcher::{Initializer, PostInitState, PreInitState},
10
    host::Host,
11
};
12

13
/// A ROFL application.
14
#[allow(unused_variables)]
15
#[async_trait]
16
pub trait App: Send + Sync {
17
    /// Whether dispatch is supported.
NEW
18
    fn is_supported(&self) -> bool {
×
NEW
19
        true
×
20
    }
21

22
    /// Called on application initialization.
NEW
23
    fn on_init(&mut self, host: Arc<dyn Host>) -> Result<()> {
×
24
        // Default implementation does nothing.
NEW
25
        Ok(())
×
26
    }
27

28
    /// Called on new runtime block being received.
NEW
29
    async fn on_runtime_block(&self, blk: &roothash::AnnotatedBlock) -> Result<()> {
×
30
        // Default implementation does nothing.
NEW
31
        Ok(())
×
32
    }
33

34
    /// Called on new runtime event being detected.
35
    async fn on_runtime_event(
36
        &self,
37
        blk: &roothash::AnnotatedBlock,
38
        tags: &[Vec<u8>],
39
    ) -> Result<()> {
40
        // Default implementation does nothing.
NEW
41
        Ok(())
×
42
    }
43

44
    /// Called for runtime queries.
NEW
45
    async fn query(&self, method: &str, args: Vec<u8>) -> Result<Vec<u8>> {
×
46
        // Default implementation rejects all requests.
NEW
47
        bail!("method not supported");
×
48
    }
49
}
50

51
/// An application which doesn't do anything.
52
pub struct NoopApp;
53

54
#[async_trait]
55
impl App for NoopApp {
NEW
56
    fn is_supported(&self) -> bool {
×
57
        false
58
    }
59
}
60

61
/// Create a new ROFL runtime for an application.
NEW
62
pub fn new(app: Box<dyn App>) -> Box<dyn Initializer> {
×
NEW
63
    Box::new(|_state: PreInitState<'_>| -> PostInitState {
×
NEW
64
        PostInitState {
×
NEW
65
            app: Some(app),
×
NEW
66
            ..Default::default()
×
67
        }
68
    })
69
}
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