Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change artifact format slightly in v1.0 #176

Open
rkalis opened this issue Dec 20, 2023 · 2 comments
Open

Change artifact format slightly in v1.0 #176

rkalis opened this issue Dec 20, 2023 · 2 comments
Labels
cashc-compiler Relates to the cashc compiler
Milestone

Comments

@rkalis
Copy link
Member

rkalis commented Dec 20, 2023

Right now the artifact contains "bytecode", which has ASM-formatted bytecode. Because there are multiple ways to represent bytecode as ASM (multiple ASM representations), it is probably better to have "bytecode" be hex-formatted. Then we can add an "asm" field for users to read it easily.

We could add a few lines of code to the CashScript SDK / utils library to be backwards compatible with the old format.

If we wanted to be completely backwards compatible, we could also leave the old "bytecode" field as-is and add a new "bytecodeHex" field (to be used by libraries).

I personally think it is kind of OK to do some backwards incompatible stuff with the artifact format in v1.0 if it means the format is "cleaner" going forward.

Would love to hear more opinions on this.

@rkalis rkalis added this to the v1 milestone Jan 23, 2024
@mr-zwets mr-zwets added the cashc-compiler Relates to the cashc compiler label Oct 14, 2024
@mr-zwets
Copy link
Member

this idea of having bytecodeHex in the Artifact goes against the idea of #214 to enable template variables in the contract asm

I don't think having the hex there adds much value, instead it makes more sense to me to not have duplicate info in the artifact and make the asm include templated variables

@mr-zwets
Copy link
Member

what could be interesting to add to the Artifact is a contract's fingerprint, this is a hash of the contract logic (minus the data pushes).

Here's a longer explanation:

By transforming sequences of data push operations into normalized count indicators, and applying a hash function to the resulting pattern, we create unique fingerprints that identify contract types regardless of their specific parameter values.
This method facilitates efficient contract classification, analysis, and discovery, while maintaining the ability to reconstruct and filter individual contract instances based on their parameters.

There's more details on the research forum: Smart Contract Fingerprinting: A Method for Pattern Recognition and Analysis in Bitcoin Cash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cashc-compiler Relates to the cashc compiler
Projects
None yet
Development

No branches or pull requests

2 participants