Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions libevmasm/GasMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
valueSize = 0;
else if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize)))
gas += GasCosts::callValueTransferGas;
gas += memoryGas(-2 - valueSize, -3 - valueSize);
gas += memoryGas(-4 - valueSize, -5 - valueSize);
int tokenIdSize = 0;
if (_item.instruction() == Instruction::CALLTOKEN)
tokenIdSize = 1;
gas += memoryGas(-2 - valueSize - tokenIdSize, -3 - valueSize - tokenIdSize);
gas += memoryGas(-4 - valueSize - tokenIdSize, -5 - valueSize - tokenIdSize);
}
break;
}
Expand Down Expand Up @@ -208,38 +211,29 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
case Instruction::ISCONTRACT:
gas = GasCosts::balanceGas(m_evmVersion);
break;
case Instruction::NATIVEFREEZE:
gas = runGas(Instruction::NATIVEFREEZE, m_evmVersion);
break;
case Instruction::NATIVEUNFREEZE:
gas = runGas(Instruction::NATIVEUNFREEZE, m_evmVersion);
break;
case Instruction::NATIVEFREEZEEXPIRETIME:
gas = runGas(Instruction::NATIVEFREEZEEXPIRETIME, m_evmVersion);
break;
case Instruction::NATIVEFREEZE:
gas = GasCosts::freezeV1Gas;
gas += GasCosts::callNewAccountGas;
break;
case Instruction::NATIVEUNFREEZE:
gas = GasCosts::freezeV1Gas;
break;
case Instruction::NATIVEFREEZEEXPIRETIME:
gas = GasCosts::expireTimeGas;
break;
case Instruction::NATIVEVOTE:
gas = runGas(Instruction::NATIVEVOTE, m_evmVersion);
gas = GasCosts::voteGas;
break;
case Instruction::NATIVEWITHDRAWREWARD:
gas = runGas(Instruction::NATIVEWITHDRAWREWARD, m_evmVersion);
gas = GasCosts::withdrawGas;
break;
case Instruction::NATIVEFREEZEBALANCEV2:
gas = runGas(Instruction::NATIVEFREEZEBALANCEV2, m_evmVersion);
break;
case Instruction::NATIVEUNFREEZEBALANCEV2:
gas = runGas(Instruction::NATIVEUNFREEZEBALANCEV2, m_evmVersion);
break;
case Instruction::NATIVECANCELALLUNFREEZEV2:
gas = runGas(Instruction::NATIVECANCELALLUNFREEZEV2, m_evmVersion);
break;
case Instruction::NATIVECANCELALLUNFREEZEV2:
case Instruction::NATIVEWITHDRAWEXPIREUNFREEZE:
gas = runGas(Instruction::NATIVEWITHDRAWEXPIREUNFREEZE, m_evmVersion);
break;
case Instruction::NATIVEDELEGATERESOURCE:
gas = runGas(Instruction::NATIVEDELEGATERESOURCE, m_evmVersion);
break;
case Instruction::NATIVEUNDELEGATERESOURCE:
gas = runGas(Instruction::NATIVEUNDELEGATERESOURCE, m_evmVersion);
gas = GasCosts::freezeV2Gas;
break;
case Instruction::CHAINID:
gas = runGas(Instruction::CHAINID, m_evmVersion);
Expand Down
6 changes: 6 additions & 0 deletions libevmasm/GasMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ namespace GasCosts
return _evmVersion >= langutil::EVMVersion::istanbul() ? 16 : 68;
}
static unsigned const copyGas = 3;

static unsigned const freezeV1Gas = 20000;
static unsigned const expireTimeGas = 50;
static unsigned const freezeV2Gas = 10000;
static unsigned const withdrawGas = 20000;
static unsigned const voteGas = 30000;
}

/**
Expand Down