the base fee opcode (#141)

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
Cyrill Leutwiler
2024-12-19 12:44:15 +01:00
committed by GitHub
parent 3f9771f838
commit 6ad846a285
5 changed files with 379 additions and 365 deletions
Generated
+358 -357
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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 = "ef8886570ea692133c6b49ecb2f1117c0a366ebd" }
polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk", rev = "2cbb4377d36af0aec9ae29dcabc5f5b1e88ed1db" }
# llvm
[workspace.dependencies.inkwell]
@@ -30,7 +30,15 @@ pub fn gas_price<'ctx, D>(
where
D: Dependency + Clone,
{
Ok(context.word_const(1).as_basic_value_enum())
let gas_price_value = context
.build_runtime_call(revive_runtime_api::polkavm_imports::GAS_PRICE, &[])
.expect("the gas_price syscall method should return a value")
.into_int_value();
Ok(context
.builder()
.build_int_z_extend(gas_price_value, context.word_type(), "gas_price")?
.into())
}
/// Translates the `tx.origin` instruction.
+4 -2
View File
@@ -82,8 +82,6 @@ POLKAVM_IMPORT(uint64_t, call_data_load, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, call_data_size)
POLKAVM_IMPORT(uint64_t, delegate_call, uint32_t)
POLKAVM_IMPORT(void, caller, uint32_t)
POLKAVM_IMPORT(void, chain_id, uint32_t)
@@ -92,10 +90,14 @@ POLKAVM_IMPORT(uint64_t, code_size, uint32_t)
POLKAVM_IMPORT(void, code_hash, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, delegate_call, uint32_t)
POLKAVM_IMPORT(void, deposit_event, uint32_t, uint32_t, uint32_t, uint32_t)
POLKAVM_IMPORT(uint64_t, gas_limit);
POLKAVM_IMPORT(uint64_t, gas_price);
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)
+7 -4
View File
@@ -32,8 +32,6 @@ pub static CALL_DATA_LOAD: &str = "call_data_load";
pub static CALL_DATA_SIZE: &str = "call_data_size";
pub static DELEGATE_CALL: &str = "delegate_call";
pub static CALLER: &str = "caller";
pub static CHAIN_ID: &str = "chain_id";
@@ -42,10 +40,14 @@ pub static CODE_SIZE: &str = "code_size";
pub static CODE_HASH: &str = "code_hash";
pub static DELEGATE_CALL: &str = "delegate_call";
pub static DEPOSIT_EVENT: &str = "deposit_event";
pub static GAS_LIMIT: &str = "gas_limit";
pub static GAS_PRICE: &str = "gas_price";
pub static GET_IMMUTABLE_DATA: &str = "get_immutable_data";
pub static GET_STORAGE: &str = "get_storage";
@@ -76,7 +78,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; 32] = [
pub static IMPORTS: [&str; 33] = [
SBRK,
MEMORY_SIZE,
ADDRESS,
@@ -88,13 +90,14 @@ pub static IMPORTS: [&str; 32] = [
CALL_DATA_COPY,
CALL_DATA_LOAD,
CALL_DATA_SIZE,
DELEGATE_CALL,
CALLER,
CHAIN_ID,
CODE_SIZE,
CODE_HASH,
DELEGATE_CALL,
DEPOSIT_EVENT,
GAS_LIMIT,
GAS_PRICE,
GET_IMMUTABLE_DATA,
GET_STORAGE,
HASH_KECCAK_256,