mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
Improve GasMeter code formatting
This commit is contained in:
parent
3212b2b139
commit
bc1ef19fe0
1 changed files with 4 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ uint64_t getStepCost(Instruction inst) // TODO: Add this function to FeeSructure
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case Instruction::SSTORE:
|
case Instruction::SSTORE:
|
||||||
return static_cast<uint64_t>(c_sstoreResetGas); // FIXME: Check store gas
|
return static_cast<uint64_t>(c_sstoreResetGas); // FIXME: Check store gas
|
||||||
|
|
||||||
case Instruction::SLOAD:
|
case Instruction::SLOAD:
|
||||||
return static_cast<uint64_t>(c_sloadGas);
|
return static_cast<uint64_t>(c_sloadGas);
|
||||||
|
|
@ -87,7 +87,7 @@ GasMeter::GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager)
|
||||||
auto module = getModule();
|
auto module = getModule();
|
||||||
|
|
||||||
m_gasCheckFunc = llvm::Function::Create(llvm::FunctionType::get(Type::Void, Type::i256, false), llvm::Function::PrivateLinkage, "gas.check", module);
|
m_gasCheckFunc = llvm::Function::Create(llvm::FunctionType::get(Type::Void, Type::i256, false), llvm::Function::PrivateLinkage, "gas.check", module);
|
||||||
InsertPointGuard guard(m_builder);
|
InsertPointGuard guard(m_builder);
|
||||||
|
|
||||||
auto checkBB = llvm::BasicBlock::Create(_builder.getContext(), "Check", m_gasCheckFunc);
|
auto checkBB = llvm::BasicBlock::Create(_builder.getContext(), "Check", m_gasCheckFunc);
|
||||||
auto outOfGasBB = llvm::BasicBlock::Create(_builder.getContext(), "OutOfGas", m_gasCheckFunc);
|
auto outOfGasBB = llvm::BasicBlock::Create(_builder.getContext(), "OutOfGas", m_gasCheckFunc);
|
||||||
|
|
@ -117,7 +117,7 @@ void GasMeter::count(Instruction _inst)
|
||||||
// Create gas check call with mocked block cost at begining of current cost-block
|
// Create gas check call with mocked block cost at begining of current cost-block
|
||||||
m_checkCall = m_builder.CreateCall(m_gasCheckFunc, llvm::UndefValue::get(Type::i256));
|
m_checkCall = m_builder.CreateCall(m_gasCheckFunc, llvm::UndefValue::get(Type::i256));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_inst != Instruction::SSTORE) // Handle cost of SSTORE separately in countSStore()
|
if (_inst != Instruction::SSTORE) // Handle cost of SSTORE separately in countSStore()
|
||||||
m_blockCost += getStepCost(_inst);
|
m_blockCost += getStepCost(_inst);
|
||||||
|
|
||||||
|
|
@ -129,7 +129,7 @@ void GasMeter::countSStore(Ext& _ext, llvm::Value* _index, llvm::Value* _newValu
|
||||||
{
|
{
|
||||||
assert(!m_checkCall); // Everything should've been commited before
|
assert(!m_checkCall); // Everything should've been commited before
|
||||||
|
|
||||||
static const auto sstoreCost = static_cast<uint64_t>(c_sstoreResetGas); // FIXME: Check store gas
|
static const auto sstoreCost = static_cast<uint64_t>(c_sstoreResetGas); // FIXME: Check store gas
|
||||||
|
|
||||||
// [ADD] if oldValue == 0 and newValue != 0 => 2*cost
|
// [ADD] if oldValue == 0 and newValue != 0 => 2*cost
|
||||||
// [DEL] if oldValue != 0 and newValue == 0 => 0
|
// [DEL] if oldValue != 0 and newValue == 0 => 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue