diff --git a/runtime-sdk/src/modules/consensus/mod.rs b/runtime-sdk/src/modules/consensus/mod.rs index 13623b7af7..1b6daae6f0 100644 --- a/runtime-sdk/src/modules/consensus/mod.rs +++ b/runtime-sdk/src/modules/consensus/mod.rs @@ -264,15 +264,10 @@ impl Module { let params = Self::params(); ::Core::use_tx_gas(ctx, params.gas_costs.round_root)?; - if !body.kind.is_valid() { - return Err(Error::InvalidArgument); - } - Ok( Self::round_roots(ctx, body.runtime_id, body.round)?.map(|rr| match body.kind { types::RootKind::IO => rr.io_root, types::RootKind::State => rr.state_root, - _ => panic!("invalid root kind"), // Covered by the is_valid check above. }), ) } diff --git a/runtime-sdk/src/modules/consensus/types.rs b/runtime-sdk/src/modules/consensus/types.rs index 70ab35fb4d..e57bb8228d 100644 --- a/runtime-sdk/src/modules/consensus/types.rs +++ b/runtime-sdk/src/modules/consensus/types.rs @@ -1,26 +1,16 @@ use oasis_core_runtime::common::namespace::Namespace; /// Kind of root. -#[derive(Clone, Debug, Default, cbor::Encode, cbor::Decode)] -#[cfg_attr(test, derive(PartialEq, Eq))] +#[derive(Clone, Debug, cbor::Encode, cbor::Decode)] #[repr(u8)] pub enum RootKind { - #[default] - Invalid = 0, State = 1, IO = 2, } -impl RootKind { - /// Whether the root kind is valid. - pub fn is_valid(&self) -> bool { - !matches!(self, Self::Invalid) - } -} - /// Internal round root call body. -#[derive(Clone, Debug, Default, cbor::Encode, cbor::Decode)] -#[cfg_attr(test, derive(PartialEq, Eq))] +#[derive(Clone, Debug, cbor::Encode, cbor::Decode)] +#[cbor(no_default)] pub struct RoundRootBody { pub runtime_id: Namespace, pub round: u64,