Browse Source

Merge branch 'develop' into develop-evmcc

cl-refactor
Paweł Bylica 10 years ago
parent
commit
1dbad21b59
  1. 2
      libethereum/Executive.cpp
  2. 2
      libethereum/Interface.h
  3. 16
      libevm/FeeStructure.cpp
  4. 23
      libevm/FeeStructure.h
  5. 4
      libevm/VM.h

2
libethereum/Executive.cpp

@ -66,7 +66,7 @@ bool Executive::setup(bytesConstRef _rlp)
} }
// Check gas cost is enough. // Check gas cost is enough.
u256 gasCost = u256(m_t.data.size()) * c_txDataGas + c_txGas; u256 gasCost = m_t.data.size() * c_txDataGas + c_txGas;
if (m_t.gas < gasCost) if (m_t.gas < gasCost)
{ {

2
libethereum/Interface.h

@ -123,7 +123,7 @@ public:
virtual Addresses addresses(int _block) const = 0; virtual Addresses addresses(int _block) const = 0;
/// Get the fee associated for a transaction with the given data. /// Get the fee associated for a transaction with the given data.
static u256 txGas(unsigned _dataCount, u256 _gas = 0) { return u256(c_txDataGas) * _dataCount + c_txGas + _gas; } static u256 txGas(unsigned _dataCount, u256 _gas = 0) { return c_txDataGas * _dataCount + c_txGas + _gas; }
/// Get the remaining gas limit in this block. /// Get the remaining gas limit in this block.
virtual u256 gasLimitRemaining() const = 0; virtual u256 gasLimitRemaining() const = 0;

16
libevm/FeeStructure.cpp

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

23
libevm/FeeStructure.h

@ -16,29 +16,28 @@
*/ */
/** @file FeeStructure.h /** @file FeeStructure.h
* @author Gav Wood <i@gavwood.com> * @author Gav Wood <i@gavwood.com>
* @author Pawel Bylica <chfast@gmail.com>
* @date 2014 * @date 2014
*/ */
#pragma once #pragma once
#include <cstdint> #include <libdevcore/Common.h>
namespace dev namespace dev
{ {
namespace eth namespace eth
{ {
static uint32_t const c_stepGas = 1; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL.
static uint32_t const c_balanceGas = 20; ///< Once per BALANCE operation. extern u256 const c_balanceGas; ///< Once per BALANCE operation.
static uint32_t const c_sha3Gas = 20; ///< Once per SHA3 operation. extern u256 const c_sha3Gas; ///< Once per SHA3 operation.
static uint32_t const c_sloadGas = 20; ///< Once per SLOAD operation. extern u256 const c_sloadGas; ///< 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). 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).
static uint32_t const c_createGas = 100; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction.
static uint32_t const c_callGas = 20; ///< Once per CALL operation & message call transaction. extern u256 const c_callGas; ///< 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. 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.
static uint32_t const c_txDataGas = 5; ///< Per byte of data attached to a transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataGas; ///< 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. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions.
} }
} }

4
libevm/VM.h

@ -146,13 +146,13 @@ template <class Ext> dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con
case Instruction::CALL: case Instruction::CALL:
require(7); require(7);
runGas = bigint(c_callGas) + m_stack[m_stack.size() - 1]; runGas = c_callGas + m_stack[m_stack.size() - 1];
newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5]));
break; break;
case Instruction::CALLCODE: case Instruction::CALLCODE:
require(7); require(7);
runGas = bigint(c_callGas) + m_stack[m_stack.size() - 1]; runGas = c_callGas + m_stack[m_stack.size() - 1];
newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5]));
break; break;

Loading…
Cancel
Save