pub struct Skeleton {
pub name: &'static str,
pub generation: Option<&'static str>,
/* private fields */
}Fields§
§name: &'static str§generation: Option<&'static str>The compiler generation whose builds this skeleton describes, when
the dumps state one (the SilverScript example contracts are cut once
per generation, under one family name). None for skeletons derived
from observed on-chain instances, whose compiler is not known.
Implementations§
Source§impl Skeleton
impl Skeleton
Sourcepub fn derive(
name: &'static str,
a: &[u8],
b: &[u8],
sentinels: &[(&'static str, Vec<u8>)],
) -> Option<Skeleton>
pub fn derive( name: &'static str, a: &[u8], b: &[u8], sentinels: &[(&'static str, Vec<u8>)], ) -> Option<Skeleton>
Derive a skeleton from two builds of the same contract with different
sentinel arguments. Instructions must align one-to-one: equal
non-push opcodes stay fixed, equal pushes become constants, and
differing pushes become slots — labeled by looking the first build’s
value up in sentinels (constructor order).
Sourcepub fn with_generation(self, generation: &'static str) -> Self
pub fn with_generation(self, generation: &'static str) -> Self
Stamp the compiler generation these dumps came from. A family name stays one name across generations; the stamp is what lets a reader say which compiler cut the build it matched.
Sourcepub fn derive_observed(
name: &'static str,
instances: &[&[u8]],
labels: &[&'static str],
) -> Option<Skeleton>
pub fn derive_observed( name: &'static str, instances: &[&[u8]], labels: &[&'static str], ) -> Option<Skeleton>
Derive a skeleton from two or more distinct on-chain instances of the
same compiled contract (no sentinels available — the arguments are
whatever the deployers used). Instructions must align one-to-one
across every instance: equal non-push opcodes stay fixed, pushes that
agree everywhere become constants, and pushes that differ anywhere
become slots. Slots are labeled in first-occurrence order; two slot
positions whose values agree in every instance are the same inlined
argument and share one label (and match_script will keep enforcing
that they agree). labels must name exactly the distinct slots.
Sourcepub fn emit(&self, args: &[(&str, &[u8])]) -> Option<Vec<u8>>
pub fn emit(&self, args: &[(&str, &[u8])]) -> Option<Vec<u8>>
Re-emit this contract’s compiled bytes with new constructor arguments.
Fixed ops and constant pushes stay byte-identical to the original
build; each slot is re-encoded from args (looked up by label).
Returns None if an argument is missing. The inverse of match_script:
match_script(disassemble(emit(args))) == args.
Sourcepub fn slot_ranges(
&self,
program: &[u8],
) -> Option<Vec<(&'static str, Range<usize>)>>
pub fn slot_ranges( &self, program: &[u8], ) -> Option<Vec<(&'static str, Range<usize>)>>
Match a script against this skeleton; on success return its fields in constructor order. Repeated slots of the same argument must agree. Byte range of each labelled slot inside a program this skeleton matches, in first-occurrence order, one entry per USE (a repeated argument yields one range per site so a splice updates all of them).
Splicing needs offsets, not instruction indices: an unspent cell never
reveals its program, so the only way to read its state is to rebuild a
candidate and check it against the committed hash. Returns None when
the program does not match, so a caller can never splice into bytes
this skeleton does not actually describe.