Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
xermicus
2025-09-03 20:17:51 +02:00
parent 2f89c743ce
commit a5fbd545c5
9 changed files with 207 additions and 5 deletions
Generated
+79 -5
View File
@@ -6505,8 +6505,8 @@ dependencies = [
"num-integer",
"num-traits",
"pallet-revive-fixtures",
"pallet-revive-proc-macro",
"pallet-revive-uapi",
"pallet-revive-proc-macro 0.3.0",
"pallet-revive-uapi 0.4.0",
"pallet-transaction-payment",
"parity-scale-codec",
"paste",
@@ -6539,7 +6539,7 @@ checksum = "dc1df19ca809f036d6ddf1632039e9db312f92dbe8f9390e6722ad808cd95377"
dependencies = [
"anyhow",
"cargo_metadata",
"pallet-revive-uapi",
"pallet-revive-uapi 0.4.0",
"polkavm-linker 0.21.0",
"sp-core",
"sp-io",
@@ -6558,7 +6558,7 @@ dependencies = [
"pallet-balances",
"pallet-message-queue",
"pallet-revive",
"pallet-revive-uapi",
"pallet-revive-uapi 0.4.0",
"pallet-timestamp",
"pallet-xcm",
"parity-scale-codec",
@@ -6587,6 +6587,17 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "pallet-revive-proc-macro"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb9c42c125790dd4bb0132312bb1a9d3a890b4720c7696d636194311f948e36"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.101",
]
[[package]]
name = "pallet-revive-uapi"
version = "0.4.0"
@@ -6594,12 +6605,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cb8f45102c6279f59f55e0051fc6c26b996619d7842800dfaf3a2583459a1c7"
dependencies = [
"bitflags 1.3.2",
"pallet-revive-proc-macro",
"pallet-revive-proc-macro 0.3.0",
"parity-scale-codec",
"polkavm-derive 0.21.0",
"scale-info",
]
[[package]]
name = "pallet-revive-uapi"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e340813d94f380bc531d4cd5f28685065a14dbbff87ab23507f72c7d2792b82c"
dependencies = [
"bitflags 1.3.2",
"pallet-revive-proc-macro 0.4.0",
"parity-scale-codec",
"polkavm-derive 0.27.0",
"scale-info",
]
[[package]]
name = "pallet-root-offences"
version = "37.0.0"
@@ -7927,6 +7951,12 @@ dependencies = [
"polkavm-assembler 0.24.0",
]
[[package]]
name = "polkavm-common"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19805789e7bf778ac5855f6fe9350353f6a1697c2aab9bfb6fc7c831be54fad"
[[package]]
name = "polkavm-derive"
version = "0.18.0"
@@ -7945,6 +7975,15 @@ dependencies = [
"polkavm-derive-impl-macro 0.21.0",
]
[[package]]
name = "polkavm-derive"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eea46a17d87cbf3c0f3f6156f6300f60cec67cf9eaca296c770e0873f8389d6"
dependencies = [
"polkavm-derive-impl-macro 0.27.0",
]
[[package]]
name = "polkavm-derive-impl"
version = "0.18.1"
@@ -7969,6 +8008,18 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "polkavm-derive-impl"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8abdd1210d96b1dda9ac21199ec469448fd628cea102e2ff0e0df1667c4c3b5f"
dependencies = [
"polkavm-common 0.27.0",
"proc-macro2",
"quote",
"syn 2.0.101",
]
[[package]]
name = "polkavm-derive-impl-macro"
version = "0.18.0"
@@ -7989,6 +8040,16 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "polkavm-derive-impl-macro"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a45173d70138aa1879892c50777ed0d8b0c8556f7678372f09fa1d89bbbddb4"
dependencies = [
"polkavm-derive-impl 0.27.0",
"syn 2.0.101",
]
[[package]]
name = "polkavm-disassembler"
version = "0.24.0"
@@ -8697,6 +8758,19 @@ dependencies = [
"sha3",
]
[[package]]
name = "revive-rul"
version = "0.1.0"
dependencies = [
"anyhow",
"pallet-revive-uapi 0.7.0",
"polkavm-linker 0.24.0",
]
[[package]]
name = "revive-rul-runtime-library"
version = "0.1.0"
[[package]]
name = "revive-runner"
version = "0.1.0"
+1
View File
@@ -71,6 +71,7 @@ tar = "0.4"
toml = "0.8"
assert_cmd = "2.0"
assert_fs = "1.1"
pallet-revive-uapi = "0.7.0"
# polkadot-sdk and friends
codec = { version = "3.7.5", default-features = false, package = "parity-scale-codec" }
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "revive-rul-runtime-library"
version.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
authors.workspace = true
description = "revive compiler rust backend runtime library"
+1
View File
@@ -0,0 +1 @@
//! The revive Rust backend contract runtime library configuration.
+17
View File
@@ -0,0 +1,17 @@
//! The revive Rust backend contract runtime library.
#![no_std]
pub const EVM_WORD_SIZE_BYTES: usize = 32;
/// The emulated linear EVM heap memory size.
pub const MEMORY_SIZE: usize = 1024 * 64;
/// The emulated linear EVM heap memory size.
pub const MEMORY: [u8; MEMORY_SIZE] = [0; MEMORY_SIZE];
pub struct Function<const VARIABLES: usize> {
pub variables: [u8; VARIABLES],
}
impl<const VARIABLES: usize> Function<VARIABLES> {}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "revive-rul"
version.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
authors.workspace = true
description = "revive compiler rust backend"
[dependencies]
anyhow = { workspace = true }
pallet-revive-uapi = { workspace = true }
polkavm-linker = { workspace = true }
+80
View File
@@ -0,0 +1,80 @@
//! The revive rust backend builder module.
const CARGO_TOML: &str = r#"
[package]
name = "contracts"
publish = false
version = "1.0.0"
edition = "2021"
# Make sure this is not included into the workspace
[workspace]
# Binary targets are injected dynamically by the build script.
[[bin]]
# All paths are injected dynamically by the build script.
[dependencies]
uapi = { version = "0.7.0", package = 'pallet-revive-uapi', features = ["unstable-hostfn"], default-features = false }
hex-literal = { version = "0.4.1", default-features = false }
polkavm-derive = { version = "0.27.0" }
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
"#;
const HEADER: &str = r#"
#![no_std]
#![no_main]
include!("../panic_handler.rs");
use uapi::{HostFn, HostFnImpl as api, ReturnFlags};
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
// SAFETY: The unimp instruction is guaranteed to trap
unsafe {
core::arch::asm!("unimp");
core::hint::unreachable_unchecked();
}
}
/// The emulated linear EVM heap memory size.
pub const MEMORY_SIZE: usize = 1024 * 64;
/// The emulated linear EVM heap memory size.
pub const MEMORY: [u8; MEMORY_SIZE] = [0; MEMORY_SIZE];
"#;
const EXPORT_FUNCTION: &str = r#"
#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn
"#;
fn emit(constructor_code: &str, runtime_code: &str) -> String {
let mut buffer = String::from(HEADER);
buffer.reserve(
constructor_code.len() + runtime_code.len() + HEADER.len() + EXPORT_FUNCTION.len() * 2,
);
buffer.push_str(EXPORT_FUNCTION);
buffer.push_str("deploy() {");
buffer.push_str(constructor_code);
buffer.push_str("\n}");
buffer.push_str(EXPORT_FUNCTION);
buffer.push_str("call() {");
buffer.push_str(runtime_code);
buffer.push_str("\n}");
buffer
}
/// Build a PVM blob.
pub fn build(constructor_code: &str, runtime_code: &str) -> Vec<u8> {
let code = emit(constructor_code, runtime_code);
todo!();
}
+5
View File
@@ -0,0 +1,5 @@
//! The revive rust backend library.
pub mod builder;
pub mod yul_library;
+1
View File
@@ -0,0 +1 @@
//! The revive rust backend YUL auxilliary library functions module.