Update dependencies (#503)

- Rust dependencies
- JS dependencies
- Retester submodule

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
xermicus authored and GitHub committed 2026-04-13 14:59:24 +02:00
1 parent b3cd402549
commit 255f5cc31b
18 files changed
+3035 -2444

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"Baseline": 870,
"Computation": 2418,
"DivisionArithmetics": 9327,
"DivisionArithmetics": 9404,
"ERC20": 17160,
"Events": 1662,
"FibonacciIterative": 1427,
@@ -1,5 +1,7 @@
//! The LLVM intrinsic functions.
use std::num::NonZeroU32;
use inkwell::types::BasicType;
use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration;
@@ -37,8 +39,17 @@ impl<'ctx> Intrinsics<'ctx> {
module: &inkwell::module::Module<'ctx>,
) -> Self {
let void_type = llvm.void_type();
let word_type = llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32);
let address_type = llvm.custom_width_int_type(revive_common::BIT_LENGTH_ETH_ADDRESS as u32);
let word_type = llvm
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_WORD as u32).expect("const is non-zero"),
)
.expect("valid integer width");
let address_type = llvm
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_ETH_ADDRESS as u32)
.expect("const is non-zero"),
)
.expect("valid integer width");
let trap = Self::declare(
llvm,
@@ -94,13 +105,21 @@ impl<'ctx> Intrinsics<'ctx> {
llvm: &'ctx inkwell::context::Context,
name: &str,
) -> Vec<inkwell::types::BasicTypeEnum<'ctx>> {
let word_type = llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32);
let word_type = llvm
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_WORD as u32).expect("const is non-zero"),
)
.expect("valid integer width");
match name {
_ if name == Self::FUNCTION_BYTE_SWAP_WORD => vec![word_type.as_basic_type_enum()],
_ if name == Self::FUNCTION_BYTE_SWAP_ETH_ADDRESS => {
vec![llvm
.custom_width_int_type(revive_common::BIT_LENGTH_ETH_ADDRESS as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_ETH_ADDRESS as u32)
.expect("const is non-zero"),
)
.expect("valid integer width")
.as_basic_type_enum()]
}
_ if name == Self::FUNCTION_COUNT_LEADING_ZEROS => {
+27 -6
View File
@@ -3,6 +3,7 @@
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::num::NonZeroU32;
use std::rc::Rc;
use inkwell::debug_info::AsDIScope;
@@ -1208,23 +1209,37 @@ impl<'ctx> Context<'ctx> {
/// Returns the default byte type.
pub fn byte_type(&self) -> inkwell::types::IntType<'ctx> {
self.llvm
.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_BYTE as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Returns the integer type of the specified bit-length.
pub fn integer_type(&self, bit_length: usize) -> inkwell::types::IntType<'ctx> {
self.llvm.custom_width_int_type(bit_length as u32)
self.llvm
.custom_width_int_type(
NonZeroU32::new(bit_length as u32).expect("bit length is non-zero"),
)
.expect("valid integer width")
}
/// Returns the XLEN witdh sized type.
pub fn xlen_type(&self) -> inkwell::types::IntType<'ctx> {
self.llvm.custom_width_int_type(crate::polkavm::XLEN as u32)
self.llvm
.custom_width_int_type(
NonZeroU32::new(crate::polkavm::XLEN as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Returns the PolkaVM native register width sized type.
pub fn register_type(&self) -> inkwell::types::IntType<'ctx> {
self.llvm
.custom_width_int_type(revive_common::BIT_LENGTH_X64 as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_X64 as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Returns the sentinel pointer value.
@@ -1244,13 +1259,19 @@ impl<'ctx> Context<'ctx> {
/// Returns the runtime value width sized type.
pub fn value_type(&self) -> inkwell::types::IntType<'ctx> {
self.llvm
.custom_width_int_type(revive_common::BIT_LENGTH_VALUE as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_VALUE as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Returns the default word type.
pub fn word_type(&self) -> inkwell::types::IntType<'ctx> {
self.llvm
.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_WORD as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Returns the array type with the specified length.
+16 -9
View File
@@ -1,6 +1,7 @@
//! The LLVM context library.
use std::collections::BTreeMap;
use std::num::NonZeroU32;
use crate::debug_config::DebugConfig;
use crate::optimizer::settings::Settings as OptimizerSettings;
@@ -80,7 +81,7 @@ pub fn link(
Ok(format @ ObjectFormat::PVM) => (bytecode.to_vec(), format),
Ok(ObjectFormat::ELF) => {
let symbols = build_symbols(linker_symbols, factory_dependencies)?;
let bytecode_linked = ElfLinker::setup()?.link(bytecode, symbols.as_slice())?;
let bytecode_linked = ElfLinker::setup()?.link(bytecode, &symbols)?;
polkavm_linker(&bytecode_linked, strip_binary)
.map(|pvm| (pvm, ObjectFormat::PVM))
.unwrap_or_else(|error| {
@@ -105,11 +106,17 @@ pub fn link(
pub fn build_symbols(
linker_symbols: &BTreeMap<String, [u8; BYTE_LENGTH_ETH_ADDRESS]>,
factory_dependencies: &BTreeMap<String, [u8; BYTE_LENGTH_WORD]>,
) -> anyhow::Result<inkwell::memory_buffer::MemoryBuffer> {
) -> anyhow::Result<Vec<u8>> {
let context = inkwell::context::Context::create();
let module = context.create_module("symbols");
let word_type = context.custom_width_int_type(BIT_LENGTH_WORD as u32);
let address_type = context.custom_width_int_type(BIT_LENGTH_ETH_ADDRESS as u32);
let word_type = context
.custom_width_int_type(NonZeroU32::new(BIT_LENGTH_WORD as u32).expect("const is non-zero"))
.expect("valid integer width");
let address_type = context
.custom_width_int_type(
NonZeroU32::new(BIT_LENGTH_ETH_ADDRESS as u32).expect("const is non-zero"),
)
.expect("valid integer width");
for (name, value) in linker_symbols {
let global_value = module.add_global(address_type, Default::default(), name);
@@ -137,11 +144,11 @@ pub fn build_symbols(
);
}
Ok(
PolkaVMTargetMachine::new(PolkaVMTarget::PVM, &OptimizerSettings::none())?
.write_to_memory_buffer(&module)
.expect("ICE: the symbols module should be valid"),
)
let target_machine = PolkaVMTargetMachine::new(PolkaVMTarget::PVM, &OptimizerSettings::none())?;
let buffer = target_machine
.write_to_memory_buffer(&module)
.expect("ICE: the symbols module should be valid");
Ok(buffer.as_slice().to_vec())
}
/// Implemented by items which are translated into LLVM IR.
pub trait WriteLLVM {
@@ -59,10 +59,10 @@ impl TargetMachine {
}
/// Writes the LLVM module to a memory buffer.
pub fn write_to_memory_buffer(
pub fn write_to_memory_buffer<'ctx>(
&self,
module: &inkwell::module::Module,
) -> Result<inkwell::memory_buffer::MemoryBuffer, inkwell::support::LLVMString> {
module: &inkwell::module::Module<'ctx>,
) -> Result<inkwell::memory_buffer::MemoryBuffer<'ctx>, inkwell::support::LLVMString> {
match self.target {
Target::PVM => self
.target_machine
+6 -5
View File
@@ -92,11 +92,12 @@ impl ExtBuilder {
.unwrap();
pallet_revive::GenesisConfig::<Runtime> {
debug_settings: Some(DebugSettings::new(
true, // allow unlimited contract size
true, // bypass EIP 3607
true, // enable PVM logs
)),
debug_settings: Some(
DebugSettings::default()
.set_allow_unlimited_contract_size(true)
.set_bypass_eip_3607(true)
.set_enable_pvm_logs(true),
),
..Default::default()
}
.assimilate_storage(&mut t)
-2
View File
@@ -60,7 +60,6 @@ impl pallet_balances::Config for Runtime {
impl pallet_timestamp::Config for Runtime {}
parameter_types! {
pub const UnstableInterface: bool = true;
pub const DebugFlag: bool = true;
pub const DepositPerByte: Balance = 1;
pub const DepositPerItem: Balance = 2;
@@ -81,7 +80,6 @@ impl pallet_revive::Config for Runtime {
type AddressMapper = AccountId32Mapper<Self>;
type RuntimeMemory = ConstU32<{ 512 * 1024 * 1024 }>;
type PVFMemory = ConstU32<{ 1024 * 1024 * 1024 }>;
type UnsafeUnstableInterface = UnstableInterface;
type UploadOrigin = EnsureSigned<Self::AccountId>;
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
+2 -2
View File
@@ -456,7 +456,7 @@ impl Specs {
code,
data,
salt.0,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
results.push(CallResult::Instantiate {
result,
@@ -495,7 +495,7 @@ impl Specs {
deposit_limit: storage_deposit_limit.unwrap_or(DEPOSIT_LIMIT),
},
data,
ExecConfig::new_substrate_tx(),
&ExecConfig::new_substrate_tx(),
);
results.push(CallResult::Exec {
result,
+9 -2
View File
@@ -50,10 +50,17 @@ fn build_module(source_path: &str, bitcode_path: &str, rust_file: &str) {
let lib = Path::new(&out_dir).join(bitcode_path);
compile(source_path, lib.to_str().expect("$OUT_DIR should be UTF-8"));
let bitcode = fs::read(lib).expect("bitcode should have been built");
// `inkwell::MemoryBuffer::create_from_memory_range` requires a trailing nul byte
// (it subtracts one from the length to drop the terminator), so we embed the bitcode
// with an extra nul byte appended.
let mut bitcode = fs::read(lib).expect("bitcode should have been built");
bitcode.push(0);
let padded_name = format!("{bitcode_path}.nul");
let padded_path = Path::new(&out_dir).join(&padded_name);
fs::write(&padded_path, &bitcode).expect("should be able to write in $OUT_DIR");
let len = bitcode.len();
let src_path = Path::new(&out_dir).join(rust_file);
let src = format!("pub static BITCODE: &[u8; {len}] = include_bytes!(\"{bitcode_path}\");");
let src = format!("pub static BITCODE: &[u8; {len}] = include_bytes!(\"{padded_name}\");");
fs::write(src_path, src).expect("should be able to write in $OUT_DIR");
}
+11 -2
View File
@@ -16,6 +16,8 @@
//!
//! [0]: https://llvm.org/docs/LangRef.html#global-variables
use std::num::NonZeroU32;
/// The immutable data module name.
pub static MODULE_NAME: &str = "__evm_immutables";
/// The immutable data global pointer.
@@ -28,13 +30,20 @@ pub static IMMUTABLE_DATA_MAX_SIZE: u32 = 4 * 1024;
/// Returns the immutable data global type.
pub fn data_type(context: &inkwell::context::Context, size: u32) -> inkwell::types::ArrayType<'_> {
context
.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_WORD as u32).expect("const is non-zero"),
)
.expect("valid integer width")
.array_type(size)
}
/// Returns the immutable data size global type.
pub fn size_type(context: &inkwell::context::Context) -> inkwell::types::IntType<'_> {
context.custom_width_int_type(revive_common::BIT_LENGTH_X32 as u32)
context
.custom_width_int_type(
NonZeroU32::new(revive_common::BIT_LENGTH_X32 as u32).expect("const is non-zero"),
)
.expect("valid integer width")
}
/// Creates a LLVM module with the immutable data and its `size` in bytes.
+9 -2
View File
@@ -24,10 +24,17 @@ fn main() {
"failed to assemble the stdlib: {output:?}"
);
let bitcode = fs::read(bitcode_path).expect("bitcode should have been built");
// `inkwell::MemoryBuffer::create_from_memory_range` requires a trailing nul byte
// (it subtracts one from the length to drop the terminator), so we embed the bitcode
// with an extra nul byte appended.
let mut bitcode = fs::read(bitcode_path).expect("bitcode should have been built");
bitcode.push(0);
let padded_lib = "stdlib_nul.bc";
let padded_path = Path::new(&out_dir).join(padded_lib);
fs::write(&padded_path, &bitcode).expect("should be able to write in $OUT_DIR");
let len = bitcode.len();
let src_path = Path::new(&out_dir).join("stdlib.rs");
let src = format!("pub static BITCODE: &[u8; {len}] = include_bytes!(\"{lib}\");");
let src = format!("pub static BITCODE: &[u8; {len}] = include_bytes!(\"{padded_lib}\");");
fs::write(src_path, src).expect("should be able to write in $OUT_DIR");
println!("cargo:rerun-if-changed=stdlib.ll");