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

Eip-1559 default values #1888

Merged
merged 12 commits into from
Oct 4, 2024
8 changes: 4 additions & 4 deletions contracts/test/EVMCompatabilityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("EVM Test", function () {
testToken = await TestToken.deploy("TestToken", "TTK");

const EVMCompatibilityTester = await ethers.getContractFactory("EVMCompatibilityTester");
evmTester = await EVMCompatibilityTester.deploy();
evmTester = await EVMCompatibilityTester.deploy({ gasPrice: ethers.parseUnits('100', 'gwei') });

await Promise.all([evmTester.waitForDeployment(), testToken.waitForDeployment()])

Expand Down Expand Up @@ -148,7 +148,7 @@ describe("EVM Test", function () {

await delay()
// Set balance
await testToken.setBalance(owner.address, setAmount);
await testToken.setBalance(owner.address, setAmount, { gasPrice: ethers.parseUnits('100', 'gwei') });

// Prepare call data for balanceOf function of MyToken
const balanceOfData = testToken.interface.encodeFunctionData("balanceOf", [owner.address]);
Expand All @@ -169,7 +169,7 @@ describe("EVM Test", function () {
describe("Msg Properties", function() {
it("Should store and retrieve msg properties correctly", async function() {
// Store msg properties
const txResponse = await evmTester.storeMsgProperties({ value: 1 });
const txResponse = await evmTester.storeMsgProperties({ value: 1, gasPrice: ethers.parseUnits('100', 'gwei') });
await txResponse.wait();

// Retrieve stored msg properties
Expand Down Expand Up @@ -1004,7 +1004,7 @@ describe("EVM Test", function () {

// increment value
debug("Incrementing value...")
const resp = await box.boxIncr();
const resp = await box.boxIncr({ gasPrice: ethers.parseUnits('100', 'gwei') });
await resp.wait();

// make sure value is incremented
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func verifyBlockResult(t *testing.T, resObj map[string]interface{}) {
require.Equal(t, "0x0", tx["yParity"])
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000002", resObj["transactionsRoot"])
require.Equal(t, []interface{}{}, resObj["uncles"])
require.Equal(t, "0x174876e800", resObj["baseFeePerGas"])
require.Equal(t, "0x3b9aca00", resObj["baseFeePerGas"])
require.Equal(t, "0x0", resObj["totalDifficulty"])
}

Expand Down
20 changes: 12 additions & 8 deletions evmrpc/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package evmrpc_test

import (
"errors"
"fmt"
"math/big"
"testing"

Expand Down Expand Up @@ -61,7 +62,8 @@ func TestGasPrice(t *testing.T) {
resObj := sendRequestGood(t, "gasPrice")
Ctx = Ctx.WithBlockHeight(8)
result := resObj["result"].(string)
require.Equal(t, "0x174876e800", result)
oneGwei := "0x3b9aca00"
require.Equal(t, oneGwei, result)
}

func TestFeeHistory(t *testing.T) {
Expand All @@ -80,12 +82,12 @@ func TestFeeHistory(t *testing.T) {
Ctx = Ctx.WithBlockHeight(1) // Simulate context with a specific block height

testCases := []feeHistoryTestCase{
{name: "Valid request by number", blockCount: 1, lastBlock: "0x8", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by latest", blockCount: 1, lastBlock: "latest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by earliest", blockCount: 1, lastBlock: "earliest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Request on the same block", blockCount: 1, lastBlock: "0x1", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Request on future block", blockCount: 1, lastBlock: "0x9", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Block count truncates", blockCount: 1025, lastBlock: "latest", rewardPercentiles: []interface{}{25}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by number", blockCount: 1, lastBlock: "0x8", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Valid request by latest", blockCount: 1, lastBlock: "latest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Valid request by earliest", blockCount: 1, lastBlock: "earliest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Request on the same block", blockCount: 1, lastBlock: "0x1", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Request on future block", blockCount: 1, lastBlock: "0x9", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Block count truncates", blockCount: 1025, lastBlock: "latest", rewardPercentiles: []interface{}{25}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Too many percentiles", blockCount: 10, lastBlock: "latest", rewardPercentiles: make([]interface{}, 101), expectedError: errors.New("rewardPercentiles length must be less than or equal to 100")},
{name: "Invalid percentiles order", blockCount: 10, lastBlock: "latest", rewardPercentiles: []interface{}{99, 1}, expectedError: errors.New("invalid reward percentiles: must be ascending and between 0 and 100")},
}
Expand All @@ -111,6 +113,8 @@ func TestFeeHistory(t *testing.T) {
reward, ok := rewards[0].([]interface{})
require.True(t, ok, "Expected reward to be a slice of interfaces")
require.Equal(t, 1, len(reward), "Expected exactly one sub-item in reward")
fmt.Println("resObj", resObj)

require.Equal(t, tc.expectedReward, reward[0].(string), "Reward does not match expected value")

require.Equal(t, tc.expectedBaseFee, resObj["baseFeePerGas"].([]interface{})[0].(string))
Expand Down Expand Up @@ -164,5 +168,5 @@ func TestMaxPriorityFeePerGas(t *testing.T) {
Ctx = Ctx.WithBlockHeight(1)
// Mimic request sending and handle the response
resObj := sendRequestGood(t, "maxPriorityFeePerGas")
assert.Equal(t, "0x0", resObj["result"])
assert.Equal(t, "0x170cdc1e00", resObj["result"])
}
2 changes: 1 addition & 1 deletion precompiles/pointer/pointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestAddNative(t *testing.T) {
evm = vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{})
ret, g, err := p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
require.Nil(t, err)
require.Equal(t, uint64(8881522), g)
require.Equal(t, uint64(8881534), g)
outputs, err := m.Outputs.Unpack(ret)
require.Nil(t, err)
addr := outputs[0].(common.Address)
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 @@ -54,7 +54,7 @@ func TestModuleExportGenesis(t *testing.T) {
cdc := app.MakeEncodingConfig().Marshaler
jsonMsg := module.ExportGenesis(ctx, cdc)
jsonStr := string(jsonMsg)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[],\"deliver_tx_hook_wasm_gas_limit\":\"300000\",\"max_dynamic_base_fee_upward_adjustment\":\"0.000000000000000000\",\"max_dynamic_base_fee_downward_adjustment\":\"0.000000000000000000\",\"target_gas_used_per_block\":\"100000\"},\"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":"1000000000.000000000000000000","whitelisted_cw_code_hashes_for_delegate_call":[],"deliver_tx_hook_wasm_gas_limit":"300000","max_dynamic_base_fee_upward_adjustment":"0.018900000000000000","max_dynamic_base_fee_downward_adjustment":"0.003900000000000000","target_gas_used_per_block":"250000"},"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
10 changes: 5 additions & 5 deletions x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ var DefaultPriorityNormalizer = sdk.NewDec(1)
// DefaultBaseFeePerGas determines how much usei per gas spent is
// burnt rather than go to validators (similar to base fee on
// Ethereum).
var DefaultBaseFeePerGas = sdk.NewDec(0) // used for static base fee, deprecated in favor of dynamic base fee
var DefaultMinFeePerGas = sdk.NewDec(100000000000)
var DefaultBaseFeePerGas = sdk.NewDec(0) // used for static base fee, deprecated in favor of dynamic base fee
var DefaultMinFeePerGas = sdk.NewDec(1000000000) // 1gwei
var DefaultDeliverTxHookWasmGasLimit = uint64(300000)

var DefaultWhitelistedCwCodeHashesForDelegateCall = generateDefaultWhitelistedCwCodeHashesForDelegateCall()

var DefaultMaxDynamicBaseFeeUpwardAdjustment = sdk.NewDec(0)
var DefaultMaxDynamicBaseFeeDownwardAdjustment = sdk.NewDec(0)
var DefaultTargetGasUsedPerBlock = uint64(100000)
var DefaultMaxDynamicBaseFeeUpwardAdjustment = sdk.NewDecWithPrec(189, 4) // 1.89%
var DefaultMaxDynamicBaseFeeDownwardAdjustment = sdk.NewDecWithPrec(39, 4) // .39%
var DefaultTargetGasUsedPerBlock = uint64(250000) // 250k

var _ paramtypes.ParamSet = (*Params)(nil)

Expand Down
Loading