pub struct ResourceControlPolicy {Show 32 fields
pub wasm_fuel_unit: Amount,
pub evm_fuel_unit: Amount,
pub read_operation: Amount,
pub write_operation: Amount,
pub byte_runtime: Amount,
pub byte_read: Amount,
pub byte_written: Amount,
pub blob_read: Amount,
pub blob_published: Amount,
pub blob_byte_read: Amount,
pub blob_byte_published: Amount,
pub byte_stored: Amount,
pub operation: Amount,
pub operation_byte: Amount,
pub message: Amount,
pub message_byte: Amount,
pub service_as_oracle_query: Amount,
pub http_request: Amount,
pub maximum_wasm_fuel_per_block: u64,
pub maximum_evm_fuel_per_block: u64,
pub maximum_service_oracle_execution_ms: u64,
pub maximum_block_size: u64,
pub maximum_bytecode_size: u64,
pub maximum_blob_size: u64,
pub maximum_published_blobs: u64,
pub maximum_block_proposal_size: u64,
pub maximum_bytes_read_per_block: u64,
pub maximum_bytes_written_per_block: u64,
pub maximum_oracle_response_bytes: u64,
pub maximum_http_response_bytes: u64,
pub http_request_timeout_ms: u64,
pub http_request_allow_list: BTreeSet<String>,
}Expand description
A collection of prices and limits associated with block execution.
Fields§
§wasm_fuel_unit: AmountThe price per unit of fuel (aka gas) for Wasm execution.
evm_fuel_unit: AmountThe price per unit of fuel (aka gas) for EVM execution.
read_operation: AmountThe price of one read operation.
write_operation: AmountThe price of one write operation.
byte_runtime: AmountThe price of accessing one byte from the runtime.
byte_read: AmountThe price of reading a byte.
byte_written: AmountThe price of writing a byte
blob_read: AmountThe base price to read a blob.
blob_published: AmountThe base price to publish a blob.
blob_byte_read: AmountThe price to read a blob, per byte.
blob_byte_published: AmountThe price to publish a blob, per byte.
byte_stored: AmountThe price of increasing storage by a byte.
operation: AmountThe base price of adding an operation to a block.
operation_byte: AmountThe additional price for each byte in the argument of a user operation.
message: AmountThe base price of sending a message from a block.
message_byte: AmountThe additional price for each byte in the argument of a user message.
service_as_oracle_query: AmountThe price per query to a service as an oracle.
http_request: AmountThe price for a performing an HTTP request.
maximum_wasm_fuel_per_block: u64The maximum amount of Wasm fuel a block can consume.
maximum_evm_fuel_per_block: u64The maximum amount of EVM fuel a block can consume.
maximum_service_oracle_execution_ms: u64The maximum time in milliseconds that a block can spend executing services as oracles.
maximum_block_size: u64The maximum size of a block. This includes the block proposal itself as well as the execution outcome.
maximum_bytecode_size: u64The maximum size of decompressed contract or service bytecode, in bytes.
maximum_blob_size: u64The maximum size of a blob.
maximum_published_blobs: u64The maximum number of published blobs per block.
maximum_block_proposal_size: u64The maximum size of a block proposal.
maximum_bytes_read_per_block: u64The maximum data to read per block
maximum_bytes_written_per_block: u64The maximum data to write per block
maximum_oracle_response_bytes: u64The maximum size in bytes of an oracle response.
maximum_http_response_bytes: u64The maximum size in bytes of a received HTTP response.
http_request_timeout_ms: u64The maximum amount of time allowed to wait for an HTTP response.
http_request_allow_list: BTreeSet<String>The list of hosts that contracts and services can send HTTP requests to.
Implementations§
Source§impl ResourceControlPolicy
impl ResourceControlPolicy
Sourcepub fn no_fees() -> Self
pub fn no_fees() -> Self
Creates a policy with no cost for anything.
This can be used in tests or benchmarks.
Sourcepub fn maximum_fuel_per_block(&self, vm_runtime: VmRuntime) -> u64
pub fn maximum_fuel_per_block(&self, vm_runtime: VmRuntime) -> u64
The maximum fuel per block according to the VmRuntime.
Sourcepub fn only_fuel() -> Self
pub fn only_fuel() -> Self
Creates a policy with no cost for anything except fuel.
This can be used in tests that need whole numbers in their chain balance.
Sourcepub fn all_categories() -> Self
pub fn all_categories() -> Self
Creates a policy where all categories have a small non-zero cost.
pub fn total_price( &self, resources: &Resources, ) -> Result<Amount, ArithmeticError>
pub fn check_blob_size( &self, content: &BlobContent, ) -> Result<(), ExecutionError>
Trait Implementations§
Source§impl Allocative for ResourceControlPolicy
impl Allocative for ResourceControlPolicy
Source§impl Clone for ResourceControlPolicy
impl Clone for ResourceControlPolicy
Source§fn clone(&self) -> ResourceControlPolicy
fn clone(&self) -> ResourceControlPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceControlPolicy
impl Debug for ResourceControlPolicy
Source§impl Default for ResourceControlPolicy
impl Default for ResourceControlPolicy
Source§impl<'de> Deserialize<'de> for ResourceControlPolicy
impl<'de> Deserialize<'de> for ResourceControlPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ResourceControlPolicy
impl Display for ResourceControlPolicy
Source§impl Hash for ResourceControlPolicy
impl Hash for ResourceControlPolicy
Source§impl InputType for ResourceControlPolicy
impl InputType for ResourceControlPolicy
Source§type RawValueType = ResourceControlPolicy
type RawValueType = ResourceControlPolicy
Source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
Source§fn parse(value: Option<Value>) -> InputValueResult<Self>
fn parse(value: Option<Value>) -> InputValueResult<Self>
Value. None represents undefined.Source§fn as_raw_value(&self) -> Option<&Self::RawValueType>
fn as_raw_value(&self) -> Option<&Self::RawValueType>
Source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
Source§impl OutputType for ResourceControlPolicy
impl OutputType for ResourceControlPolicy
Source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
Source§async fn resolve(
&self,
_: &ContextSelectionSet<'_>,
_field: &Positioned<Field>,
) -> ServerResult<Value>
async fn resolve( &self, _: &ContextSelectionSet<'_>, _field: &Positioned<Field>, ) -> ServerResult<Value>
async_graphql::Value.Source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
Source§impl PartialEq for ResourceControlPolicy
impl PartialEq for ResourceControlPolicy
Source§impl ScalarType for ResourceControlPolicy
impl ScalarType for ResourceControlPolicy
Source§impl Serialize for ResourceControlPolicy
impl Serialize for ResourceControlPolicy
impl Eq for ResourceControlPolicy
impl StructuralPartialEq for ResourceControlPolicy
Auto Trait Implementations§
impl Freeze for ResourceControlPolicy
impl RefUnwindSafe for ResourceControlPolicy
impl Send for ResourceControlPolicy
impl Sync for ResourceControlPolicy
impl Unpin for ResourceControlPolicy
impl UnwindSafe for ResourceControlPolicy
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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<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<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> MockResults for T
impl<T> MockResults for T
Source§type Results = T
type Results = T
MockInstance.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
Source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length bytes from memory from the provided location.
Source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes to memory at the provided location.
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.