Skip to content

Commit 379dcbd

Browse files
committed
sim-rs: add parent to RBs
1 parent 684124a commit 379dcbd

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

data/simulation/trace.rust.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ interface RustBlockEvent extends Omit<RustBaseEvent, "message"> {
6363
transactions?: string[];
6464
vrf?: number;
6565
endorsement?: any;
66+
parent?: {
67+
id: string;
68+
slot: number;
69+
producer: string;
70+
};
6671
};
6772
}
6873

data/simulation/trace.rust.schema.json

+14
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@
5757
"index": {
5858
"type": "number"
5959
},
60+
"parent": {
61+
"properties": {
62+
"id": {
63+
"type": "string"
64+
},
65+
"producer": {
66+
"type": "string"
67+
},
68+
"slot": {
69+
"type": "number"
70+
}
71+
},
72+
"type": "object"
73+
},
6074
"transactions": {
6175
"items": {
6276
"type": "string"

sim-rs/sim-core/src/events.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub enum Event {
100100
#[serde(flatten)]
101101
id: BlockId<Node>,
102102
vrf: u64,
103+
parent: Option<BlockId<Node>>,
103104
header_bytes: u64,
104105
endorsement: Option<Endorsement<Node>>,
105106
transactions: Vec<TransactionId>,
@@ -276,6 +277,7 @@ impl EventTracker {
276277
self.send(Event::RBGenerated {
277278
id: self.to_block(block.id),
278279
vrf: block.vrf,
280+
parent: block.parent.map(|id| self.to_block(id)),
279281
header_bytes: block.header_bytes,
280282
endorsement: block.endorsement.as_ref().map(|e| Endorsement {
281283
eb: self.to_endorser_block(e.eb),

sim-rs/sim-core/src/model.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl<Node: Display + Serialize> Serialize for BlockId<Node> {
7070
pub struct Block {
7171
pub id: BlockId,
7272
pub vrf: u64,
73+
pub parent: Option<BlockId>,
7374
pub header_bytes: u64,
7475
pub endorsement: Option<Endorsement>,
7576
pub transactions: Vec<Arc<Transaction>>,

sim-rs/sim-core/src/sim/node.rs

+7
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,19 @@ impl Node {
696696
}
697697
}
698698

699+
let parent = self
700+
.praos
701+
.blocks
702+
.last_key_value()
703+
.map(|(_, block)| block.id);
704+
699705
let block = Block {
700706
id: BlockId {
701707
slot,
702708
producer: self.id,
703709
},
704710
vrf,
711+
parent,
705712
header_bytes: self.sim_config.sizes.block_header,
706713
endorsement,
707714
transactions,

0 commit comments

Comments
 (0)