Polkavm heap (#2)

Use PolkaVM heap
This commit is contained in:
Cyrill Leutwiler
2024-03-22 12:41:41 +01:00
committed by GitHub
parent e83e4f04e6
commit 50f2dd9b74
17 changed files with 220 additions and 131 deletions
+5 -2
View File
@@ -6,10 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hex = { workspace = true }
polkavm = { workspace = true }
alloy-primitives = { workspace = true }
parity-scale-codec = { workspace = true }
revive-solidity = { path = "../solidity" }
era-compiler-llvm-context = { path = "../llvm-context" }
alloy-primitives = { workspace = true }
hex = { workspace = true }
env_logger = { workspace = true }
[dev-dependencies]
alloy-sol-types = { workspace = true }
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract Computation {
function triangle_number(int64 n) public pure returns (int64 sum) {
unchecked {
+3
View File
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract Flipper {
bool coin;
+12
View File
@@ -217,9 +217,21 @@ pub fn call(mut state: State, on: &InstancePre<State>, export: ExportIndex) -> S
let call_args = polkavm::CallArgs::new(&mut state, export);
init_logs();
match on.instantiate().unwrap().call(state_args, call_args) {
Err(polkavm::ExecutionError::Trap(_)) => state,
Err(other) => panic!("unexpected error: {other}"),
Ok(_) => panic!("unexpected return"),
}
}
fn init_logs() {
if std::env::var("RUST_LOG").is_ok() {
#[cfg(test)]
let test = true;
#[cfg(not(test))]
let test = false;
let _ = env_logger::builder().is_test(test).try_init();
}
}