Refactor contracts#122
Conversation
There was a problem hiding this comment.
Pull Request Overview
Refactors contracts and decoding logic to support new event schemas, protocol handler improvements, and chunked content storage/rendering.
- Introduces SSTORE2-based chunked content storage and a dedicated renderer library for tokenURI/media generation.
- Updates event signatures (e.g., EthscriptionCreated, ProtocolHandlerSuccess), protocol parameter naming, and custom error usage across contracts and tests.
- Replaces magic timestamps with a shared constant and updates decoders to handle the new event payloads.
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/protocol_event_reader.rb | Updates event signatures and parsing to include ProtocolHandlerSuccess returnData. |
| lib/event_decoder.rb | Adjusts EthscriptionCreated signature keccak and parsing for contentUriHash and new data layout. |
| contracts/test/*.t.sol and *.sol | Aligns tests with new APIs, error selectors, and adds a test-only Ethscriptions variant with storage inspection. |
| contracts/src/libraries/SSTORE2ChunkedStorageLib.sol | Adds chunked SSTORE2 storage and read utilities with assembly concatenation. |
| contracts/src/libraries/EthscriptionsRendererLib.sol | Adds tokenURI/media rendering with attributes including Transaction Hash. |
| contracts/src/libraries/Constants.sol | Adds a shared timestamp constant for backfill completion. |
| contracts/src/L2/L1Block.sol | Uses the shared constant instead of a magic timestamp. |
| contracts/src/EthscriptionsProver.sol | Switches to ownerOf(txHash) helper. |
| contracts/src/Ethscriptions.sol | Major refactor: new events, protocol handling, content storage, renderer usage, and helper APIs. |
| contracts/script/L2Genesis.s.sol | Aligns genesis flow with new content URI uniqueness handling and protocol param rename. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /// @dev This is the keccak256 of "eip1967.proxy.initialized" - 1 | ||
| bytes32 internal constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; | ||
|
|
||
| uint256 internal constant historicalBackfillApproxDoneAt = 1760630077; |
There was a problem hiding this comment.
Consider making historicalBackfillApproxDoneAt public to safely reference it across contracts and tests (e.g., L1Block and EthscriptionsProver tests). Changing to public constant avoids any visibility ambiguities and improves discoverability.
| uint256 internal constant historicalBackfillApproxDoneAt = 1760630077; | |
| uint256 public constant historicalBackfillApproxDoneAt = 1760630077; |
|
|
||
| def self.parse_protocol_handler_success(log) | ||
| # ProtocolHandlerSuccess(bytes32 indexed txHash, string protocol) | ||
| # ProtocolHandlerSuccess(bytes32 indexed txHash, string protocol, bytes returnData) |
There was a problem hiding this comment.
The minimum-length comment is outdated for two dynamic parameters; the ABI head must contain two 32-byte offsets (128 hex chars). Update the comment to reflect 'two 32-byte offsets' rather than 'offset + length' to match the new signature.
|
|
||
| # Decode non-indexed data | ||
| # The data contains a single string parameter | ||
| # The data contains string protocol and bytes returnData parameters |
There was a problem hiding this comment.
The minimum-length comment is outdated for two dynamic parameters; the ABI head must contain two 32-byte offsets (128 hex chars). Update the comment to reflect 'two 32-byte offsets' rather than 'offset + length' to match the new signature.
| if log['data'] && log['data'] != '0x' | ||
| data_hex = log['data'].delete_prefix('0x') | ||
| # Handle empty or very short data | ||
| if data_hex.length < 128 # Minimum for offset (32 bytes) + length (32 bytes) |
There was a problem hiding this comment.
The minimum-length comment is outdated for two dynamic parameters; the ABI head must contain two 32-byte offsets (128 hex chars). Update the comment to reflect 'two 32-byte offsets' rather than 'offset + length' to match the new signature.
| if data_hex.length < 128 # Minimum for offset (32 bytes) + length (32 bytes) | |
| if data_hex.length < 128 # Minimum for two 32-byte offsets (128 hex chars) for two dynamic parameters |
Note
Refactors Ethscriptions to use chunked storage and a renderer lib, updates events and protocol params, tightens prover/manager logic, and aligns scripts/tests and Ruby decoders with the new interfaces.
contentByShawithcontentPointersByShaviaSSTORE2ChunkedStorageLib; dedupe byfirstEthscriptionByContentUri.EthscriptionsRendererLib.ProtocolParams.protocol->protocolName; track withprotocolOf; addownerOf(bytes32)andexists(uint256).EthscriptionCreatedaddscontentUriHashand dropspointerCount;ProtocolHandlerSuccessincludesbytes returnData.NoSuccessfulTransfers,OnlyDepositor, etc.); useConstants.historicalBackfillApproxDoneAt; minor L1 block var rename.ethscriptions.ownerOf(bytes32); trigger flush usingConstants.historicalBackfillApproxDoneAt.initializeexternal; restrict user flows with specific reverts; docs cleanup.firstEthscriptionByContentUrilogic; rename protocol param toprotocolNamein JSON import.Constants.historicalBackfillApproxDoneAt,EthscriptionsRendererLib, andSSTORE2ChunkedStorageLib.EthscriptionCreatedandProtocolHandlerSuccess.EthscriptionsWithTestFunctionsfor chunk introspection; adjust expectations (e.g.,ownerOf(bytes32), new error selectors).Written by Cursor Bugbot for commit e28f496. This will update automatically on new commits. Configure here.