Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompile events - Fee Config #967

Merged
merged 56 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f19a275
add equality tests
ceyonur Sep 6, 2023
143aeb7
regenerate abis
ceyonur Sep 6, 2023
f51a4d0
Merge branch 'master' into abi-standardize
ceyonur Sep 6, 2023
a6a90a0
add extra padding tests
ceyonur Sep 11, 2023
a1774c3
Merge branch 'abi-standardize' of github.com:ava-labs/subnet-evm into…
ceyonur Sep 11, 2023
c964e42
Merge branch 'master' into abi-standardize
ceyonur Sep 14, 2023
1166ad3
override network upgrades (#839)
ceyonur Sep 12, 2023
c31b56b
update native minter
ceyonur Sep 13, 2023
80e6d6e
nativeminter nit test changes
ceyonur Sep 14, 2023
116b981
replace fee manager packers
ceyonur Sep 14, 2023
0585f89
remove generated abis
ceyonur Sep 14, 2023
97357bf
Update precompile/contracts/feemanager/contract.go
ceyonur Sep 14, 2023
f0c504c
fix comments
ceyonur Sep 14, 2023
eb2c13b
Merge branch 'replace-old-packers' of github.com:ava-labs/subnet-evm …
ceyonur Sep 14, 2023
6c11f5e
add event packing/unpacking to contract template
ceyonur Oct 10, 2023
bcb368e
add pack event tests to template
ceyonur Oct 11, 2023
1b9dbb8
add event precompile bind tests
ceyonur Oct 12, 2023
313736a
Merge branch 'master' into precompile-events-template
ceyonur Oct 12, 2023
a6589ff
Merge branch 'master' into precompile-events-template
ceyonur Oct 16, 2023
1c84946
nits
ceyonur Oct 16, 2023
d917590
Merge branch 'precompile-events-template' of github.com:ava-labs/subn…
ceyonur Oct 16, 2023
c17f5e1
separate event file
ceyonur Oct 16, 2023
f9e6910
Update accounts/abi/bind/precompilebind/precompile_bind.go
ceyonur Oct 17, 2023
db9baf0
revert set changes
ceyonur Oct 17, 2023
5da09f1
change event comments
ceyonur Oct 17, 2023
934a9ef
Merge branch 'master' into precompile-events-template
ceyonur Oct 17, 2023
dd20767
Merge branch 'master' into precompile-events-template
ceyonur Oct 20, 2023
206e75d
Merge branch 'replace-old-packers' into precompile-events-fee-config
abi87 Oct 20, 2023
8518a27
added event for setFeeConfig
abi87 Oct 23, 2023
0bd5b21
added UT
abi87 Oct 23, 2023
db4da0a
cleanups
abi87 Oct 24, 2023
9f5720b
Merge branch 'master' into precompile-events-template
ceyonur Nov 8, 2023
cf6618a
Merge branch 'master' into precompile-events-template
ceyonur Dec 8, 2023
2013998
add get event gas cost and tests
ceyonur Dec 8, 2023
e877e66
nits
ceyonur Dec 11, 2023
fa12de1
Merge branch 'precompile-events-template' into precompile-events-fee-…
ceyonur Dec 11, 2023
dc6f498
revert unrelated changes
ceyonur Dec 12, 2023
fb09170
add event
ceyonur Dec 12, 2023
4e9ad6a
add hardhat test
ceyonur Dec 12, 2023
36d6408
add topics to GetLogData
ceyonur Dec 13, 2023
365912f
Merge branch 'precompile-events-template' into precompile-events-fee-…
ceyonur Dec 13, 2023
cfb9ccc
use interface function for testing logs
ceyonur Dec 13, 2023
0314fb7
add sender to indexed topics
ceyonur Dec 13, 2023
fde3e0c
Update contract.go
ceyonur Dec 15, 2023
8125975
move gas to above
ceyonur Dec 15, 2023
723f83a
Update contracts/test/fee_manager.ts
ceyonur Dec 15, 2023
79f4af0
use existing test
ceyonur Dec 15, 2023
9b710f4
Merge branch 'precompile-events-fee-config' of github.com:ava-labs/su…
ceyonur Dec 15, 2023
b0396d9
fix typo
ceyonur Dec 15, 2023
0f86b7e
add signature topic gas costs
ceyonur Dec 15, 2023
fffc0fb
Merge branch 'master' into precompile-events-fee-config
ceyonur Dec 18, 2023
b8ed429
fix tests
ceyonur Dec 18, 2023
c8a7908
Apply suggestions from code review
ceyonur Dec 19, 2023
fcca577
add assert fee event func
ceyonur Dec 19, 2023
b8d14f9
Merge branch 'precompile-events-fee-config' of github.com:ava-labs/su…
ceyonur Dec 19, 2023
33a91cd
Merge branch 'master' into precompile-events-fee-config
ceyonur Dec 21, 2023
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
12 changes: 12 additions & 0 deletions contracts/contracts/interfaces/IFeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ pragma solidity ^0.8.0;
import "./IAllowList.sol";

interface IFeeManager is IAllowList {
struct FeeConfig {
uint256 gasLimit;
uint256 targetBlockRate;
uint256 minBaseFee;
uint256 targetGas;
uint256 baseFeeChangeDenominator;
uint256 minBlockGasCost;
uint256 maxBlockGasCost;
uint256 blockGasCostStep;
}
event FeeConfigChanged(address indexed sender, FeeConfig oldFeeConfig, FeeConfig newFeeConfig);

// Set fee config fields to contract storage
function setFeeConfig(
uint256 gasLimit,
Expand Down
67 changes: 67 additions & 0 deletions contracts/test/fee_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import { expect } from "chai"
import { ethers } from "hardhat"
import { test } from "./utils"
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import {
Contract,
} from "ethers"
ceyonur marked this conversation as resolved.
Show resolved Hide resolved

const ADMIN_ADDRESS: string = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
const FEE_MANAGER = "0x0200000000000000000000000000000000000003"
Expand Down Expand Up @@ -53,3 +57,66 @@ describe("ExampleFeeManager", function () {
"step_lowerMinFeeByOne",
])
})
const C_FEES = {
ceyonur marked this conversation as resolved.
Show resolved Hide resolved
gasLimit: 8_000_000, // gasLimit
targetBlockRate: 2, // targetBlockRate
minBaseFee: 25_000_000_000, // minBaseFee
targetGas: 15_000_000, // targetGas
baseFeeChangeDenominator: 36, // baseFeeChangeDenominator
minBlockGasCost: 0, // minBlockGasCost
maxBlockGasCost: 1_000_000, // maxBlockGasCost
blockGasCostStep: 100_000 // blockGasCostStep
}

const WAGMI_FEES = {
gasLimit: 20_000_000, // gasLimit
targetBlockRate: 2, // targetBlockRate
minBaseFee: 1_000_000_000, // minBaseFee
targetGas: 100_000_000, // targetGas
baseFeeChangeDenominator: 48, // baseFeeChangeDenominator
minBlockGasCost: 0, // minBlockGasCost
maxBlockGasCost: 10_000_000, // maxBlockGasCost
blockGasCostStep: 100_000 // blockGasCostStep
}

describe("IFeeManager", function () {
let owner: SignerWithAddress
let contract: Contract
before(async function () {
owner = await ethers.getSigner(ADMIN_ADDRESS);
contract = await ethers.getContractAt("IFeeManager", FEE_MANAGER, owner)
// reset to C fees
let tx = await contract.setFeeConfig(
C_FEES.gasLimit,
C_FEES.targetBlockRate,
C_FEES.minBaseFee,
C_FEES.targetGas,
C_FEES.baseFeeChangeDenominator,
C_FEES.minBlockGasCost,
C_FEES.maxBlockGasCost,
C_FEES.blockGasCostStep)
await tx.wait()
});

it("should emit fee config changed event", async function () {
await expect(contract.setFeeConfig(
WAGMI_FEES.gasLimit,
WAGMI_FEES.targetBlockRate,
WAGMI_FEES.minBaseFee,
WAGMI_FEES.targetGas,
WAGMI_FEES.baseFeeChangeDenominator,
WAGMI_FEES.minBlockGasCost,
WAGMI_FEES.maxBlockGasCost,
WAGMI_FEES.blockGasCostStep)
)
.to.emit(contract, 'FeeConfigChanged')
.withArgs(
owner.address,
// old config
[C_FEES.gasLimit, C_FEES.targetBlockRate, C_FEES.minBaseFee, C_FEES.targetGas, C_FEES.baseFeeChangeDenominator, C_FEES.minBlockGasCost, C_FEES.maxBlockGasCost, C_FEES.blockGasCostStep],
// new config
[WAGMI_FEES.gasLimit, WAGMI_FEES.targetBlockRate, WAGMI_FEES.minBaseFee, WAGMI_FEES.targetGas, WAGMI_FEES.baseFeeChangeDenominator, WAGMI_FEES.minBlockGasCost, WAGMI_FEES.maxBlockGasCost, WAGMI_FEES.blockGasCostStep]
);
})
})

Loading
Loading