Introduce portable SilverScript ABI artifacts - #232
Merged
Conversation
Classify compiled bytecode and template hashes with serde_bytes. Add project JSON formatting that keeps short byte arrays inline and wraps larger arrays at 64 bytes per line. Keep ordinary arrays unchanged and use the formatter for silverc output.
Format ABI byte arrays compactly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a portable, versioned ABI artifact shared by the compiler, debugger, and external tooling.
There are no intentional SilverScript syntax, bytecode, or runtime-semantics changes. The practical change is that compiled contract metadata and signature-script encoding no longer depend on the compiler’s
internal AST representation.
Artifact and Tooling Changes
Add
SilAbiArtifact, containing:Add
ArtifactValueas the portable representation for constructor and entrypoint arguments.Add typed encoders for:
Add artifact validation for schema versions, dispatch-tag collisions, bytecode encodings, runtime-state spans, and template hashes.
Preserve compiler-generated dispatch tags in
CompiledContract, while moving the complete public ABI representation intoSilAbiArtifact.Add
SilDebugArtifact, which combines a portable ABI artifact with per-contract debug information.Migrate the debugger to use portable ABI types for argument parsing, entrypoint selection, signature-script generation, and covenant metadata.
CLI Changes
silvercnow emits aSilAbiArtifactJSON document instead of serializing the compiler’s internalCompiledContract.Constructor argument files now use portable artifact values:
[ { "kind": "bytes", "value": [1, 2, 3, 4] }, { "kind": "int", "value": 12345 } ]The generated artifact has the following general shape:
{ "schema_version": 1, "compiler_version": "0.1.0", "structs": [], "contracts": [ { "name": "Example", "runtime_state": { "source": "State", "fields": [] }, "entries": [ { "name": "main", "dispatch_tag": "01234567", "params": [ { "name": "amount", "type": { "kind": "int" } } ] } ], "compiled": { "bytecode": [], "script_hex": "", "template_hash": [], "template_hash_hex": "", "state_span": { "offset": 0, "len": 0 } } } ] }Programmatic Usage
Contracts can be compiled directly into portable artifacts:
Signature scripts are generated from the portable ABI: