mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Remove addtional cost param from commitCostBlock(). Count additional cost manually. [#81461534]
This commit is contained in:
parent
90cb4a753e
commit
e3245e140b
3 changed files with 4 additions and 9 deletions
|
|
@ -773,7 +773,7 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, bytes const& _bytecode
|
|||
auto outOff = stack.pop();
|
||||
auto outSize = stack.pop();
|
||||
|
||||
_gasMeter.commitCostBlock(gas);
|
||||
_gasMeter.commitCostBlock();
|
||||
|
||||
// Require memory for in and out buffers
|
||||
_memory.require(outOff, outSize); // Out buffer first as we guess it will be after the in one
|
||||
|
|
@ -783,6 +783,7 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, bytes const& _bytecode
|
|||
if (inst == Instruction::CALLCODE)
|
||||
receiveAddress = _runtimeManager.get(RuntimeData::Address);
|
||||
|
||||
_gasMeter.count(gas);
|
||||
auto ret = _ext.call(gas, receiveAddress, value, inOff, inSize, outOff, outSize, codeAddress);
|
||||
_gasMeter.giveBack(gas);
|
||||
stack.push(ret);
|
||||
|
|
|
|||
|
|
@ -181,10 +181,8 @@ void GasMeter::giveBack(llvm::Value* _gas)
|
|||
m_runtimeManager.setGas(m_builder.CreateAdd(m_runtimeManager.getGas(), _gas));
|
||||
}
|
||||
|
||||
void GasMeter::commitCostBlock(llvm::Value* _additionalCost)
|
||||
void GasMeter::commitCostBlock()
|
||||
{
|
||||
assert(!_additionalCost || m_checkCall); // _additionalCost => m_checkCall; Must be inside cost-block
|
||||
|
||||
// If any uncommited block
|
||||
if (m_checkCall)
|
||||
{
|
||||
|
|
@ -198,9 +196,6 @@ void GasMeter::commitCostBlock(llvm::Value* _additionalCost)
|
|||
m_checkCall->setArgOperand(0, Constant::get(m_blockCost)); // Update block cost in gas check call
|
||||
m_checkCall = nullptr; // End cost-block
|
||||
m_blockCost = 0;
|
||||
|
||||
if (_additionalCost)
|
||||
count(_additionalCost);
|
||||
}
|
||||
assert(m_blockCost == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ public:
|
|||
void countSha3Data(llvm::Value* _dataLength);
|
||||
|
||||
/// Finalize cost-block by checking gas needed for the block before the block
|
||||
/// @param _additionalCost adds additional cost to cost-block before commit
|
||||
void commitCostBlock(llvm::Value* _additionalCost = nullptr);
|
||||
void commitCostBlock();
|
||||
|
||||
/// Give back an amount of gas not used by a call
|
||||
void giveBack(llvm::Value* _gas);
|
||||
|
|
|
|||
Loading…
Reference in a new issue