Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ triehash = "0.8"
walkdir = "2.5"

# rwasm
rwasm = { git = "https://github.com/fluentlabs-xyz/rwasm", branch = "devel", default-features = false }
rwasm = { version = "0.3.2", default-features = false }
#rwasm = { path = "../rwasm", default-features = false }

[workspace.package]
Expand Down
4 changes: 3 additions & 1 deletion crates/handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bytecode.workspace = true

auto_impl.workspace = true
derive-where.workspace = true
cfg-if.workspace = true

# Optional
serde = { version = "1.0", default-features = false, features = [
Expand Down Expand Up @@ -73,4 +74,5 @@ serde = [
"derive-where/serde"
]
serde-json = ["serde"]
debug-print = []
debug-print = []
fluent-testnet = [] # Compatibility with Fluent testnet
16 changes: 14 additions & 2 deletions crates/handler/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use context_interface::{
Block, Cfg, ContextTr,
};
use core::cmp;
use interpreter::gas::{self, InitialAndFloorGas, FUEL_DENOM_RATE};
use interpreter::gas::{self, InitialAndFloorGas};
use primitives::wasm::WASM_MAGIC_BYTES;
use primitives::{eip4844, hardfork::SpecId, wasm::wasm_max_code_size, B256};

Expand Down Expand Up @@ -299,8 +299,20 @@ pub fn validate_initial_tx_gas(
}

let mut floor_gas = gas.floor_gas;

// Fuel denomination rate rwasm -> evm
// Testnet uses legacy rate (1000), correct rate is 20
// see more details here:
// https://github.com/fluentlabs-xyz/fluentbase/blob/devel/crates/types/src/lib.rs#L63

if tx.input().starts_with(&WASM_MAGIC_BYTES) {
floor_gas /= FUEL_DENOM_RATE;
cfg_if::cfg_if! {
if #[cfg(feature = "fluent-testnet")] {
floor_gas /= 1000;
} else {
floor_gas /= 20;
}
}
}

// EIP-7623: Increase calldata cost
Expand Down
17 changes: 0 additions & 17 deletions crates/interpreter/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,6 @@ impl Gas {

MemoryExtensionResult::Extended
}

/// Records the denominated fuel cost by converting the provided raw fuel cost
/// with a predefined fuel denomination rate (FUEL_DENOM_RATE) and logs it.
/// This operation does not round up due to syncing requirements between gas
/// and fuel rates.
#[inline]
pub fn record_denominated_cost(&mut self, fuel_cost: u64) -> bool {
// TODO(dmitry123): "we can't do round ceil here because we need to sync gas/fuel rates"
// self.record_cost((fuel_cost + FUEL_DENOM_RATE - 1) / FUEL_DENOM_RATE)
self.record_cost(fuel_cost / FUEL_DENOM_RATE)
}

/// Records a denominated fuel refund value.
#[inline]
pub fn record_denominated_refund(&mut self, fuel_refund: i64) {
self.record_refund(fuel_refund / FUEL_DENOM_RATE as i64)
}
}

/// Result of attempting to extend memory during execution.
Expand Down
5 changes: 0 additions & 5 deletions crates/interpreter/src/gas/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,3 @@ pub const INITCODE_WORD_COST: u64 = 2;
pub const CALL_STIPEND: u64 = 2300;
/// Minimum gas that must be provided to a callee.
pub const MIN_CALLEE_GAS: u64 = CALL_STIPEND;

/// A fuel denomination rate for rWasm vs. EVM opcodes
///
/// Make sure this value is synchronized with a Fluentbase version
pub const FUEL_DENOM_RATE: u64 = 1000;
Loading