Skip to content

Commit bb67184

Browse files
committed
refactor!: TasmObject is BFieldCodec subtrait
All derived and any proper implementations of the trait `TasmObject` assume that the struct can be encoded according to the rules of `BFieldCodec`. Make this currently implicit assumption explicit.
1 parent 4d55540 commit bb67184

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tasm-lib/src/structure/auto_generated_tasm_object_implementations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::twenty_first::util_types::mmr::mmr_successor_proof::MmrSuccessorProof
1414

1515
macro_rules! derive_tasm_object_for {
1616
($actual:ident using $fake:ident {$($field:ident: $field_type:ty,)* $(,)?}) => {
17-
#[derive(TasmObject)]
17+
#[derive(BFieldCodec, TasmObject)]
1818
struct $fake { $($field: $field_type),* }
1919

2020
impl TasmObject for $actual {
@@ -80,7 +80,7 @@ derive_tasm_object_for!(
8080

8181
// can't use macro: MmrAccumulator has private fields and uses a dedicated
8282
// constructor
83-
#[derive(TasmObject)]
83+
#[derive(BFieldCodec, TasmObject)]
8484
struct FakeMmrAccumulator {
8585
leaf_count: u64,
8686
peaks: Vec<Digest>,

tasm-lib/src/structure/tasm_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub const DEFAULT_MAX_DYN_FIELD_SIZE: u32 = 1u32 << 28;
1818
///
1919
/// The arguments referring to fields are strings. For structs with unnamed fields, the
2020
/// nth field name is implicitly `field_n`.
21-
pub trait TasmObject {
21+
pub trait TasmObject: BFieldCodec {
2222
/// Maximum jump distance for encoded size and length indicators.
2323
/// The field getters will compare any length or size indicator read
2424
/// from memory against this value and crash the VM if the indicator

0 commit comments

Comments
 (0)