diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-09-26 22:16:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 22:16:38 +0800 |
commit | 410d94c49802ffd1a8cc834e30630308aed7283b (patch) | |
tree | 1d75cae3e1d7a7f2ac1e62faded1261cc310e2a0 /libevmasm | |
parent | 2c860b7d7403fdec27442b617e9d01e610d06502 (diff) | |
parent | d7c3f197c4c5bb5eb735089486134fdc20a5850f (diff) | |
download | dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar.gz dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar.bz2 dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar.lz dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar.xz dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.tar.zst dexon-solidity-410d94c49802ffd1a8cc834e30630308aed7283b.zip |
Merge pull request #5089 from ethereum/gasmeter
Small pathgasmeter cleanups
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/GasMeter.cpp | 4 | ||||
-rw-r--r-- | libevmasm/GasMeter.h | 2 | ||||
-rw-r--r-- | libevmasm/PathGasMeter.h | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index b525c301..b40617c1 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -101,8 +101,8 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ break; case Instruction::KECCAK256: gas = GasCosts::keccak256Gas; - gas += wordGas(GasCosts::keccak256WordGas, m_state->relativeStackElement(-1)); gas += memoryGas(0, -1); + gas += wordGas(GasCosts::keccak256WordGas, m_state->relativeStackElement(-1)); break; case Instruction::CALLDATACOPY: case Instruction::CODECOPY: @@ -214,7 +214,7 @@ GasMeter::GasConsumption GasMeter::memoryGas(ExpressionClasses::Id _position) if (!value) return GasConsumption::infinite(); if (*value < m_largestMemoryAccess) - return GasConsumption(u256(0)); + return GasConsumption(0); u256 previous = m_largestMemoryAccess; m_largestMemoryAccess = *value; auto memGas = [=](u256 const& pos) -> u256 diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index 7cb8015f..da90b028 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -137,6 +137,8 @@ public: static unsigned runGas(Instruction _instruction); /// @returns the gas cost of the supplied data, depending whether it is in creation code, or not. + /// In case of @a _inCreation, the data is only sent as a transaction and is not stored, whereas + /// otherwise code will be stored and have to pay "createDataGas" cost. static u256 dataGas(bytes const& _data, bool _inCreation); private: diff --git a/libevmasm/PathGasMeter.h b/libevmasm/PathGasMeter.h index 9537b176..fb821684 100644 --- a/libevmasm/PathGasMeter.h +++ b/libevmasm/PathGasMeter.h @@ -57,6 +57,16 @@ public: GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr<KnownState> const& _state); + static GasMeter::GasConsumption estimateMax( + AssemblyItems const& _items, + solidity::EVMVersion _evmVersion, + size_t _startIndex, + std::shared_ptr<KnownState> const& _state + ) + { + return PathGasMeter(_items, _evmVersion).estimateMax(_startIndex, _state); + } + private: /// Adds a new path item to the queue, but only if we do not already have /// a higher gas usage at that point. |