diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index d29b9fef9..b9974a3e7 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -16,22 +16,8 @@ */ /** @file FeeStructure.cpp * @author Gav Wood + * @author Pawel Bylica * @date 2014 */ #include "FeeStructure.h" - -using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_stepGas = 1; -u256 const dev::eth::c_balanceGas = 20; -u256 const dev::eth::c_sha3Gas = 20; -u256 const dev::eth::c_sloadGas = 20; -u256 const dev::eth::c_sstoreGas = 100; -u256 const dev::eth::c_createGas = 100; -u256 const dev::eth::c_callGas = 20; -u256 const dev::eth::c_memoryGas = 1; -u256 const dev::eth::c_txDataGas = 5; -u256 const dev::eth::c_txGas = 500; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 76be9a398..8c1519e86 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -16,28 +16,34 @@ */ /** @file FeeStructure.h * @author Gav Wood + * @author Pawel Bylica * @date 2014 */ #pragma once -#include - namespace dev { namespace eth { -extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. -extern u256 const c_balanceGas; ///< Once per BALANCE operation. -extern u256 const c_sha3Gas; ///< Once per SHA3 operation. -extern u256 const c_sloadGas; ///< Once per SLOAD operation. -extern u256 const c_sstoreGas; ///< Once per non-zero storage element in a CREATE call/transaction. Also, once/twice per SSTORE operation depending on whether the zeroness changes (twice iff it changes from zero; nothing at all if to zero) or doesn't (once). -extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. -extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. -extern u256 const c_txDataGas; ///< Per byte of data attached to a transaction. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +enum class Instruction: uint8_t; + +struct FeeStructure +{ + static uint32_t getInstructionFee(Instruction _inst); +}; + +static uint32_t const c_stepGas = 1; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. +static uint32_t const c_balanceGas = 20; ///< Once per BALANCE operation. +static uint32_t const c_sha3Gas = 20; ///< Once per SHA3 operation. +static uint32_t const c_sloadGas = 20; ///< Once per SLOAD operation. +static uint32_t const c_sstoreGas = 100; ///< Once per non-zero storage element in a CREATE call/transaction. Also, once/twice per SSTORE operation depending on whether the zeroness changes (twice iff it changes from zero; nothing at all if to zero) or doesn't (once). +static uint32_t const c_createGas = 100; ///< Once per CREATE operation & contract-creation transaction. +static uint32_t const c_callGas = 20; ///< Once per CALL operation & message call transaction. +static uint32_t const c_memoryGas = 1; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. +static uint32_t const c_txDataGas = 5; ///< Per byte of data attached to a transaction. NOTE: Not payable on data of calls between transactions. +static uint32_t const c_txGas = 500; ///< Per transaction. NOTE: Not payable on data of calls between transactions. } }