Skip to content

Refactor Ethscription Content Handling and Metadata Storage#137

Merged
RogerPodacter merged 1 commit into
evm-backend-demofrom
fix_collections
Nov 7, 2025
Merged

Refactor Ethscription Content Handling and Metadata Storage#137
RogerPodacter merged 1 commit into
evm-backend-demofrom
fix_collections

Conversation

@RogerPodacter

@RogerPodacter RogerPodacter commented Nov 7, 2025

Copy link
Copy Markdown
Member
  • Updated content URI handling to use contentUriSha for protocol uniqueness checks.
  • Introduced contentHash for deduplication of content, replacing the previous contentSha.
  • Enhanced metadata storage with MetaStoreLib for efficient management of mimetype, protocol, and operation.
  • Updated relevant contracts and tests to reflect changes in content and metadata handling, ensuring consistency across the codebase.

Note

Replaces contentUriHash/contentSha with contentUriSha/contentHash and introduces MetaStoreLib-based deduped metadata; updates contracts, scripts, validators/readers, and tests accordingly.

  • Contracts (Solidity):
    • Replace contentUriHash/contentSha with contentUriSha (sha256 URI) and contentHash (keccak256 content) across storage, events, proofs, and APIs in Ethscriptions, EthscriptionsProver, and GenesisEthscriptions.
    • Introduce MetaStoreLib and metadataStorage; store mimetype/protocol/operation as metaRef (bytes32), removing dynamic mimetype storage and protocolOf mapping.
    • Add DedupedBlobStore for shared inline/SSTORE2 deduped blob storage; update content retrieval/storage paths.
    • Update EthscriptionsRendererLib to decode metadata via MetaStoreLib, render new attributes (e.g., Content Hash, Protocol, Operation), and adjust media URI handling.
    • Extend BytePackLib with pack(bytes); minor interface/ABI changes for getters and pagination unchanged externally.
  • Scripts/Genesis:
    • L2Genesis.s.sol: use contentUriSha throughout; store metaRef; emit updated events; register protocols unchanged.
    • process_genesis_json.rb: write content_uri_sha field.
    • TestTokenUri.s.sol: test cases updated to contentUriSha.
  • Indexer (Ruby):
    • storage_reader.rb: decode new Ethscription tuple (adds content_uri_sha, content_hash, protocol_name, operation).
    • event_decoder.rb: parse EthscriptionCreated with content_uri_sha/content_hash.
    • block_validator.rb: validate content_uri_sha and content_hash instead of old fields; instrumentation keys updated.
    • app/models/ethscription_transaction.rb: calldata builder now encodes contentUriSha.
  • Tests:
    • Broad updates replacing contentUriHashcontentUriSha, contentShacontentHash; new assertions for renderer attributes and prover proof fields; add MetaStore.t.sol.

Written by Cursor Bugbot for commit 847d5de. This will update automatically on new commits. Configure here.

- Updated content URI handling to use `contentUriSha` for protocol uniqueness checks.
- Introduced `contentHash` for deduplication of content, replacing the previous `contentSha`.
- Enhanced metadata storage with `MetaStoreLib` for efficient management of mimetype, protocol, and operation.
- Updated relevant contracts and tests to reflect changes in content and metadata handling, ensuring consistency across the codebase.
@RogerPodacter RogerPodacter requested a review from Copilot November 7, 2025 17:14

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

This PR performs a systematic field renaming across the codebase to improve clarity and consistency. The main changes rename contentUriHash to contentUriSha (clarifying it uses SHA-256) and contentSha to contentHash (clarifying it uses keccak256). Additionally, the PR introduces new libraries for metadata storage (MetaStoreLib, DedupedBlobStore) that consolidate the storage of mimetype, protocol name, and operation into a deduplicated reference system.

  • Renamed hash fields to clarify their hash algorithms: contentUriSha (SHA-256) and contentHash (keccak256)
  • Introduced deduplicated metadata storage system replacing direct mimetype string storage
  • Updated all tests, contracts, and Ruby integration code to use the new field names

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/integration/ethscriptions_creation_spec.rb Updated test expectations to use content_uri_sha instead of content_uri_hash
lib/storage_reader.rb Updated struct field names and comments to reflect renamed fields and new metadata fields
lib/event_decoder.rb Updated decoded event field names to match contract changes
lib/block_validator.rb Updated validation logic and error messages for renamed hash fields
contracts/src/Ethscriptions.sol Core contract updated with renamed fields and new metadata storage system
contracts/src/libraries/MetaStoreLib.sol New library for deduplicated metadata storage
contracts/src/libraries/DedupedBlobStore.sol New library for generic blob storage with deduplication
contracts/src/libraries/BytePackLib.sol Added memory variant of pack function
contracts/src/libraries/EthscriptionsRendererLib.sol Updated to accept decoded metadata parameters and removed escapeJSON call
contracts/test/*.t.sol Updated all test files to use contentUriSha instead of contentUriHash
contracts/script/process_genesis_json.rb Updated to output content_uri_sha field name
contracts/script/L2Genesis.s.sol Updated to read from genesis JSON and use new field names
app/models/ethscription_transaction.rb Updated Ruby model to use content_uri_sha variable naming

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ethscriptions.CreateEthscriptionParams memory params;
params.ethscriptionId = vm.parseJsonBytes32(json, string.concat(basePath, ".transaction_hash"));
params.contentUriHash = vm.parseJsonBytes32(json, string.concat(basePath, ".content_uri_hash"));
params.contentUriSha = vm.parseJsonBytes32(json, string.concat(basePath, ".content_uri_hash"));

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

The JSON field name is incorrect. The Ruby script process_genesis_json.rb writes the field as content_uri_sha (line 17), but this code is trying to read from content_uri_hash. This will cause the genesis script to fail. Change .content_uri_hash to .content_uri_sha to match the JSON output.

Suggested change
params.contentUriSha = vm.parseJsonBytes32(json, string.concat(basePath, ".content_uri_hash"));
params.contentUriSha = vm.parseJsonBytes32(json, string.concat(basePath, ".content_uri_sha"));

Copilot uses AI. Check for mistakes.
mediaType,
'":"',
mediaUri.escapeJSON(),
mediaUri,

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

Removed .escapeJSON() from mediaUri when constructing JSON. While data URIs with base64 encoding typically don't contain characters requiring JSON escaping, this removal could cause issues if the data URI contains quotes, backslashes, or other special characters. Consider restoring .escapeJSON() or documenting why it's safe to omit.

Suggested change
mediaUri,
mediaUri.escapeJSON(),

Copilot uses AI. Check for mistakes.
Comment thread lib/block_validator.rb
stored_sha = stored[:content_hash]&.downcase&.delete_prefix('0x')
expected_sha = creation[:content_hash].downcase.delete_prefix('0x')
content_hash_match = stored_sha == expected_sha
content_hash_check = record_comparison(

Copilot AI Nov 7, 2025

Copy link

Choose a reason for hiding this comment

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

This assignment to content_hash_check is useless, since its value is never read.

Copilot uses AI. Check for mistakes.
@RogerPodacter RogerPodacter merged commit 0ab3868 into evm-backend-demo Nov 7, 2025
8 checks passed
@RogerPodacter RogerPodacter deleted the fix_collections branch November 7, 2025 18:05
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