diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ff8baa72b22..4bd63593c6c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,9 @@ 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 diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 866b5d66f2fa..e9235c45c4e5 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -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; } @@ -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); diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index c91e0f0971c9..68149dc52534 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -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; } /**