pub struct Libraries { /* private fields */ }Expand description
External libraries deployed once per distinct bytecode, and the address each linked contract substitutes for its placeholders.
Solidity links a contract against a library by <File>.sol:<Name>, so
two files that each carry a copy of the same library — bb writes
RelationsLib and ZKTranscriptLib into every verifier it generates —
link by different keys. This groups those keys by the hash of the
library’s creation code, and that hash is the whole rule: identical
bytecode is one deployment, and every contract whose artifact names
that bytecode links against it; bytecode that differs is a deployment
of its own. No version, release or list of which libraries happen to
match takes part — a bb or solc bump that leaves a library identical
keeps it shared, one that changes it separates it, and a contract can
only ever link the bytes it was compiled against.
Each distinct library lands through the canonical CREATE2 deployer under
LIBRARY_SALT, so its address is library_address of its creation
code: the same on every chain, and already holding code on a re-run,
which is how a library that is deployed is found and reused with no
record kept off chain. The deployer is installed if the chain lacks it,
as ensure_factory does; there is no
plain-CREATE fallback, because an address that is not a function of the
code is one a later run cannot find.
Creation code rather than runtime code, because it is what the chain receives and what the address derives from, and equal creation code is equal runtime code.
Implementations§
Source§impl Libraries
impl Libraries
Sourcepub async fn deploy<P: Provider>(
provider: &P,
artifacts: &Artifacts,
contracts: &[(&str, &str)],
sender: Option<Address>,
) -> Result<Self>
pub async fn deploy<P: Provider>( provider: &P, artifacts: &Artifacts, contracts: &[(&str, &str)], sender: Option<Address>, ) -> Result<Self>
Deploy every library the (file, contract) artifacts link, once per
distinct bytecode, skipping any whose code is already at its address.
A library that links libraries of its own has those resolved first.
Contracts that link nothing contribute nothing and cost nothing.
sender opts into explicit nonce management (see
deploy_contract_from).
Sourcepub fn address(&self, file: &str, library: &str) -> Option<Address>
pub fn address(&self, file: &str, library: &str) -> Option<Address>
The address <file>.sol:<library> links against, if it is in the
set.
Sourcepub fn distinct(&self) -> impl Iterator<Item = (B256, Address)> + '_
pub fn distinct(&self) -> impl Iterator<Item = (B256, Address)> + '_
Every distinct library, as the hash of its creation code and its address. One entry per deployment, however many files name it.
Trait Implementations§
impl Eq for Libraries
impl StructuralPartialEq for Libraries
Auto Trait Implementations§
impl Freeze for Libraries
impl RefUnwindSafe for Libraries
impl Send for Libraries
impl Sync for Libraries
impl Unpin for Libraries
impl UnsafeUnpin for Libraries
impl UnwindSafe for Libraries
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more