Browse Source

Use compile-time constants instead of runtime-constructed multiprecision objects in FeeStructure.

cl-refactor
Paweł Bylica 10 years ago
parent
commit
3030e8f74f
  1. 16
      libevm/FeeStructure.cpp
  2. 30
      libevm/FeeStructure.h

16
libevm/FeeStructure.cpp

@ -16,22 +16,8 @@
*/
/** @file FeeStructure.cpp
* @author Gav Wood <i@gavwood.com>
* @author Pawel Bylica <chfast@gmail.com>
* @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;

30
libevm/FeeStructure.h

@ -16,28 +16,34 @@
*/
/** @file FeeStructure.h
* @author Gav Wood <i@gavwood.com>
* @author Pawel Bylica <chfast@gmail.com>
* @date 2014
*/
#pragma once
#include <libdevcore/Common.h>
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.
}
}

Loading…
Cancel
Save