You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust provides a package registry at [crates.io](https://crates.io/), which lets developers conveniently access a plethora of open source libraries to utilize as dependencies in their code. Stylus Rust contracts can take advantage of these crates to simplify their development workflow.
10
10
11
-
While **crates.io** is a fantastic resource, many of these libraries were not designed with the constraints of a blockchain environment in mind. Some produce large binaries that exceed the 24KB compressed size limit of WASM smart contracts on Arbitrum. Many also take advantage of unsupported features such as:
11
+
While **crates.io** is a fantastic resource, many of these libraries were not designed with the constraints of a blockchain environment in mind. Some produce large binaries that exceed the decompressed WASM size limit (`MaxWasmSize`) for Stylus programs on Arbitrum — a chain-configurable ArbOS parameter that defaults to 128 KB, raised to 256 KB at ArbOS 60 and later. Many also take advantage of unsupported features such as:
12
12
13
13
- Random numbers
14
14
- Multi threading
@@ -32,6 +32,8 @@ A Rust library is compatible with Stylus if it meets all of the following:
32
32
33
33
To save developers time on smart contract development for common dependencies, we've curated a list of crates and utilities that we found helpful. Keep in mind that we have not audited this code, and you should always be mindful about pulling dependencies into your codebase, whether they've been audited or not. We provide this list for you to use at your discretion and risk.
34
34
35
+
-[`alloy-primitives`](https://crates.io/crates/alloy-primitives): Core Ethereum primitive types (`U256`, `Address`, `B256`, and more). Re-exported by the Stylus SDK, which currently pins the 1.x line (`1.5.7`), and the foundation for nearly every Stylus contract
36
+
-[`alloy-sol-types`](https://crates.io/crates/alloy-sol-types): Solidity type and ABI encoding/decoding via the `sol!` macro. Used by the Stylus SDK (same 1.x line) for typed calls, events, and errors
35
37
-[`rust_decimal`](https://crates.io/crates/rust_decimal): Decimal number implementation written in pure Rust. Suitable for financial and fixed-precision calculations
36
38
-[`special`](https://crates.io/crates/special): The package provides special functions, which are mathematical functions with special names due to their common usage, such as `sin`, `ln`, `tan`, etc.
37
39
-[`hashbrown`](https://crates.io/crates/hashbrown): Rust port of Google's SwissTable hash map
Copy file name to clipboardExpand all lines: docs/stylus/reference/opcode-hostio-pricing.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ sidebar_position: 3
9
9
10
10
This reference provides the latest gas and ink costs for specific WASM opcodes and host I/Os when using Stylus. For a conceptual introduction to Stylus gas and ink, see [Gas and ink (Stylus)](/stylus/concepts/gas-metering).
11
11
12
+
<VanillaAdmonitiontype="info">The per-opcode and per-host-I/O ink costs in the tables below are subject to change as Stylus matures. They are defined in the upstream Stylus/Arbitrator source rather than in the precompiles, so confirm the current values against that source before relying on exact figures. The ink-to-gas relationship is fixed: 10,000 ink = 1 gas.</VanillaAdmonition>
13
+
12
14
## Opcode costs
13
15
14
16
The Stylus VM charges for WASM opcodes according to the following table, which was determined via a conservative statistical analysis and is expected to change as Stylus matures. Prices may fluctuate across upgrades as our analysis evolves and optimizations are made.
@@ -99,7 +101,7 @@ The Stylus VM charges for WASM opcodes according to the following table, which w
99
101
| 0x77 | I32Rotl | 70 | 0.007 ||
100
102
| 0x78 | I32Rotr | 70 | 0.007 ||
101
103
| 0x79 | I64Clz | 210 | 0.021 ||
102
-
| 0x7a | I64Ctz | 210 | 0.012||
104
+
| 0x7a | I64Ctz | 210 | 0.021||
103
105
| 0x7b | I64Popcnt | 6000 | 0.6 ||
104
106
| 0x7c | I64Add | 100 | 0.01 ||
105
107
| 0x7d | I64Sub | 100 | 0.01 ||
@@ -142,7 +144,7 @@ Note that the values in this table were determined via a conservative statistica
0 commit comments