Commit 15a1e21
chore: (A-815) fix l1 tx utils fallback id logic (#22187)
This is purely a correctness fix, no behavioral changes as the id is
only used for store operations and when there is no store, this fallback
is never hit.
**Fallback logic previous:**
If `txs.map` is empty then `this.txs.map(tx => tx.id)` resolves to
nothing and `Math.max(0)` resolves to 0.
Next iteration, `this.txs.map(tx => tx.id)` resolves to 0 and
`Math.max(0, 0)` resolves to 0 again. Collision!
**Fallback logic fixed:**
If `txs.map` is empty then `this.txs.map(tx => tx.id)` resolves to empty
and `Math.max(-1) + 1` resolves to 0.
Next iteration, `this.txs.map(tx => tx.id)` resolves to 0 and
`Math.max(0, -1) + 1` resolves to 1, a unique id.
Co-authored-by: danielntmd <danielntmd@nethermind.io>1 parent babb6c6 commit 15a1e21
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| |||
0 commit comments