Skip to content

Refactor contracts#122

Merged
RogerPodacter merged 3 commits into
evm-backend-demofrom
refactor
Oct 17, 2025
Merged

Refactor contracts#122
RogerPodacter merged 3 commits into
evm-backend-demofrom
refactor

Conversation

@RogerPodacter

@RogerPodacter RogerPodacter commented Oct 17, 2025

Copy link
Copy Markdown
Member

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.

  • Contracts (Ethscriptions):
    • Storage: Replace contentBySha with contentPointersBySha via SSTORE2ChunkedStorageLib; dedupe by firstEthscriptionByContentUri.
    • Rendering: Move token URI/media building to EthscriptionsRendererLib.
    • API: ProtocolParams.protocol -> protocolName; track with protocolOf; add ownerOf(bytes32) and exists(uint256).
    • Events: EthscriptionCreated adds contentUriHash and drops pointerCount; ProtocolHandlerSuccess includes bytes returnData.
    • Errors/logic: New custom errors (e.g., NoSuccessfulTransfers, OnlyDepositor, etc.); use Constants.historicalBackfillApproxDoneAt; minor L1 block var rename.
  • Prover/L1:
    • Access control via custom errors; use ethscriptions.ownerOf(bytes32); trigger flush using Constants.historicalBackfillApproxDoneAt.
  • ERC20 Token:
    • Add explicit errors; make initialize external; restrict user flows with specific reverts; docs cleanup.
  • TokenManager:
    • Add custom errors; validate/mint/deploy with strict checks; consolidate tick key derivation; expand views; simplify transfer notifications.
  • Genesis Script:
    • Use firstEthscriptionByContentUri logic; rename protocol param to protocolName in JSON import.
  • Libraries:
    • Add Constants.historicalBackfillApproxDoneAt, EthscriptionsRendererLib, and SSTORE2ChunkedStorageLib.
  • Infra/Tools:
    • Update Ruby decoders/signatures for new EthscriptionCreated and ProtocolHandlerSuccess.
  • Tests:
    • Update for new events/errors/APIs; add EthscriptionsWithTestFunctions for 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.

@RogerPodacter RogerPodacter requested a review from Copilot October 17, 2025 15:38
cursor[bot]

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
uint256 internal constant historicalBackfillApproxDoneAt = 1760630077;
uint256 public constant historicalBackfillApproxDoneAt = 1760630077;

Copilot uses AI. Check for mistakes.

def self.parse_protocol_handler_success(log)
# ProtocolHandlerSuccess(bytes32 indexed txHash, string protocol)
# ProtocolHandlerSuccess(bytes32 indexed txHash, string protocol, bytes returnData)

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

# Decode non-indexed data
# The data contains a single string parameter
# The data contains string protocol and bytes returnData parameters

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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)

Copilot AI Oct 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@RogerPodacter RogerPodacter requested a review from Copilot October 17, 2025 17:06
@RogerPodacter RogerPodacter merged commit 3be3820 into evm-backend-demo Oct 17, 2025
2 checks passed
@RogerPodacter RogerPodacter deleted the refactor branch October 17, 2025 17:21
@RogerPodacter RogerPodacter removed the request for review from Copilot March 23, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants