Skip to content

Commit

Permalink
[EVM] Tune configs (sei-protocol#1800)
Browse files Browse the repository at this point in the history
* increase min gas price from 1gwei to 333gwei

* fixes

* fixes

* fix

* fetch depth 0

* try to install docker compose

* fixes
  • Loading branch information
jewei1997 authored Aug 2, 2024
1 parent d502396 commit 033a8b5
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ jobs:
with:
go-version: 1.21

- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Start 4 node docker cluster
run: make clean && INVARIANT_CHECK_INTERVAL=10 ${{matrix.test.env}} make docker-cluster-start &

Expand Down
4 changes: 2 additions & 2 deletions app/receipt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestEvmEventsForCw20(t *testing.T) {
wasmAddr := common.HexToAddress(wasmd.WasmdAddress)
txData := ethtypes.LegacyTx{
Nonce: 0,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 1000000,
To: &wasmAddr,
Data: data,
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestEvmEventsForCw721(t *testing.T) {
wasmAddr := common.HexToAddress(wasmd.WasmdAddress)
txData := ethtypes.LegacyTx{
Nonce: 0,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 1000000,
To: &wasmAddr,
Data: data,
Expand Down
10 changes: 7 additions & 3 deletions contracts/test/ERC20toNativePointerTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {setupSigners, deployErc20PointerNative, getAdmin, createTokenFactoryTokenAndMint, ABI, generateWallet,
fundAddress, getSeiAddress
fundAddress, getSeiAddress,
delay
} = require("./lib");
const {expect} = require("chai");

Expand Down Expand Up @@ -89,10 +90,13 @@ describe("ERC20 to Native Pointer", function () {
expect(await pointer.balanceOf(recipient)).to.equal(amount);

// fund address so it can transact
await fundAddress(recipient)
await fundAddress(recipient, "1000000000000000000000")
await delay()

// unlinked wallet can send balance back to sender (becomes linked at this moment)
await (await pointer.connect(recipientWallet).transfer(sender.evmAddress, amount)).wait()
await (await pointer.connect(recipientWallet).transfer(sender.evmAddress, amount, {
gasPrice: ethers.parseUnits('333', 'gwei')
})).wait()
expect(await pointer.balanceOf(recipient)).to.equal(BigInt(0));
expect(await pointer.balanceOf(sender.evmAddress)).to.equal(startBal);

Expand Down
25 changes: 13 additions & 12 deletions contracts/test/EVMCompatabilityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,24 +497,24 @@ describe("EVM Test", function () {

describe("EIP-1559", async function() {
const zero = ethers.parseUnits('0', 'ether')
const twoGwei = ethers.parseUnits("2", "gwei");
const oneGwei = ethers.parseUnits("1", "gwei");
const highgp = ethers.parseUnits("400", "gwei");
const gp = ethers.parseUnits("333", "gwei");

const testCases = [
["No truncation from max priority fee", oneGwei, oneGwei],
["With truncation from max priority fee", oneGwei, twoGwei],
["With complete truncation from max priority fee", zero, twoGwei]
["No truncation from max priority fee", gp, gp],
["With truncation from max priority fee", gp, highgp],
["With complete truncation from max priority fee", zero, highgp]
];

it("Should be able to send many EIP-1559 txs", async function () {
const oneGwei = ethers.parseUnits("1", "gwei");
const gp = ethers.parseUnits("333", "gwei");
const zero = ethers.parseUnits('0', 'ether')
for (let i = 0; i < 10; i++) {
const txResponse = await owner.sendTransaction({
to: owner.address,
value: zero,
maxPriorityFeePerGas: oneGwei,
maxFeePerGas: oneGwei,
maxPriorityFeePerGas: gp,
maxFeePerGas: gp,
type: 2
});
await txResponse.wait();
Expand Down Expand Up @@ -617,8 +617,8 @@ describe("EVM Test", function () {
it("Should retrieve a transaction receipt", async function () {
const txResponse = await evmTester.setBoolVar(false, {
type: 2, // force it to be EIP-1559
maxPriorityFeePerGas: ethers.parseUnits('100', 'gwei'), // set gas high just to get it included
maxFeePerGas: ethers.parseUnits('100', 'gwei')
maxPriorityFeePerGas: ethers.parseUnits('400', 'gwei'), // set gas high just to get it included
maxFeePerGas: ethers.parseUnits('400', 'gwei')
});
await txResponse.wait();
const receipt = await ethers.provider.getTransactionReceipt(txResponse.hash);
Expand Down Expand Up @@ -1093,6 +1093,7 @@ describe("EVM Validations ", function() {
await setupSigners(await hre.ethers.getSigners())
signer = generateWallet()
await fundAddress(await signer.getAddress())
await sleep(3000)
})

it("should prevent wrong chainId for eip-155 txs", async function() {
Expand All @@ -1104,9 +1105,9 @@ describe("EVM Validations ", function() {
chainId: "0x12345",
type: 2,
nonce: nonce,
maxPriorityFeePerGas: 21000,
maxPriorityFeePerGas: 400000000000,
gasLimit: 21000,
maxFeePerGas:10000000000})
maxFeePerGas: 400000000000})

const nodeUrl = 'http://localhost:8545';
const response = await axios.post(nodeUrl, {
Expand Down
8 changes: 4 additions & 4 deletions precompiles/distribution/distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestWithdraw(t *testing.T) {
res, err = msgServer.EVMTransaction(sdk.WrapSDKContext(ctx), req)
require.Nil(t, err)
require.Empty(t, res.VmError)
require.Equal(t, uint64(68682), res.GasUsed)
require.Equal(t, uint64(68688), res.GasUsed)

// reinitialized
d, found = testApp.StakingKeeper.GetDelegation(ctx, seiAddr, val)
Expand Down Expand Up @@ -301,7 +301,7 @@ func setWithdrawAddressAndWithdraw(
res, err = msgServer.EVMTransaction(sdk.WrapSDKContext(ctx), r)
require.Nil(t, err)
require.Empty(t, res.VmError)
require.Equal(t, uint64(152848), res.GasUsed)
require.Equal(t, uint64(152854), res.GasUsed)

// reinitialized
for _, val := range vals {
Expand Down Expand Up @@ -1051,7 +1051,7 @@ func TestPrecompile_RunAndCalculateGas_Rewards(t *testing.T) {
suppliedGas: uint64(1000000),
},
wantRet: emptyCasePackedOutput,
wantRemainingGas: 994319,
wantRemainingGas: 994313,
wantErr: false,
},
{
Expand All @@ -1067,7 +1067,7 @@ func TestPrecompile_RunAndCalculateGas_Rewards(t *testing.T) {
suppliedGas: uint64(1000000),
},
wantRet: happyPathPackedOutput,
wantRemainingGas: 994319,
wantRemainingGas: 994313,
wantErr: false,
},
}
Expand Down
6 changes: 3 additions & 3 deletions precompiles/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestPrecompile_Run(t *testing.T) {
fields: fields{transferKeeper: &MockTransferKeeper{}},
args: commonArgs,
wantBz: packedTrue,
wantRemainingGas: 994319,
wantRemainingGas: 994313,
wantErr: false,
},
{
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestPrecompile_Run(t *testing.T) {
value: nil,
},
wantBz: packedTrue,
wantRemainingGas: 994319,
wantRemainingGas: 994313,
wantErr: false,
},
{
Expand All @@ -255,7 +255,7 @@ func TestPrecompile_Run(t *testing.T) {
value: nil,
},
wantBz: packedTrue,
wantRemainingGas: 994319,
wantRemainingGas: 994313,
wantErr: false,
},
}
Expand Down
8 changes: 4 additions & 4 deletions x/evm/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestERC2981PointerToCW2981(t *testing.T) {
require.Nil(t, err)
txData := ethtypes.LegacyTx{
Nonce: 0,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 5000000,
To: &to,
Data: data,
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestERC2981PointerToCW2981(t *testing.T) {
require.Nil(t, err)
txData = ethtypes.LegacyTx{
Nonce: 1,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 1000000,
To: &pointerAddr,
Data: data,
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestCW2981PointerToERC2981(t *testing.T) {
require.Nil(t, err)
txData := ethtypes.LegacyTx{
Nonce: 0,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 5000000,
To: nil,
Data: append(bz, data...),
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestCW2981PointerToERC2981(t *testing.T) {
to := common.HexToAddress(receipt.ContractAddress)
txData = ethtypes.LegacyTx{
Nonce: 1,
GasPrice: big.NewInt(1000000000),
GasPrice: big.NewInt(333000000000),
Gas: 1000000,
To: &to,
Data: data,
Expand Down
2 changes: 1 addition & 1 deletion x/evm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestModuleExportGenesis(t *testing.T) {
module := evm.NewAppModule(nil, k)
jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc)
jsonStr := string(jsonMsg)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"1000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"333000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr)
}

func TestConsensusVersion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var DefaultPriorityNormalizer = sdk.NewDec(1)
// burnt rather than go to validators (similar to base fee on
// Ethereum).
var DefaultBaseFeePerGas = sdk.NewDec(0)
var DefaultMinFeePerGas = sdk.NewDec(1000000000)
var DefaultMinFeePerGas = sdk.NewDec(333000000000)

var DefaultWhitelistedCwCodeHashesForDelegateCall = generateDefaultWhitelistedCwCodeHashesForDelegateCall()

Expand Down

0 comments on commit 033a8b5

Please sign in to comment.