mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-25 10:37:57 +00:00
Generated
+357
-357
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -68,7 +68,7 @@ git2 = "0.19.0"
|
||||
# polkadot-sdk and friends
|
||||
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
|
||||
scale-info = { version = "2.11.1", default-features = false }
|
||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "53f6473c9c8c9d18b5ef0ed02a587757495d1dbf" }
|
||||
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "ddfc608962febad82f154dc1ec39768d6675b329" }
|
||||
|
||||
# llvm
|
||||
[workspace.dependencies.inkwell]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8;
|
||||
|
||||
/* runner.json
|
||||
{
|
||||
"differential": false,
|
||||
"actions": [
|
||||
{
|
||||
"Instantiate": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "GasLimit"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"VerifyCall": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
contract GasLimit {
|
||||
constructor() payable {
|
||||
assert(block.gaslimit == 2000000000000);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ test_spec!(block_hash, "BlockHash", "BlockHash.sol");
|
||||
test_spec!(delegate, "Delegate", "Delegate.sol");
|
||||
test_spec!(gas_price, "GasPrice", "GasPrice.sol");
|
||||
test_spec!(gas_left, "GasLeft", "GasLeft.sol");
|
||||
test_spec!(gas_limit, "GasLimit", "GasLimit.sol");
|
||||
|
||||
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
|
||||
vec![Instantiate {
|
||||
|
||||
@@ -7,12 +7,20 @@ use crate::polkavm::Dependency;
|
||||
|
||||
/// Translates the `gas_limit` instruction.
|
||||
pub fn gas_limit<'ctx, D>(
|
||||
_context: &mut Context<'ctx, D>,
|
||||
context: &mut Context<'ctx, D>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
todo!()
|
||||
let gas_limit_value = context
|
||||
.build_runtime_call(revive_runtime_api::polkavm_imports::GAS_LIMIT, &[])
|
||||
.expect("the gas_limit syscall method should return a value")
|
||||
.into_int_value();
|
||||
|
||||
Ok(context
|
||||
.builder()
|
||||
.build_int_z_extend(gas_limit_value, context.word_type(), "gas_limit")?
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Translates the `gas_price` instruction.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use frame_support::runtime;
|
||||
use frame_support::{runtime, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
|
||||
|
||||
use pallet_revive::AccountId32Mapper;
|
||||
use polkadot_sdk::*;
|
||||
@@ -46,6 +46,7 @@ mod runtime {
|
||||
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
|
||||
impl frame_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
type BlockWeights = BlockWeights;
|
||||
type AccountId = AccountId32;
|
||||
type AccountData = pallet_balances::AccountData<<Runtime as pallet_balances::Config>::Balance>;
|
||||
}
|
||||
@@ -65,6 +66,10 @@ parameter_types! {
|
||||
pub const DepositPerByte: Balance = 1;
|
||||
pub const DepositPerItem: Balance = 2;
|
||||
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
frame_system::limits::BlockWeights::simple_max(
|
||||
Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
|
||||
);
|
||||
}
|
||||
|
||||
#[derive_impl(pallet_revive::config_preludes::TestDefaultConfig)]
|
||||
|
||||
@@ -94,6 +94,8 @@ POLKAVM_IMPORT(void, code_hash, uint32_t, uint32_t)
|
||||
|
||||
POLKAVM_IMPORT(void, deposit_event, uint32_t, uint32_t, uint32_t, uint32_t)
|
||||
|
||||
POLKAVM_IMPORT(uint64_t, gas_limit);
|
||||
|
||||
POLKAVM_IMPORT(void, get_immutable_data, uint32_t, uint32_t);
|
||||
|
||||
POLKAVM_IMPORT(uint64_t, get_storage, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
|
||||
|
||||
@@ -44,6 +44,8 @@ pub static CODE_HASH: &str = "code_hash";
|
||||
|
||||
pub static DEPOSIT_EVENT: &str = "deposit_event";
|
||||
|
||||
pub static GAS_LIMIT: &str = "gas_limit";
|
||||
|
||||
pub static GET_IMMUTABLE_DATA: &str = "get_immutable_data";
|
||||
|
||||
pub static GET_STORAGE: &str = "get_storage";
|
||||
@@ -74,7 +76,7 @@ pub static WEIGHT_TO_FEE: &str = "weight_to_fee";
|
||||
|
||||
/// All imported runtime API symbols.
|
||||
/// Useful for configuring common attributes and linkage.
|
||||
pub static IMPORTS: [&str; 31] = [
|
||||
pub static IMPORTS: [&str; 32] = [
|
||||
SBRK,
|
||||
MEMORY_SIZE,
|
||||
ADDRESS,
|
||||
@@ -92,6 +94,7 @@ pub static IMPORTS: [&str; 31] = [
|
||||
CODE_SIZE,
|
||||
CODE_HASH,
|
||||
DEPOSIT_EVENT,
|
||||
GAS_LIMIT,
|
||||
GET_IMMUTABLE_DATA,
|
||||
GET_STORAGE,
|
||||
HASH_KECCAK_256,
|
||||
|
||||
Reference in New Issue
Block a user