mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 22:41:07 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bec5d60b7c | |||
| 3608a5a143 |
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## v0.1.0-dev.9
|
||||||
|
|
||||||
|
This is a development pre-release.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Syscalls with more than 6 arguments now pack them into registers.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Remove reloading of the resolc.js file (fix issue with relative path in web worker)
|
||||||
|
|
||||||
## v0.1.0-dev.8
|
## v0.1.0-dev.8
|
||||||
|
|
||||||
This is a development pre-release.
|
This is a development pre-release.
|
||||||
|
|||||||
Generated
+380
-396
File diff suppressed because it is too large
Load Diff
+18
-18
@@ -3,7 +3,7 @@ resolver = "2"
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0-dev.8"
|
version = "0.1.0-dev.9"
|
||||||
authors = [
|
authors = [
|
||||||
"Cyrill Leutwiler <cyrill@parity.io>",
|
"Cyrill Leutwiler <cyrill@parity.io>",
|
||||||
"Parity Technologies <admin@parity.io>",
|
"Parity Technologies <admin@parity.io>",
|
||||||
@@ -14,29 +14,29 @@ repository = "https://github.com/paritytech/revive"
|
|||||||
rust-version = "1.81.0"
|
rust-version = "1.81.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
revive-benchmarks = { version = "0.1.0-dev.8", path = "crates/benchmarks" }
|
revive-benchmarks = { version = "0.1.0-dev.9", path = "crates/benchmarks" }
|
||||||
revive-builtins = { version = "0.1.0-dev.8", path = "crates/builtins" }
|
revive-builtins = { version = "0.1.0-dev.9", path = "crates/builtins" }
|
||||||
revive-common = { version = "0.1.0-dev.8", path = "crates/common" }
|
revive-common = { version = "0.1.0-dev.9", path = "crates/common" }
|
||||||
revive-differential = { version = "0.1.0-dev.8", path = "crates/differential" }
|
revive-differential = { version = "0.1.0-dev.9", path = "crates/differential" }
|
||||||
revive-integration = { version = "0.1.0-dev.8", path = "crates/integration" }
|
revive-integration = { version = "0.1.0-dev.9", path = "crates/integration" }
|
||||||
revive-linker = { version = "0.1.0-dev.8", path = "crates/linker" }
|
revive-linker = { version = "0.1.0-dev.9", path = "crates/linker" }
|
||||||
lld-sys = { version = "0.1.0-dev.8", path = "crates/lld-sys" }
|
lld-sys = { version = "0.1.0-dev.9", path = "crates/lld-sys" }
|
||||||
revive-llvm-context = { version = "0.1.0-dev.8", path = "crates/llvm-context" }
|
revive-llvm-context = { version = "0.1.0-dev.9", path = "crates/llvm-context" }
|
||||||
revive-runtime-api = { version = "0.1.0-dev.8", path = "crates/runtime-api" }
|
revive-runtime-api = { version = "0.1.0-dev.9", path = "crates/runtime-api" }
|
||||||
revive-runner = { version = "0.1.0-dev.8", path = "crates/runner" }
|
revive-runner = { version = "0.1.0-dev.9", path = "crates/runner" }
|
||||||
revive-solidity = { version = "0.1.0-dev.8", path = "crates/solidity" }
|
revive-solidity = { version = "0.1.0-dev.9", path = "crates/solidity" }
|
||||||
revive-stdlib = { version = "0.1.0-dev.8", path = "crates/stdlib" }
|
revive-stdlib = { version = "0.1.0-dev.9", path = "crates/stdlib" }
|
||||||
revive-build-utils = { version = "0.1.0-dev.8", path = "crates/build-utils" }
|
revive-build-utils = { version = "0.1.0-dev.9", path = "crates/build-utils" }
|
||||||
|
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
libc = "0.2.169"
|
libc = "0.2.169"
|
||||||
tempfile = "3.8"
|
tempfile = "3.8"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
semver = { version = "1.0", features = [ "serde" ] }
|
semver = { version = "1.0", features = ["serde"] }
|
||||||
itertools = "0.14"
|
itertools = "0.14"
|
||||||
serde = { version = "1.0", features = [ "derive" ] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", features = [ "arbitrary_precision" ] }
|
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
|
||||||
regex = "1.10"
|
regex = "1.10"
|
||||||
once_cell = "1.19"
|
once_cell = "1.19"
|
||||||
num = "0.4.3"
|
num = "0.4.3"
|
||||||
@@ -73,7 +73,7 @@ assert_fs = "1.1.2"
|
|||||||
# polkadot-sdk and friends
|
# polkadot-sdk and friends
|
||||||
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
|
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
|
||||||
scale-info = { version = "2.11.6", default-features = false }
|
scale-info = { version = "2.11.6", default-features = false }
|
||||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "d62a90c8c729acd98c7e9a5cab9803b8b211ffc5" }
|
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "4302f74f7874e6a894578731142a7b310a1449b0" }
|
||||||
|
|
||||||
# llvm
|
# llvm
|
||||||
[workspace.dependencies.inkwell]
|
[workspace.dependencies.inkwell]
|
||||||
|
|||||||
@@ -1339,11 +1339,17 @@ where
|
|||||||
self.llvm.custom_width_int_type(bit_length as u32)
|
self.llvm.custom_width_int_type(bit_length as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the register witdh sized type.
|
/// Returns the XLEN witdh sized type.
|
||||||
pub fn xlen_type(&self) -> inkwell::types::IntType<'ctx> {
|
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(crate::polkavm::XLEN as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the sentinel pointer value.
|
/// Returns the sentinel pointer value.
|
||||||
pub fn sentinel_pointer(&self) -> Pointer<'ctx> {
|
pub fn sentinel_pointer(&self) -> Pointer<'ctx> {
|
||||||
let sentinel_pointer = self
|
let sentinel_pointer = self
|
||||||
|
|||||||
@@ -58,39 +58,48 @@ where
|
|||||||
};
|
};
|
||||||
let flags = context.xlen_type().const_int(flags as u64, false);
|
let flags = context.xlen_type().const_int(flags as u64, false);
|
||||||
|
|
||||||
let argument_type = revive_runtime_api::calling_convention::call(context.llvm());
|
let flags_and_callee = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
let argument_pointer = context.build_alloca_at_entry(argument_type, "call_arguments");
|
|
||||||
let arguments = &[
|
|
||||||
flags.as_basic_value_enum(),
|
|
||||||
address_pointer.value.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
deposit_pointer.value.as_basic_value_enum(),
|
|
||||||
value_pointer.value.as_basic_value_enum(),
|
|
||||||
input_pointer.value.as_basic_value_enum(),
|
|
||||||
input_length.as_basic_value_enum(),
|
|
||||||
output_pointer.value.as_basic_value_enum(),
|
|
||||||
output_length_pointer.value.as_basic_value_enum(),
|
|
||||||
];
|
|
||||||
revive_runtime_api::calling_convention::spill(
|
|
||||||
context.builder(),
|
context.builder(),
|
||||||
argument_pointer.value,
|
context.llvm(),
|
||||||
argument_type,
|
flags,
|
||||||
arguments,
|
address_pointer.to_int(context),
|
||||||
|
"address_and_callee",
|
||||||
|
)?;
|
||||||
|
let deposit_and_value = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
deposit_pointer.to_int(context),
|
||||||
|
value_pointer.to_int(context),
|
||||||
|
"deposit_and_value",
|
||||||
|
)?;
|
||||||
|
let input_data = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
input_length,
|
||||||
|
input_pointer.to_int(context),
|
||||||
|
"input_data",
|
||||||
|
)?;
|
||||||
|
let output_data = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
output_length_pointer.to_int(context),
|
||||||
|
output_pointer.to_int(context),
|
||||||
|
"output_data",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let name = revive_runtime_api::polkavm_imports::CALL;
|
let name = revive_runtime_api::polkavm_imports::CALL;
|
||||||
let argument_pointer = context.builder().build_ptr_to_int(
|
|
||||||
argument_pointer.value,
|
|
||||||
context.xlen_type(),
|
|
||||||
"call_argument_pointer",
|
|
||||||
)?;
|
|
||||||
let success = context
|
let success = context
|
||||||
.build_runtime_call(name, &[argument_pointer.into()])
|
.build_runtime_call(
|
||||||
|
name,
|
||||||
|
&[
|
||||||
|
flags_and_callee.into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
deposit_and_value.into(),
|
||||||
|
input_data.into(),
|
||||||
|
output_data.into(),
|
||||||
|
],
|
||||||
|
)
|
||||||
.unwrap_or_else(|| panic!("{name} should return a value"))
|
.unwrap_or_else(|| panic!("{name} should return a value"))
|
||||||
.into_int_value();
|
.into_int_value();
|
||||||
|
|
||||||
@@ -144,38 +153,41 @@ where
|
|||||||
|
|
||||||
let flags = context.xlen_type().const_int(0u64, false);
|
let flags = context.xlen_type().const_int(0u64, false);
|
||||||
|
|
||||||
let argument_type = revive_runtime_api::calling_convention::delegate_call(context.llvm());
|
let flags_and_callee = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
let argument_pointer = context.build_alloca_at_entry(argument_type, "delegate_call_arguments");
|
|
||||||
let arguments = &[
|
|
||||||
flags.as_basic_value_enum(),
|
|
||||||
address_pointer.value.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
deposit_pointer.value.as_basic_value_enum(),
|
|
||||||
input_pointer.value.as_basic_value_enum(),
|
|
||||||
input_length.as_basic_value_enum(),
|
|
||||||
output_pointer.value.as_basic_value_enum(),
|
|
||||||
output_length_pointer.value.as_basic_value_enum(),
|
|
||||||
];
|
|
||||||
revive_runtime_api::calling_convention::spill(
|
|
||||||
context.builder(),
|
context.builder(),
|
||||||
argument_pointer.value,
|
context.llvm(),
|
||||||
argument_type,
|
flags,
|
||||||
arguments,
|
address_pointer.to_int(context),
|
||||||
|
"address_and_callee",
|
||||||
|
)?;
|
||||||
|
let input_data = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
input_length,
|
||||||
|
input_pointer.to_int(context),
|
||||||
|
"input_data",
|
||||||
|
)?;
|
||||||
|
let output_data = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
output_length_pointer.to_int(context),
|
||||||
|
output_pointer.to_int(context),
|
||||||
|
"output_data",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let name = revive_runtime_api::polkavm_imports::DELEGATE_CALL;
|
let name = revive_runtime_api::polkavm_imports::DELEGATE_CALL;
|
||||||
let argument_pointer = context.builder().build_ptr_to_int(
|
|
||||||
argument_pointer.value,
|
|
||||||
context.xlen_type(),
|
|
||||||
"delegate_call_argument_pointer",
|
|
||||||
)?;
|
|
||||||
let success = context
|
let success = context
|
||||||
.build_runtime_call(name, &[argument_pointer.into()])
|
.build_runtime_call(
|
||||||
|
name,
|
||||||
|
&[
|
||||||
|
flags_and_callee.into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
deposit_pointer.to_int(context).into(),
|
||||||
|
input_data.into(),
|
||||||
|
output_data.into(),
|
||||||
|
],
|
||||||
|
)
|
||||||
.unwrap_or_else(|| panic!("{name} should return a value"))
|
.unwrap_or_else(|| panic!("{name} should return a value"))
|
||||||
.into_int_value();
|
.into_int_value();
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,6 @@ where
|
|||||||
|
|
||||||
let code_hash_pointer = context.build_heap_gep(input_offset, input_length)?;
|
let code_hash_pointer = context.build_heap_gep(input_offset, input_length)?;
|
||||||
|
|
||||||
let input_data_pointer = context.build_gep(
|
|
||||||
code_hash_pointer,
|
|
||||||
&[context
|
|
||||||
.xlen_type()
|
|
||||||
.const_int(revive_common::BYTE_LENGTH_WORD as u64, false)],
|
|
||||||
context.byte_type(),
|
|
||||||
"input_ptr_parameter_offset",
|
|
||||||
);
|
|
||||||
|
|
||||||
let value_pointer = context.build_alloca_at_entry(context.value_type(), "transferred_value");
|
let value_pointer = context.build_alloca_at_entry(context.value_type(), "transferred_value");
|
||||||
context.build_store(value_pointer, value)?;
|
context.build_store(value_pointer, value)?;
|
||||||
|
|
||||||
@@ -56,40 +47,38 @@ where
|
|||||||
let deposit_pointer = context.build_alloca_at_entry(context.word_type(), "deposit_pointer");
|
let deposit_pointer = context.build_alloca_at_entry(context.word_type(), "deposit_pointer");
|
||||||
context.build_store(deposit_pointer, context.word_type().const_all_ones())?;
|
context.build_store(deposit_pointer, context.word_type().const_all_ones())?;
|
||||||
|
|
||||||
let argument_type = revive_runtime_api::calling_convention::instantiate(context.llvm());
|
let deposit_and_value = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
let argument_pointer = context.build_alloca_at_entry(argument_type, "instantiate_arguments");
|
|
||||||
let arguments = &[
|
|
||||||
code_hash_pointer.value.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
context
|
|
||||||
.integer_const(revive_common::BIT_LENGTH_X64, u64::MAX)
|
|
||||||
.as_basic_value_enum(),
|
|
||||||
deposit_pointer.value.as_basic_value_enum(),
|
|
||||||
value_pointer.value.as_basic_value_enum(),
|
|
||||||
input_data_pointer.value.as_basic_value_enum(),
|
|
||||||
input_length.as_basic_value_enum(),
|
|
||||||
address_pointer.value.as_basic_value_enum(),
|
|
||||||
context.sentinel_pointer().value.as_basic_value_enum(),
|
|
||||||
context.sentinel_pointer().value.as_basic_value_enum(),
|
|
||||||
salt_pointer.value.as_basic_value_enum(),
|
|
||||||
];
|
|
||||||
revive_runtime_api::calling_convention::spill(
|
|
||||||
context.builder(),
|
context.builder(),
|
||||||
argument_pointer.value,
|
context.llvm(),
|
||||||
argument_type,
|
deposit_pointer.to_int(context),
|
||||||
arguments,
|
value_pointer.to_int(context),
|
||||||
|
"deposit_and_value",
|
||||||
|
)?;
|
||||||
|
let input_data = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
input_length,
|
||||||
|
code_hash_pointer.to_int(context),
|
||||||
|
"input_data",
|
||||||
|
)?;
|
||||||
|
let address_and_salt = revive_runtime_api::calling_convention::pack_hi_lo_reg(
|
||||||
|
context.builder(),
|
||||||
|
context.llvm(),
|
||||||
|
address_pointer.to_int(context),
|
||||||
|
salt_pointer.to_int(context),
|
||||||
|
"output_data",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let argument_pointer = context.builder().build_ptr_to_int(
|
|
||||||
argument_pointer.value,
|
|
||||||
context.xlen_type(),
|
|
||||||
"instantiate_argument_pointer",
|
|
||||||
)?;
|
|
||||||
context.build_runtime_call(
|
context.build_runtime_call(
|
||||||
revive_runtime_api::polkavm_imports::INSTANTIATE,
|
revive_runtime_api::polkavm_imports::INSTANTIATE,
|
||||||
&[argument_pointer.into()],
|
&[
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
deposit_and_value.into(),
|
||||||
|
input_data.into(),
|
||||||
|
context.register_type().const_all_ones().into(),
|
||||||
|
address_and_salt.into(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
let address = context.build_byte_swap(context.build_load(address_pointer, "address")?)?;
|
let address = context.build_byte_swap(context.build_load(address_pointer, "address")?)?;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ impl ExtBuilder {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
pallet_balances::GenesisConfig::<Runtime> {
|
pallet_balances::GenesisConfig::<Runtime> {
|
||||||
balances: self.balance_genesis_config,
|
balances: self.balance_genesis_config,
|
||||||
|
dev_accounts: None,
|
||||||
}
|
}
|
||||||
.assimilate_storage(&mut t)
|
.assimilate_storage(&mut t)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -87,6 +87,5 @@ impl pallet_revive::Config for Runtime {
|
|||||||
type UploadOrigin = EnsureSigned<AccountId32>;
|
type UploadOrigin = EnsureSigned<AccountId32>;
|
||||||
type InstantiateOrigin = EnsureSigned<AccountId32>;
|
type InstantiateOrigin = EnsureSigned<AccountId32>;
|
||||||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
||||||
type Debug = ();
|
|
||||||
type ChainId = ConstU64<420_420_420>;
|
type ChainId = ConstU64<420_420_420>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
use inkwell::{
|
use inkwell::{builder::Builder, context::Context, module::Module, values::IntValue};
|
||||||
builder::Builder,
|
|
||||||
context::Context,
|
|
||||||
module::Module,
|
|
||||||
types::{BasicType, StructType},
|
|
||||||
values::{BasicValueEnum, PointerValue},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Creates a module that sets the PolkaVM minimum stack size to [`size`] if linked in.
|
/// Creates a module that sets the PolkaVM minimum stack size to [`size`] if linked in.
|
||||||
pub fn min_stack_size<'context>(
|
pub fn min_stack_size<'context>(
|
||||||
@@ -21,115 +15,23 @@ pub fn min_stack_size<'context>(
|
|||||||
module
|
module
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper for building function calls with stack spilled arguments.
|
/// Helper for packing two 32 bit integer values into a 64 bit integer value.
|
||||||
/// - `pointer`: points to a struct of the packed argument struct type
|
pub fn pack_hi_lo_reg<'ctx>(
|
||||||
/// - `type`: the packed argument struct type
|
|
||||||
/// - `arguments`: a correctly ordered list of the struct field values
|
|
||||||
pub fn spill<'ctx>(
|
|
||||||
builder: &Builder<'ctx>,
|
builder: &Builder<'ctx>,
|
||||||
pointer: PointerValue<'ctx>,
|
context: &'ctx Context,
|
||||||
r#type: StructType<'ctx>,
|
hi: IntValue<'ctx>,
|
||||||
arguments: &[BasicValueEnum<'ctx>],
|
lo: IntValue<'ctx>,
|
||||||
) -> anyhow::Result<()> {
|
name: &str,
|
||||||
for index in 0..r#type.get_field_types().len() {
|
) -> anyhow::Result<IntValue<'ctx>> {
|
||||||
let field_pointer = builder.build_struct_gep(
|
assert_eq!(hi.get_type(), context.i32_type());
|
||||||
r#type,
|
assert_eq!(lo.get_type(), context.i32_type());
|
||||||
pointer,
|
|
||||||
index as u32,
|
|
||||||
&format!("spill_parameter_{}", index),
|
|
||||||
)?;
|
|
||||||
let field_value = arguments
|
|
||||||
.get(index)
|
|
||||||
.ok_or_else(|| anyhow::anyhow!("invalid index {index} for struct type {}", r#type))?;
|
|
||||||
builder.build_store(field_pointer, *field_value)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
let lo_part = builder.build_int_z_extend(lo, context.i64_type(), &format!("{name}_lo_part"))?;
|
||||||
}
|
let hi_part = builder.build_int_z_extend(hi, context.i64_type(), &format!("{name}_hi_part"))?;
|
||||||
|
let hi_part_shifted = builder.build_left_shift(
|
||||||
/// Returns a packed struct argument type for the `instantiate` API.
|
hi_part,
|
||||||
pub fn instantiate(context: &Context) -> StructType {
|
context.i64_type().const_int(32, false),
|
||||||
context.struct_type(
|
&format!("{name}_hi_part_shifted"),
|
||||||
&[
|
)?;
|
||||||
// code_hash_ptr: u32,
|
Ok(builder.build_or(hi_part_shifted, lo_part, name)?)
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// ref_time_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// proof_size_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// deposit_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// value_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_len: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// address_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_len_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// salt_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a packed struct argument type for the `call` API.
|
|
||||||
pub fn call(context: &Context) -> StructType {
|
|
||||||
context.struct_type(
|
|
||||||
&[
|
|
||||||
// flags: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// address_ptr:
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// ref_time_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// proof_size_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// deposit_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// value_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_len: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_len_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a packed struct argument type for the `delegate_call` API.
|
|
||||||
pub fn delegate_call(context: &Context) -> StructType {
|
|
||||||
context.struct_type(
|
|
||||||
&[
|
|
||||||
// flags: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// address_ptr:
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// ref_time_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// proof_size_limit: u64,
|
|
||||||
context.i64_type().as_basic_type_enum(),
|
|
||||||
// deposit_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// input_data_len: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
// output_len_ptr: u32,
|
|
||||||
context.i32_type().as_basic_type_enum(),
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ POLKAVM_IMPORT(void, block_hash, uint32_t, uint32_t)
|
|||||||
|
|
||||||
POLKAVM_IMPORT(void, block_number, uint32_t)
|
POLKAVM_IMPORT(void, block_number, uint32_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(uint64_t, call, uint32_t)
|
POLKAVM_IMPORT(uint64_t, call, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(uint64_t, call_data_copy, uint32_t, uint32_t, uint32_t)
|
POLKAVM_IMPORT(uint64_t, call_data_copy, uint32_t, uint32_t, uint32_t)
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ POLKAVM_IMPORT(uint64_t, code_size, uint32_t)
|
|||||||
|
|
||||||
POLKAVM_IMPORT(void, code_hash, uint32_t, uint32_t)
|
POLKAVM_IMPORT(void, code_hash, uint32_t, uint32_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(uint64_t, delegate_call, uint32_t)
|
POLKAVM_IMPORT(uint64_t, delegate_call, uint64_t, uint64_t, uint64_t, uint32_t, uint64_t, uint64_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(void, deposit_event, uint32_t, uint32_t, uint32_t, uint32_t)
|
POLKAVM_IMPORT(void, deposit_event, uint32_t, uint32_t, uint32_t, uint32_t)
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ POLKAVM_IMPORT(uint64_t, get_storage, uint32_t, uint32_t, uint32_t, uint32_t, ui
|
|||||||
|
|
||||||
POLKAVM_IMPORT(void, hash_keccak_256, uint32_t, uint32_t, uint32_t)
|
POLKAVM_IMPORT(void, hash_keccak_256, uint32_t, uint32_t, uint32_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(uint64_t, instantiate, uint32_t)
|
POLKAVM_IMPORT(uint64_t, instantiate, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(void, now, uint32_t)
|
POLKAVM_IMPORT(void, now, uint32_t)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user