mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 15:41:04 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 36d9317831 | |||
| 5b3b90db83 | |||
| a4043ecde7 |
Generated
+434
-415
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -51,10 +51,10 @@ path-slash = "0.2"
|
|||||||
rayon = "1.8"
|
rayon = "1.8"
|
||||||
clap = { version = "4", default-features = false, features = ["derive"] }
|
clap = { version = "4", default-features = false, features = ["derive"] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
polkavm-common = "0.13"
|
polkavm-common = "0.14"
|
||||||
polkavm-linker = "0.13"
|
polkavm-linker = "0.14"
|
||||||
polkavm-disassembler = "0.13"
|
polkavm-disassembler = "0.14"
|
||||||
polkavm = "0.13"
|
polkavm = "0.14"
|
||||||
alloy-primitives = { version = "0.8", features = ["serde"] }
|
alloy-primitives = { version = "0.8", features = ["serde"] }
|
||||||
alloy-sol-types = "0.8"
|
alloy-sol-types = "0.8"
|
||||||
alloy-genesis = "0.3"
|
alloy-genesis = "0.3"
|
||||||
@@ -67,7 +67,7 @@ log = { version = "0.4" }
|
|||||||
# 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.1", default-features = false }
|
scale-info = { version = "2.11.1", default-features = false }
|
||||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "35535efb3d9f4d3b3be63c3c2bcf963883ab6af1" }
|
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "db40a66db71e8e7fe943dda5cd0e28078efa2a19" }
|
||||||
|
|
||||||
# llvm
|
# llvm
|
||||||
[workspace.dependencies.inkwell]
|
[workspace.dependencies.inkwell]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"Baseline": 989,
|
"Baseline": 967,
|
||||||
"Computation": 4153,
|
"Computation": 4022,
|
||||||
"DivisionArithmetics": 40614,
|
"DivisionArithmetics": 31787,
|
||||||
"ERC20": 47348,
|
"ERC20": 44233,
|
||||||
"Events": 1781,
|
"Events": 1743,
|
||||||
"FibonacciIterative": 3035,
|
"FibonacciIterative": 2927,
|
||||||
"Flipper": 3448,
|
"Flipper": 3408,
|
||||||
"SHA1": 33553
|
"SHA1": 26009
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
/* runner.json
|
||||||
|
{
|
||||||
|
"differential": true,
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"Upload": {
|
||||||
|
"code": {
|
||||||
|
"Solidity": {
|
||||||
|
"contract": "TransactionOrigin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Instantiate": {
|
||||||
|
"code": {
|
||||||
|
"Solidity": {
|
||||||
|
"contract": "TransactionTester"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Call": {
|
||||||
|
"dest": {
|
||||||
|
"Instantiated": 0
|
||||||
|
},
|
||||||
|
"data": "f8a8fd6d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
contract TransactionTester {
|
||||||
|
constructor() payable {
|
||||||
|
assert(tx.origin == new TransactionOrigin().test());
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() public payable returns (address ret) {
|
||||||
|
ret = tx.origin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract TransactionOrigin {
|
||||||
|
function test() public payable returns (address ret) {
|
||||||
|
assert(msg.sender != tx.origin);
|
||||||
|
|
||||||
|
ret = tx.origin;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,6 +43,7 @@ test_spec!(call, "Caller", "Call.sol");
|
|||||||
test_spec!(transfer, "Transfer", "Transfer.sol");
|
test_spec!(transfer, "Transfer", "Transfer.sol");
|
||||||
test_spec!(return_data_oob, "ReturnDataOob", "ReturnDataOob.sol");
|
test_spec!(return_data_oob, "ReturnDataOob", "ReturnDataOob.sol");
|
||||||
test_spec!(immutables, "Immutables", "Immutables.sol");
|
test_spec!(immutables, "Immutables", "Immutables.sol");
|
||||||
|
test_spec!(transaction, "Transaction", "Transaction.sol");
|
||||||
|
|
||||||
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
|
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
|
||||||
vec![Instantiate {
|
vec![Instantiate {
|
||||||
|
|||||||
@@ -27,12 +27,19 @@ where
|
|||||||
|
|
||||||
/// Translates the `tx.origin` instruction.
|
/// Translates the `tx.origin` instruction.
|
||||||
pub fn origin<'ctx, D>(
|
pub fn origin<'ctx, D>(
|
||||||
_context: &mut Context<'ctx, D>,
|
context: &mut Context<'ctx, D>,
|
||||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||||
where
|
where
|
||||||
D: Dependency + Clone,
|
D: Dependency + Clone,
|
||||||
{
|
{
|
||||||
todo!()
|
let address_type = context.integer_type(revive_common::BIT_LENGTH_ETH_ADDRESS);
|
||||||
|
let address_pointer = context.build_alloca_at_entry(address_type, "origin_address");
|
||||||
|
context.build_store(address_pointer, address_type.const_zero())?;
|
||||||
|
context.build_runtime_call(
|
||||||
|
revive_runtime_api::polkavm_imports::ORIGIN,
|
||||||
|
&[address_pointer.to_int(context).into()],
|
||||||
|
);
|
||||||
|
context.build_load_address(address_pointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translates the `chain_id` instruction.
|
/// Translates the `chain_id` instruction.
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ impl TargetMachine {
|
|||||||
|
|
||||||
/// LLVM target features.
|
/// LLVM target features.
|
||||||
#[cfg(feature = "riscv-zbb")]
|
#[cfg(feature = "riscv-zbb")]
|
||||||
pub const VM_FEATURES: &'static str = "+zbb,+e,+m,+c";
|
pub const VM_FEATURES: &'static str = "+zbb,+a,+e,+m,+c,+fast-unaligned-access,+xtheadcondmov";
|
||||||
#[cfg(not(feature = "riscv-zbb"))]
|
#[cfg(not(feature = "riscv-zbb"))]
|
||||||
pub const VM_FEATURES: &'static str = "+e,+m,+c";
|
pub const VM_FEATURES: &'static str = "+a,+e,+m,+c,+fast-unaligned-access,+xtheadcondmov";
|
||||||
|
|
||||||
/// A shortcut constructor.
|
/// A shortcut constructor.
|
||||||
/// A separate instance for every optimization level is created.
|
/// A separate instance for every optimization level is created.
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ pub enum Code {
|
|||||||
/// A contract blob
|
/// A contract blob
|
||||||
Bytes(Vec<u8>),
|
Bytes(Vec<u8>),
|
||||||
/// Pre-existing contract hash
|
/// Pre-existing contract hash
|
||||||
Hash(Hash),
|
Hash(crate::runtime::Hash),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Code {
|
impl Default for Code {
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ POLKAVM_IMPORT(uint32_t, instantiate, uint32_t)
|
|||||||
|
|
||||||
POLKAVM_IMPORT(void, now, uint32_t)
|
POLKAVM_IMPORT(void, now, uint32_t)
|
||||||
|
|
||||||
|
POLKAVM_IMPORT(void, origin, uint32_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(void, seal_return, uint32_t, uint32_t, uint32_t)
|
POLKAVM_IMPORT(void, seal_return, uint32_t, uint32_t, uint32_t)
|
||||||
|
|
||||||
POLKAVM_IMPORT(uint32_t, set_storage, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
|
POLKAVM_IMPORT(uint32_t, set_storage, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ pub static INSTANTIATE: &str = "instantiate";
|
|||||||
|
|
||||||
pub static NOW: &str = "now";
|
pub static NOW: &str = "now";
|
||||||
|
|
||||||
|
pub static ORIGIN: &str = "origin";
|
||||||
|
|
||||||
pub static RETURN: &str = "seal_return";
|
pub static RETURN: &str = "seal_return";
|
||||||
|
|
||||||
pub static SET_STORAGE: &str = "set_storage";
|
pub static SET_STORAGE: &str = "set_storage";
|
||||||
@@ -60,7 +62,7 @@ pub static VALUE_TRANSFERRED: &str = "value_transferred";
|
|||||||
|
|
||||||
/// All imported runtime API symbols.
|
/// All imported runtime API symbols.
|
||||||
/// Useful for configuring common attributes and linkage.
|
/// Useful for configuring common attributes and linkage.
|
||||||
pub static IMPORTS: [&str; 24] = [
|
pub static IMPORTS: [&str; 25] = [
|
||||||
SBRK,
|
SBRK,
|
||||||
MEMORY_SIZE,
|
MEMORY_SIZE,
|
||||||
ADDRESS,
|
ADDRESS,
|
||||||
@@ -79,6 +81,7 @@ pub static IMPORTS: [&str; 24] = [
|
|||||||
INPUT,
|
INPUT,
|
||||||
INSTANTIATE,
|
INSTANTIATE,
|
||||||
NOW,
|
NOW,
|
||||||
|
ORIGIN,
|
||||||
RETURN,
|
RETURN,
|
||||||
RETURNDATACOPY,
|
RETURNDATACOPY,
|
||||||
RETURNDATASIZE,
|
RETURNDATASIZE,
|
||||||
|
|||||||
Reference in New Issue
Block a user