Skip to main content

Skeleton

Struct Skeleton 

Source
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

Source

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).

Source

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.

Source

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.

Source

pub fn params(&self) -> &[&'static str]

Constructor parameter labels, in order.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.