-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime-sdk: Consensus module #92
Conversation
Codecov Report
@@ Coverage Diff @@
## main #92 +/- ##
==========================================
+ Coverage 59.42% 63.36% +3.93%
==========================================
Files 41 38 -3
Lines 1649 2001 +352
==========================================
+ Hits 980 1268 +288
- Misses 650 733 +83
+ Partials 19 0 -19
Continue to review full report at Codecov.
|
2d76bcc
to
02f3163
Compare
afa2283
to
2be49e8
Compare
@@ -19,7 +20,11 @@ pub trait Runtime { | |||
/// Runtime version. | |||
const VERSION: version::Version; | |||
|
|||
type Modules: AuthHandler + MigrationHandler + MethodRegistrationHandler + BlockHandler; | |||
type Modules: AuthHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason these are here and not trait bounds on
Module
. @kostko ?
It could be done either way and we always only use modules here so maybe we can move them (in a subsequent issue/PR of course).
aaf3b10
to
9d3a69e
Compare
7b1c9ed
to
85de3fd
Compare
runtime-sdk/src/dispatcher.rs
Outdated
const MODULE: &str = "dispatcher"; | ||
|
||
/// State schema constants. | ||
pub mod state { | ||
/// Map of message idx to message handlers for messages emitted in previous round. | ||
pub const HANDLERS: &[u8] = &[0x01]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably move this under the core
module as that one currently has a similar thing for module migration metadata.
68d6c6c
to
822ad2d
Compare
822ad2d
to
ddee57d
Compare
runtime-sdk/src/context.rs
Outdated
@@ -31,21 +27,126 @@ pub enum Mode { | |||
SimulateTx, | |||
} | |||
|
|||
impl Mode { | |||
/// Mode string representation. | |||
pub fn to_str(&self) -> &'static str { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could implement the Display
trait for Mode
instead and then directly use mode
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So afaik to use it in the logger context as i do bellow (so that it's present in all log invocations) it needs to be threadsafe ('static
, Send
, Sync
).
So I'm not sure if the display trait implementation will be useful. However I should probably move these strings into constants and use these to also implement the Display
trait and maybe rename this method to to_static_str
with a comment on why we need it.
Unless i missed something obvious?
cf8e372
to
86b5a75
Compare
91f5525
to
76bb6bb
Compare
4440e5a
to
a35720c
Compare
ok, I think I'll have the |
05e4bf6
to
a6f076a
Compare
b6757df
to
aaa78a9
Compare
runtime-sdk/src/context.rs
Outdated
} | ||
} | ||
|
||
/// Runtime sdk context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Runtime sdk context. | |
/// Runtime SDK context. |
Amount: *quantity.NewFromUint64(50), | ||
Denomination: types.Denomination("TEST"), | ||
} | ||
log.Info("charlie withdrawing") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also test with dave (secp256k1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, done 👍
aaa78a9
to
48a93bf
Compare
This PR:
consensus
, and higher levelconsensus-accounts
modules to the SDKContext
trait so that module methods can support bothTxContext
andDispatchCtx
TODO:
Only low-level staking support (emitting messages) is available currently. Adding a higher level support for staking (e.g. adding staking to
consensus-accounts
module) will be done later, as it requires oasisprotocol/oasis-core#3862.Requires: