ethscriptions-protocol / ESIP-Discussion

Public discussions of current draft ESIPs as well as public proposals for new ESIPs
https://docs.ethscriptions.com/esips/what-are-esips
MIT License
9 stars 3 forks source link

How is the ethscription number determined? #12

Open 0xxfu opened 11 months ago

0xxfu commented 11 months ago

I have looked around the docs at https://docs.ethscriptions.com/overview/introducing-ethscriptions but didn't find the ethscription number and valid formats rule. How is the ethscription number determined? what data formats are valid ethscriptions?

RogerPodacter commented 11 months ago

Ethscription numbers aren't an official part of the protocol—ie nothing about the protocol depends on their existing. They are more of a "for fun" thing that indexers can choose to implement or not (and users should take with a grain of salt and not use as identifiers).

We define the ethscription number for ethscription X as "the number of valid ethscriptions before X" where before means "in an earlier block or in the same block with a lower transaction index."

However, this definition itself is "loose" in that we only calculate this once every 20 mins or so, meaning if you query us you will not always get the same thing, which is obviously not acceptable for any real part of the protocol.

The reason is that these numbers are quite difficult to calculate as you can't just keep a running total because of re-orgs.

0xxfu commented 11 months ago

Can we establish a rule for Ethscription numbers similar to Ordinals? Using the transaction hash as the Ethscription ID is inefficient. If the ID rules of the Ethscription are unclear, it hinders the development of related applications and the utilization of the combination between projects.

RogerPodacter commented 11 months ago

The issue is that the Ethscription Number can change during a reorg and Ethscription ids must never change.

But people can use the numbers if they want! The “show ethscription” API endpoint allows you to use them instead of the transaction hash. But if you want to uniquely identify an ethscription using an identifier that will not change, Ethscription Numbers are a poor choice because of the way Ethereum works.

Does this make sense? I admit I don’t know how Ordinals solves this problem as there are reorgs on Bitcoin as well.

On Sun, Dec 17, 2023 at 3:45 AM xfu @.***> wrote:

Can we establish a rule for Ethscription numbers similar to Ordinals? Using the transaction hash as the Ethscription ID is inefficient. If the ID rules of the Ethscription are unclear, it hinders the development of related applications and the utilization of the combination between projects.

— Reply to this email directly, view it on GitHub https://github.com/ethscriptions-protocol/ESIP-Discussion/issues/12#issuecomment-1859075690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOONXUS2257HN7AJ7N64TYJ2WMLAVCNFSM6AAAAABAOH5GBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGA3TKNRZGA . You are receiving this because you commented.Message ID: @.***>

0xxfu commented 11 months ago

I don't know the Ethscription number context. Why will the number change after reindexing the block?

There are two options for the Ethscription number:

  1. Ethscription number = block number + tx index * 100000
  2. Starting from 0, increment each Ethscription by one.

For the option 2:

  1. Define what constitutes a valid Ethscription. A valid Ethscription should adhere to the DataURI scheme. For example: data:image/png;base64, or data:application/json,. Thus, a valid Ethscription is data:*;*.
  2. Indexing starts from block 0 and transaction (tx), and the Ethscription number increments. I think the step 2 should yield a deterministic number.
RogerPodacter commented 11 months ago

The issue is that chain reorgs can affect tx order and therefore ethscription number in both of your proposals. Example:

  1. You observe me ethscribe a beautiful image and note the ethscription number is 100.
  2. The next day you see someone selling ethscription number 100! You buy it.
  3. But no! There was a reorg and now number 100 points to a different ethscription than it did when it was first ethscribed. You just bought the wrong asset!

This is the nature of Ethereum and so ethscription numbers can never be relied on as ids, but rather used "for entertainment only."

Does this make sense?

0xxfu commented 11 months ago

The issue is that chain reorgs can affect tx order and therefore ethscription number in both of your proposals. Example:

  1. You observe me ethscribe a beautiful image and note the ethscription number is 100.
  2. The next day you see someone selling ethscription number 100! You buy it.
  3. But no! There was a reorg and now number 100 points to a different ethscription than it did when it was first ethscribed. You just bought the wrong asset!

This is the nature of Ethereum and so ethscription numbers can never be relied on as ids, but rather used "for entertainment only."

Does this make sense?

Thank you for your answer. Now i understand what's Ethereum's reorg is.

https://beaconscan.com/epochs

image

The transactions will be finally confirmed after the epoch vote, and the final confirmation time will be delayed by approximately 20 minutes compared to the execution nodes. Therefore, the confirmation of the Etherscription number should be determined after the final confirmation of the epoch. After epoch confirmation, there will be no more reorg situations for transactions.

0xxfu commented 10 months ago

The issue is that the Ethscription Number can change during a reorg and Ethscription ids must never change. But people can use the numbers if they want! The “show ethscription” API endpoint allows you to use them instead of the transaction hash. But if you want to uniquely identify an ethscription using an identifier that will not change, Ethscription Numbers are a poor choice because of the way Ethereum works. Does this make sense? I admit I don’t know how Ordinals solves this problem as there are reorgs on Bitcoin as well. On Sun, Dec 17, 2023 at 3:45 AM xfu @.> wrote: Can we establish a rule for Ethscription numbers similar to Ordinals? Using the transaction hash as the Ethscription ID is inefficient. If the ID rules of the Ethscription are unclear, it hinders the development of related applications and the utilization of the combination between projects. — Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOONXUS2257HN7AJ7N64TYJ2WMLAVCNFSM6AAAAABAOH5GBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGA3TKNRZGA . You are receiving this because you commented.Message ID: @.>

https://github.com/ordinals/ord/blob/d791800fa438469ac8102f8f972e2a1e99b16bd4/src/index/reorg.rs

This is related to the reorganization process of Ordinals.

0xxfu commented 10 months ago

The issue is that the Ethscription Number can change during a reorg and Ethscription ids must never change. But people can use the numbers if they want! The “show ethscription” API endpoint allows you to use them instead of the transaction hash. But if you want to uniquely identify an ethscription using an identifier that will not change, Ethscription Numbers are a poor choice because of the way Ethereum works. Does this make sense? I admit I don’t know how Ordinals solves this problem as there are reorgs on Bitcoin as well. On Sun, Dec 17, 2023 at 3:45 AM xfu @.**> wrote: Can we establish a rule for Ethscription numbers similar to Ordinals? Using the transaction hash as the Ethscription ID is inefficient. If the ID rules of the Ethscription are unclear, it hinders the development of related applications and the utilization of the combination between projects. — Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOONXUS2257HN7AJ7N64TYJ2WMLAVCNFSM6AAAAABAOH5GBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGA3TKNRZGA . You are receiving this because you commented.Message ID: @.**>

https://github.com/ordinals/ord/blob/d791800fa438469ac8102f8f972e2a1e99b16bd4/src/index/reorg.rs

This is related to the reorganization process of Ordinals.

https://github.com/ordinals/ord/pull/2320

If a reorg is detected it rolls back the database 6 blocks and reindexes from there.

tunnckoCore commented 8 months ago

@RogerPodacter indexers can choose to implement or not (and users should take with a grain of salt and not use as identifiers).

OOH! That's a relief. :laughing: Was just thinking about that recently. I'm gonna ignore it, definitely :laughing:

@0xxfu Using the transaction hash as the Ethscription ID is inefficient.

Inefficient in what manner? Transaction hashes are universally accepted everywhere and the whole ecosystem can work with them already.

@0xxfu Can we establish a rule for Ethscription numbers similar to Ordinals?

I've been thinking recently (and i even built it into the indexer i'm open sourcing in a bit) to have unique IDs - secure, stable, shorter, and collision resistant - cuid v2.

This can work as "sat names" in fact and who knows what more interesting things. The default length is 24 alphanumeric characters like ek0yimz8ihx6gyljz151ihyl. And the explorer i'm building will also support them. It's not a lot better than transaction hashes but at least a bit.

What you think @RogerPodacter Middle To propose it as ESIP? We can be strict and define them to be with length of 15 or 20 (bigger is better but harder for "end users" ;d).

RogerPodacter commented 8 months ago

Interesting, @tunnckoCore!

I think if we want shorter ids we should tie them to the transaction hash in some way for backwards compatibility. Eg we could encode the 32 bytes as base64 and drop the 0x which would reduce the length from 66 to 43 with no loss in fidelity.

If you wanted to go further you could cut that in half for 128 bits of id space versus 256, which is also more than enough and at least this would give you the ability to convert one-way.

But I don't think the juice is worth the squeeze to force everyone to support a new id scheme now. For that I'd think we need to add a major new feature like multiple ethscriptions per tx which I know I've said I never ever ever ever want to do but who knows never say never.

tunnckoCore commented 8 months ago

@RogerPodacter we need to add a major new feature like multiple ethscriptions per tx which I know I've said I never ever ever ever want to do but who knows never say never.

HA HA HA HA!! Yeah. People are always coming to what WGW is asking or saying :D

Interesting turn of events, I was in support before, but not that much now and kinda relieved cuz recently just thought how harder it gonna be for indexers. Well, not that much tho.. It's only a matter of supporting it through events, which is easy to track so.. :man_shrugging:

It's also cool, cuz Evm.Ink is supporting multiple for quite some months already, it will become part of "regular" ethscriptions now.