Skip to content

Commit 5e5eb48

Browse files
committed
sim-rs: display more info about EBs with TXs in UI
1 parent 9f22cf1 commit 5e5eb48

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

sim-rs/sim-cli/src/events/aggregate.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl TraceAggregator {
123123
pipeline,
124124
producer,
125125
size_bytes,
126+
transactions,
126127
input_blocks,
127128
endorser_blocks,
128129
..
@@ -134,6 +135,7 @@ impl TraceAggregator {
134135
slot,
135136
pipeline,
136137
bytes: size_bytes,
138+
txs: transactions.iter().map(|tx| tx.id).collect(),
137139
ibs: input_blocks
138140
.iter()
139141
.map(|ib| self.ibs.get(&ib.id).unwrap().clone())
@@ -144,14 +146,16 @@ impl TraceAggregator {
144146
.collect(),
145147
},
146148
);
147-
for tx in input_blocks
149+
for tx_id in input_blocks
148150
.iter()
149151
.map(|ib| self.ibs.get(&ib.id).unwrap())
150152
.flat_map(|ib| ib.txs.iter())
153+
.map(|tx| tx.id)
154+
.chain(transactions.iter().map(|tx| tx.id))
151155
{
152156
let status = self
153157
.tx_statuses
154-
.entry(tx.id)
158+
.entry(tx_id)
155159
.or_insert(TransactionStatus::InEb);
156160
if matches!(status, TransactionStatus::Created | TransactionStatus::InIb) {
157161
*status = TransactionStatus::InEb;
@@ -404,6 +408,7 @@ struct EndorsementBlock {
404408
slot: u64,
405409
pipeline: u64,
406410
bytes: u64,
411+
txs: Vec<TransactionId>,
407412
ibs: Vec<InputBlock>,
408413
ebs: Vec<EndorsementBlock>,
409414
}

ui/src/components/Blocks/modules/BlockContents.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const EndorserBlock: FC<IEndorserBlockProps> = ({ eb, hovered, onHover, onClick
138138
<Box hovered={hovered} onHover={onHover} onClick={onClick}>
139139
Endorser Block
140140
<span className='text-sm'>Pipeline {eb.pipeline}, Slot {eb.slot}</span>
141+
{eb.txs.length ? <span className='text-sm'>References {eb.txs.length} TX(s)</span> : null}
141142
{eb.ibs.length ? <span className='text-sm'>References {eb.ibs.length} IB(s)</span> : null}
142143
{eb.ebs.length ? <span className='text-sm'>References {eb.ebs.length} EB(s)</span> : null}
143144
</Box>

ui/src/components/Blocks/modules/BlockGraph.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export const BlockGraph: FC = ({ }) => {
1515
const data = useMemo(() => {
1616
return blocks.map(b => {
1717
const praosTx = b.txs.reduce((txs, tx) => { txs.add(tx.id); return txs; }, new Set()).size;
18-
const leiosTx = b.cert?.eb.ibs.reduce((txs, ib) => { ib.txs.forEach(tx => txs.add(tx.id)); return txs }, new Set()).size ?? 0;
18+
const leiosTx = b.cert?.eb.ibs.reduce((txs, ib) => { ib.txs.forEach(tx => txs.add(tx.id)); return txs }, new Set()).size ?? 0
19+
+ (b.cert?.eb.txs.length ?? 0);
1920
return {
2021
name: `Slot ${b.slot}`,
2122
praosTx,

ui/src/components/Sim/hooks/utils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const getNodeData = (aggregationNodeDataRef: ISimulationAggregatedDataState, nod
5454

5555
const extractEb = (intermediate: ISimulationIntermediateDataState, ebId: string): ISimulationEndorsementBlock => {
5656
const eb = intermediate.ebs.get(ebId)!;
57+
const txs = eb.txs.map(id => intermediate.txs[Number(id)]);
5758
const ibs = eb.ibs.map(id => {
5859
const ib = intermediate.ibs.get(id)!;
5960
for (const tx of ib.txs) {
@@ -77,6 +78,7 @@ const extractEb = (intermediate: ISimulationIntermediateDataState, ebId: string)
7778
slot: eb.slot,
7879
pipeline: eb.pipeline,
7980
bytes: eb.bytes,
81+
txs,
8082
ibs,
8183
ebs,
8284
}
@@ -145,18 +147,25 @@ export const processMessage = (
145147
trackDataReceived(aggregatedData, intermediate, message.recipient, "pb", message.id);
146148
} else if (message.type === EMessageType.EBGenerated) {
147149
trackDataGenerated(aggregatedData, intermediate, message.producer, "eb", message.id, message.size_bytes);
148-
for (const { id: ibId } of message.input_blocks) {
150+
for (const { id: ibId } of message.input_blocks ?? []) {
149151
for (const tx of intermediate.ibs.get(ibId)?.txs ?? []) {
150152
if (intermediate.txStatuses[tx] === 'created' || intermediate.txStatuses[tx] === 'inIb') {
151153
intermediate.txStatuses[tx] = 'inEb';
152154
}
153155
}
154156
}
157+
for (const { id: txId } of message.transactions ?? []) {
158+
const tx = Number(txId);
159+
if (intermediate.txStatuses[tx] === 'created' || intermediate.txStatuses[tx] === 'inIb') {
160+
intermediate.txStatuses[tx] = 'inEb';
161+
}
162+
}
155163
intermediate.ebs.set(message.id, {
156164
slot: message.slot,
157165
pipeline: message.pipeline,
158166
bytes: message.size_bytes,
159-
ibs: message.input_blocks.map(ib => ib.id),
167+
txs: message.transactions?.map(tx => tx.id) ?? [],
168+
ibs: message.input_blocks?.map(ib => ib.id) ?? [],
160169
ebs: message.endorser_blocks.map(eb => eb.id),
161170
});
162171
} else if (message.type === EMessageType.EBSent) {

ui/src/components/Sim/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ export interface IEndorserBlockGenerated {
159159
pipeline: number;
160160
producer: string;
161161
size_bytes: number;
162-
input_blocks: IInputBlock[]
163-
endorser_blocks: IEndorserBlock[]
162+
transactions?: ITransaction[];
163+
input_blocks?: IInputBlock[];
164+
endorser_blocks: IEndorserBlock[];
165+
}
166+
167+
export interface ITransaction {
168+
id: string;
164169
}
165170

166171
export interface IInputBlock {

ui/src/contexts/SimContext/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface ISimulationEndorsementBlock {
6363
slot: number;
6464
pipeline: number;
6565
bytes: number;
66+
txs: ISimulationTransaction[];
6667
ibs: ISimulationInputBlock[];
6768
ebs: ISimulationEndorsementBlock[];
6869
}
@@ -99,6 +100,7 @@ export interface ISimulationIntermediateEndorsementBlock {
99100
slot: number;
100101
pipeline: number;
101102
bytes: number;
103+
txs: string[];
102104
ibs: string[];
103105
ebs: string[];
104106
}

0 commit comments

Comments
 (0)