Skip to content

Commit 4f8ed64

Browse files
committed
Merge branch 'grarco/network-gas' (#2205)
* origin/grarco/network-gas: Changelog #2205 Charges wrapper gas for network usage
2 parents 1a321b2 + 13ce967 commit 4f8ed64

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Charge gas for network usage.
2+
([\#2205](https://github.com/anoma/namada/pull/2205))

core/src/ledger/gas.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const STORAGE_OCCUPATION_GAS_PER_BYTE: u64 =
3535
// codebase. For these two reasons we just set an arbitrary value (based on
3636
// actual SSDs latency) per byte here
3737
const PHYSICAL_STORAGE_LATENCY_PER_BYTE: u64 = 75;
38+
// This is based on the global avarage bandwidth
39+
const NETWORK_TRANSMISSION_GAS_PER_BYTE: u64 = 13;
3840

3941
/// The cost of accessing data from memory (both read and write mode), per byte
4042
pub const MEMORY_ACCESS_GAS_PER_BYTE: u64 = 2;
@@ -273,13 +275,18 @@ impl TxGasMeter {
273275
/// Add the gas required by a wrapper transaction which is comprised of:
274276
/// - cost of validating the wrapper tx
275277
/// - space that the transaction requires in the block
278+
/// - cost of downloading (as part of the block) the transaction bytes over
279+
/// the network
276280
pub fn add_wrapper_gas(&mut self, tx_bytes: &[u8]) -> Result<()> {
277281
self.consume(WRAPPER_TX_VALIDATION_GAS)?;
278282

279283
let bytes_len = tx_bytes.len() as u64;
280284
self.consume(
281285
bytes_len
282-
.checked_mul(STORAGE_OCCUPATION_GAS_PER_BYTE)
286+
.checked_mul(
287+
STORAGE_OCCUPATION_GAS_PER_BYTE
288+
+ NETWORK_TRANSMISSION_GAS_PER_BYTE,
289+
)
283290
.ok_or(Error::GasOverflow)?,
284291
)
285292
}

0 commit comments

Comments
 (0)