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
21 changes: 12 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
- name: Checkout code
uses: actions/checkout@v5

- name: Fix git safe directory
run: git config --global --add safe.directory '*'

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: .\deps
key: dependencies-win-${{ runner.arch }}-${{ hashFiles('scripts/install_deps.ps1') }}
Expand All @@ -37,7 +40,7 @@ jobs:
cp build/solc/Release/solc.exe github/solc-windows.exe

- name: Save artifact to cache
uses: actions/cache/save@v4
uses: actions/cache/save@v5
with:
path: github/solc-windows.exe
key: solc-windows-${{ github.run_id }}
Expand Down Expand Up @@ -67,7 +70,7 @@ jobs:
cp build/solc/solc github/solc-macos

- name: Save artifact to cache
uses: actions/cache/save@v4
uses: actions/cache/save@v5
with:
path: github/solc-macos
key: solc-macos-${{ github.run_id }}
Expand Down Expand Up @@ -100,7 +103,7 @@ jobs:
cp build/solc/solc github/solc-static-linux

- name: Save artifact to cache
uses: actions/cache/save@v4
uses: actions/cache/save@v5
with:
path: github/solc-static-linux
key: solc-linux-${{ github.run_id }}
Expand Down Expand Up @@ -131,7 +134,7 @@ jobs:
cp upload/soljson.js github/soljson.js

- name: Save artifact to cache
uses: actions/cache/save@v4
uses: actions/cache/save@v5
with:
path: github/soljson.js
key: solc-ems-${{ github.run_id }}
Expand All @@ -147,27 +150,27 @@ jobs:

steps:
- name: Restore solc-windows
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: github/solc-windows.exe
key: solc-windows-${{ github.run_id }}
enableCrossOsArchive: true

- name: Restore solc-macos
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: github/solc-macos
key: solc-macos-${{ github.run_id }}
enableCrossOsArchive: true

- name: Restore solc-linux
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: github/solc-static-linux
key: solc-linux-${{ github.run_id }}

- name: Restore solc-ems
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: github/soljson.js
key: solc-ems-${{ github.run_id }}
Expand Down
44 changes: 19 additions & 25 deletions libevmasm/GasMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,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 @@ -212,38 +215,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