feat: emit compact PiecesAddedV2 events - #300
Conversation
4f3fe9e to
b043537
Compare
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
79e5e6c to
ff68e56
Compare
…ces-added Signed-off-by: Jakub Sztandera <oss@kubuxu.com> # Conflicts: # src/PDPVerifier.sol
| /// @notice Deprecated. This event is no longer emitted; use {PiecesAddedV2} instead. | ||
| /// @custom:deprecated Use {PiecesAddedV2} instead. | ||
| event PiecesAdded(uint256 indexed setId, uint256[] pieceIds, Cids.Cid[] pieceCids); |
There was a problem hiding this comment.
I suspect this will be removed from the ABI if it's unused. If so, might as well remove it from here now.
There was a problem hiding this comment.
I don't want to remove it from ABI as indexers still have to support handling it.
I would be ok removing it in the next version after the switchover is complete, but indexers will still have to understand it.
There was a problem hiding this comment.
Solidity includes explicitly declared events in the ABI even when they are not emitted. forge inspect confirms PiecesAdded remains in both ABIs. We intentionally retain it so the current published ABI remains sufficient to decode historical logs; removal can happen after the consumer migration.
| uint256 public constant MAX_PIECE_SIZE_LOG2 = 50; | ||
| uint256 public constant MAX_ENQUEUED_REMOVALS = 2000; | ||
| uint256 private constant PIECE_ID_EVENT_BATCH_SIZE = 100; | ||
| uint256 private constant PIECES_ADDED_EVENT_BATCH_SIZE = 100; |
There was a problem hiding this comment.
how was this calculated?
There was a problem hiding this comment.
The limit is 125, based on the calculated event size, event size limit and running in ref-fvm. 100 was requested by Rod as just a round number.
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
Closes #295
Summary
Adds a compact, ABI-decodable event for piece additions:
Piece IDs derive from
firstPieceId + arrayIndex. CIDs are reconstructed by stripping the leading zero padding fromheaderand appendingroot.Events are limited to 100 pieces. Larger calls emit multiple events with adjusted
firstPieceIdvalues. This is a conservative round-number cap below the theoretical 125-piece FEVM limit.BREAKING (!!): event consumers must upgrade
The legacy
PiecesAddedevent remains in the contract ABI but is no longer emitted. New additions emit onlyPiecesAddedV2.Indexers and all other event consumers must support
PiecesAddedV2before the contract rollout.Historical
PiecesAddedlogs remain decodable. TheaddPiecesfunction ABI and listener callbacks are unchanged.Tracked in #302
Size
PiecesAddedPiecesAddedV2A
PiecesAddedV2event consumes160 + 64nbytes: two 32-byte topics, three 32-byte ABI words, and two 32-byte words per packed CID. A 100-piece event consumes 6,560 bytes. The theoretical maximum is 125 pieces (8,160 bytes), below FEVM’s 8,192-byte limit.Gas
Measured with this PR applied, using the prior batch sizes of 41 pieces with one metadata pair and 61 pieces without metadata as baselines.
Dependency
Relies on #292 enforcing canonical PieceCIDv2 encodings so splitting a CID into
headerandrootpreserves it exactly.Validation