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
#[cold] marks a function as rarely called. It is not inlined into a caller that is not cold, unless it is also #[inline(always)], and native code lays out the paths that call it after the rest of their function and places cold functions after all others. It applies to free functions, methods, trait methods and extern functions. See docs/language/inline-and-cold.md. (#1974)
std::native::sha256_compress(state, block) runs one SHA-256 compression over sixteen message words. On x86-64 hosts with the SHA extensions it compiles to the SHA instructions. It is native-only. (#1977)
fe build --backend wasm now builds ingots and workspaces as well as single files. An ingot is one module, which exports the functions marked #[unsafe(export)] anywhere in the ingot, as a native library does; they may call the rest of the ingot and its dependencies. A workspace build writes one module per member with exports, and --ingot <name> selects one member. --wasm-stack-size <bytes> sets the stack size, 1 MiB by default. Released fe binaries now include the WebAssembly backend. (#1981)
std::wasm::Host now provides the std::io streams Stdout, Stderr and Stdin, so code that prints with print! and println! builds for WebAssembly as well as native targets. A module imports them as sys_wasm_stream_write and sys_wasm_stream_read, which examples/wasm/host.mjs implements. See "WebAssembly output" in CLI.md. (#1981)
fe test --backend wasm builds the tests of a suite into one module. A failed test shows what it printed, and a revert fails a test with its data, as on the other backends. #[test(should_revert)] works on wasm, and --native-timeout-secs and --native-output-limit-kib set the limits of wasm tests. (#1981)
A WebAssembly module now passes the revert data of a panic to its host instead of trapping. Overflow, division by zero, a failed assert! and an index outside an array call the import __fe_revert(address, length) with Solidity Panic(uint256) data, and assert! with a message passes Error(string) data. The data of a constant code is a constant of the module, and a module with no memory left for other data calls the import abort(). examples/wasm/host.mjs throws a GuestRevert with the data and its decoded reason. A failed call frees nothing it allocated, so a host makes a new instance of the module after one, as host.mjs does. These imports, sys_wasm_files_read and the new instance after a failure make version 3 of the host contract. (#1985)
std::wasm::files::read(handle, offset, buf) reads a block of a file with one call to the import sys_wasm_files_read, and returns the number of bytes read. examples/wasm/lines.fe reads its input this way. (#1985)
Native executables and fe test --backend native now work on AArch64 Linux, as well as x86-64 Linux and AArch64 macOS. #[cfg(target_arch = "x86_64")] and #[cfg(target_arch = "aarch64")] select items by the architecture that native code runs on, as target_os does by its operating system. (#1989)
A call may give only some of its callee's generic arguments. They fill the parameters from the left, and each parameter left out takes its default or is inferred, so op<1>(c) calls fn op<const N: u64, F: Rules>(_ c: Cursor<F>) with F inferred from c. This applies to function, method and associated function calls, such as self.op_push<1>(c, mut tracer) and T::make<1>(c). A _ among a call's generic arguments is inferred, even for a parameter with a default, so later arguments can be given while earlier ones are inferred: len<_, 3>(xs). _ is only allowed as a whole generic argument of a call, not in signatures or in the types a body writes. A call that leaves a generic parameter uninferred now names it, with the arguments that would give it, as in "cannot infer the type parameter F of op" and "consider giving it explicitly: op<1, F>". (#1990)
Call::forward_delegatecall(addr, gas) forwards the current calldata to addr with DELEGATECALL and returns or reverts with the callee's returndata unchanged, the fallback of a delegating proxy. A proxy built on it spends about 100 to 170 gas a call less than one that copies through MemBuffer, raw_delegatecall and copy_returndata. (#2004)
A trailing ... makes an extern function variadic, so native programs can call C functions such as fcntl(_ fd: i32, _ cmd: i32, ...) -> i32. A call passes the fixed parameters, then unlabelled extra arguments, which must be i32, u32, i64, u64, isize, usize or raw pointers. Variadic functions are native-only and can't be generic, take effects or be const. (#2029)
std::io adds the Read and Write traits, MemReader, and BufReader, which reads a byte or a line at a time (read_line, and read_line_max with a length limit). std::fs adds File and OpenOptions: Fs::open, create and open_with open a file that reads and writes through those traits and closes when dropped. io::Error has new kinds for sockets such as WouldBlock, TimedOut and ConnectionRefused, Error::new(kind) makes an error without a host error number, and Error::code() now returns an Option<i32>. (#2030)
std::net adds networking for native programs on Linux and macOS. Ipv4Addr, Ipv6Addr, IpAddr and SocketAddr parse and print addresses on every target. The Net capability connects a TcpStream, opens a TcpListener or a UdpSocket, and resolves host names with lookup. Poller waits for events on many sockets at once, with epoll on Linux and kqueue on macOS. (#2031)
Bugfixes
Optimized code no longer moves a division, a constant table read or an address computation ahead of the test that guards it: if d != 0 { s += x / d } in a loop could trap with d == 0 on native and WebAssembly targets at -O1 and above. (#1981)
Code after yield in a projection can now write a packed storage field passed as a mut argument or receiver. With fn cached(_ x: mut u8) -> mut u8 writing x after its yield, let b = mut cached(mut pair.b); b = 5 left pair.b unchanged in storage when b shares its slot with other fields. (#1984)
The language server now clears diagnostics for embedded files under their editor-facing file URIs instead of sending duplicate clears under internal builtin-* URIs. (#1986)
A call's effects now follow the rule its arguments do: two effects of one call may not overlap where one is mut, so with (totals.log, mut totals) { settle() } is rejected, naming both effects, as is a storage effect beside a capability that reaches all state. A read-only effect of a snapshot type is, like a snapshot argument, a copy taken at the call, now from storage too, and overlaps nothing. In return a function takes its effects to be disjoint, as its parameters are, and may iterate a view of one effect while it writes another. Two effects whose keys one provider may satisfy, such as generic keys that are one type or two trait keys, may still be given one place, which no longer loses writes through a packed storage lane or reads a stale copy. See docs/language/effects.md. (#1987)
A write to a packed storage field through a mut access is no longer lost when a callee halts successfully, such as through ContractHost::return_*, while the access is open. (#1988)
Invalid trait arguments in a qualified path, such as the mode in <u8 as Tr<ref>>::m(1), are now reported where they are written. Before, a body with one passed fe check and failed to compile, and a signature got only an unrelated error. (#1991)
A trait's associated type default is now checked where it is written, as an impl's associated type is: type B = Option<Missing> reports the missing type instead of nothing. (#1992)
A call that forwards one effect row and gives the components of another, such as read_two(a, Q {}) in a function that uses (A::E, other: Other), no longer passes the callee's effects in the wrong order. (#1994)
A write through a mut trait-key effect that a packed contract field provides, such as with (Counter = b) { bump() }, is no longer lost. with (mut field) { .. } now borrows the field at each call in the block, as it does a local, not for the whole block. (#1995)
A manual contract root with a trait-key effect that nothing provides, such as fn runtime() uses (evm: mut Evm, k: mut Tick), is now reported as a missing effect. It failed with "invalid const value". A test may name its root effect by a projection, such as <EvmTarget as Target>::RootEffect. (#1996)
A parameter that names storage can provide a trait-key effect whose callee returns a borrow of it, such as fn slot_of(z: mut Z) -> mut u256 { with (Cell = z) { mut slot() } } called with a storage place. It failed to compile with an internal error. (#1998)
An impl method that requires an effect its trait method lacks is always rejected. An extra trait-key effect whose bound every type meets, such as uses (any: Anything) with impl<T> Anything for T {}, was accepted. (#2000)
Calling a function generic over an effect row inside a with block that provides part of the row, where the row names a type parameter of the caller, no longer fails with an internal access checking error. (#2000)
A zero-sized temporary can provide a type-key effect, such as with (()) { h() } where h uses e: (). It panicked in code generation. (#2000)
The language server now applies didOpen, didChange and file watcher notifications in the order they arrive, so a request that follows sees the change. Files outside every ingot are reported with the severity of a hint instead of a warning. fe lsp tcp listens on 127.0.0.1 unless --host is given, keeps serving after a connection is reset before it is accepted, and exits after --timeout seconds without clients. The language server no longer panics on a document without a file name, a manifest in a directory that does not exist, a missing current directory, or a dependency cycle that an ingot does not reach. (#2003)
The language server now shows signature help for function calls, such as plain(1, 2), Point::new(1, 2) or a call through a used path, for trait method calls, and for calls in a contract's init and recv arms. Signature help is for the call whose argument list holds the cursor, and its highlighted parameter no longer counts a method's self as the first argument or stops at the arguments written so far, as in plain(1, ). A comma or parenthesis in a closure's parameters, generic arguments, a string or a comment no longer changes the highlighted parameter, and a call written inside format! or println! shows its own signature instead of one the macro expands to. Call hierarchy no longer lists a call of a closure as a call of Fn::call. (#2019)
Performance improvements
A constant that holds a single scalar, such as Id { v: 1 } for struct Id { v: usize }, or (true,), is now passed like a computed value of its type. It used to be stored as data in the contract code, and each function it was passed to got a second copy that read it from there. (#1964)
A contract with an immutable field no longer carries constant data that its code never reads, nor a second copy of the constant data it does read. Contracts in the Liquity and Uniswap v4 ports shrink by up to 1,236 bytes. (#1979)
WebAssembly modules are at least a third smaller, 128- and 256-bit division is 20 to 40 times faster, and mulmod is 30 times faster. Dense matches on integers compile to jump tables, and a recursive function that calls itself in tail position no longer grows the stack, unless the call passes an aggregate from the caller's frame. (#1981)
fe test on the EVM backend now compiles the selected tests of a file or ingot into one contract and deploys it once, instead of compiling and deploying each test on its own. Tests that share code no longer pay to compile it once per test: 20 tests calling a 300-function library went from 24 s to 1.1 s of CPU time. A test's call now has its 4-byte selector as calldata. (#1982)
Native MemVec and MemBuffer growth past 1032 bytes resizes the allocation with C's realloc, which extends a block where it lies, or remaps a large one, instead of copying it. A program that replaces malloc and free must now replace realloc too. (#1983)
Native executables no longer inline the panic reporter into every check that can panic: fevm's is 1.7% smaller at -O2. (#1985)
Changing or saving fe.toml no longer makes the language server recheck the embedded core and std libraries, so diagnostics for workspace projects refresh sooner. (#1986)
Reduce the gas cost of core::num::isqrt(u256) by computing its initial estimate with leading_zeros. (#2005)
Reduce the gas cost of typed call, static, delegate and staticcall_decode when the returned data exactly matches the static ABI size, by decoding directly from the call output buffer. (#2006)
Reduce gas for checked exponentiation with a nonnegative constant base on the EVM by checking the exponent bound once and using EXP. (#2007)
Speed up canonical_dyn_array for u256, i256 and Bytes32 elements by copying their already canonical ABI words as a block. (#2008)
RLP integer encoding and decoding use fewer EVM instructions by computing payload lengths from leading zeros and reading integer payloads a word at a time. (#2009)
Equality comparisons between memory buffers, and between a memory buffer and a byte span, compare full words at a time to reduce EVM gas usage for longer byte sequences. (#2010)
Decimal integer formatting determines the output length from the value's bit length, reducing gas spent counting decimal digits. (#2011)
Numeric text parsing avoids redundant arithmetic overflow checks after validating each digit, reducing EVM gas while preserving overflow rejection. (#2012)
Lowercase and uppercase hexadecimal formatting use packed digit alphabets to reduce EVM gas per output digit. (#2013)
Reduce gas for copying larger Bytes and DynString payloads, including clones, by clearing only the final padding word. (#2014)
Scan byte patterns in 32-byte words to reduce gas for longer searches and splits. Short searches can incur a small additional cost. (#2015)
Reduce gas for UFixed rescale and rescale_up by using the exact ratio between decimal scales. (#2016)
Reduce gas for matching and searching DynString, MemSpan and MemBuffer text patterns by comparing bytes in words. (#2017)
Reduce gas in the 512-bit path of mul_div and its checked and rounding variants by using bit scans and shifts to remove powers of two from the divisor. (#2018)
Reduce gas for ordering DynString and MemBuffer values, especially when they share long prefixes, by comparing bytes in words. (#2021)
Reduce gas for Packed appends near the end of their buffer capacity by replacing the bytewise fallback with bounded integer stores. (#2022)
Base64 decoding uses less EVM gas by handling padding separately from full input blocks. (#2023)
Base58 encoding and decoding use word operations and a packed alphabet lookup to reduce EVM gas usage. (#2024)
Base64 decoding uses about 90% less EVM gas on long inputs by decoding 32 digits at a time with word operations. (#2025)
EIP-712 domain separator calculations can now be folded for constant inputs and reused for identical runtime inputs. (#2026)
Sorted Merkle pair hashes can now be folded for constant inputs and reused for identical runtime inputs. (#2027)
Reduce gas and code size for checked powers with a small constant exponent, such as x ** 2, by computing them with at most two checked multiplications instead of an exponentiation loop. (#2028)
Deprecations and Removals
A provider is no longer chosen by matching its name to the callee's effect label: two providers of one key in a scope are ambiguous where a callee needs it, and with (Key = value) chooses one. A uses list may name a key only once and bind a name only once, and a with may bind a key only once. See docs/language/effects.md. (#1987)
The EffectRef marker trait is removed. Every type implemented it, so a bound naming it can be dropped. (#2000)