File tree Expand file tree Collapse file tree
.changelog/unreleased/improvements Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ - Charge gas for network usage.
2+ ([ \# 2205] ( https://github.com/anoma/namada/pull/2205 ) )
Original file line number Diff line number Diff 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
3737const 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
4042pub 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 }
You can’t perform that action at this time.
0 commit comments