Skip to content

Commit

Permalink
enable shanghai fork
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Nov 22, 2023
1 parent a2ec014 commit c9b139b
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 148 deletions.
4 changes: 1 addition & 3 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ func (suite *AnteTestSuite) SetupTest() {
evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt
evmGenesis.Params.ChainConfig.ShanghaiTime = math.MaxUint64
evmGenesis.Params.ChainConfig.CancunTime = math.MaxUint64
evmGenesis.Params.ChainConfig.PragueTime = math.MaxUint64
evmGenesis.Params.ChainConfig.ShanghaiTime = &maxInt
}
if suite.evmParamsOption != nil {
suite.evmParamsOption(&evmGenesis.Params)
Expand Down
21 changes: 0 additions & 21 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1813,19 +1813,16 @@ paths:
use as a network splitter
shanghai_time:
type: string
format: uint64
title: >-
shanghai switch time (nil = no fork, 0 = already on
shanghai)
cancun_time:
type: string
format: uint64
title: >-
cancun switch time (nil = no fork, 0 = already on
cancun)
prague_time:
type: string
format: uint64
title: >-
prague switch time (nil = no fork, 0 = already on
prague)
Expand Down Expand Up @@ -2636,19 +2633,16 @@ paths:
in: query
required: false
type: string
format: uint64
- name: trace_config.overrides.cancun_time
description: cancun switch time (nil = no fork, 0 = already on cancun).
in: query
required: false
type: string
format: uint64
- name: trace_config.overrides.prague_time
description: prague switch time (nil = no fork, 0 = already on prague).
in: query
required: false
type: string
format: uint64
- name: trace_config.enable_memory
description: enable_memory switches memory capture.
in: query
Expand Down Expand Up @@ -3156,19 +3150,16 @@ paths:
in: query
required: false
type: string
format: uint64
- name: trace_config.overrides.cancun_time
description: cancun switch time (nil = no fork, 0 = already on cancun).
in: query
required: false
type: string
format: uint64
- name: trace_config.overrides.prague_time
description: prague switch time (nil = no fork, 0 = already on prague).
in: query
required: false
type: string
format: uint64
- name: trace_config.enable_memory
description: enable_memory switches memory capture.
in: query
Expand Down Expand Up @@ -3531,15 +3522,12 @@ definitions:
splitter
shanghai_time:
type: string
format: uint64
title: shanghai switch time (nil = no fork, 0 = already on shanghai)
cancun_time:
type: string
format: uint64
title: cancun switch time (nil = no fork, 0 = already on cancun)
prague_time:
type: string
format: uint64
title: prague switch time (nil = no fork, 0 = already on prague)
description: >-
ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int
Expand Down Expand Up @@ -4008,15 +3996,12 @@ definitions:
network splitter
shanghai_time:
type: string
format: uint64
title: shanghai switch time (nil = no fork, 0 = already on shanghai)
cancun_time:
type: string
format: uint64
title: cancun switch time (nil = no fork, 0 = already on cancun)
prague_time:
type: string
format: uint64
title: prague switch time (nil = no fork, 0 = already on prague)
description: >-
ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int
Expand Down Expand Up @@ -4207,15 +4192,12 @@ definitions:
network splitter
shanghai_time:
type: string
format: uint64
title: shanghai switch time (nil = no fork, 0 = already on shanghai)
cancun_time:
type: string
format: uint64
title: cancun switch time (nil = no fork, 0 = already on cancun)
prague_time:
type: string
format: uint64
title: prague switch time (nil = no fork, 0 = already on prague)
description: >-
ChainConfig defines the Ethereum ChainConfig parameters using
Expand Down Expand Up @@ -4392,15 +4374,12 @@ definitions:
network splitter
shanghai_time:
type: string
format: uint64
title: shanghai switch time (nil = no fork, 0 = already on shanghai)
cancun_time:
type: string
format: uint64
title: cancun switch time (nil = no fork, 0 = already on cancun)
prague_time:
type: string
format: uint64
title: prague switch time (nil = no fork, 0 = already on prague)
description: >-
ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int
Expand Down
15 changes: 9 additions & 6 deletions proto/ethermint/evm/v1/chain_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@ message ChainConfig {
(gogoproto.moretags) = "yaml:\"merge_netsplit_block\""
];
// shanghai switch time (nil = no fork, 0 = already on shanghai)
uint64 shanghai_time = 22 [
(gogoproto.moretags) = "yaml:\"shanghai_time,omitempty\""
string shanghai_time = 22 [

Check failure on line 103 in proto/ethermint/evm/v1/chain_config.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "22" with name "shanghai_time" on message "ChainConfig" changed option "json_name" from "shanghaiBlock" to "shanghaiTime".

Check failure on line 103 in proto/ethermint/evm/v1/chain_config.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "22" on message "ChainConfig" changed name from "shanghai_block" to "shanghai_time".
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"shanghai_time\""
];
// cancun switch time (nil = no fork, 0 = already on cancun)
uint64 cancun_time = 23 [
(gogoproto.moretags) = "yaml:\"cancun_time,omitempty\""
string cancun_time = 23 [

Check failure on line 108 in proto/ethermint/evm/v1/chain_config.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "23" with name "cancun_time" on message "ChainConfig" changed option "json_name" from "cancunBlock" to "cancunTime".

Check failure on line 108 in proto/ethermint/evm/v1/chain_config.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "23" on message "ChainConfig" changed name from "cancun_block" to "cancun_time".
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"cancun_time\""
];
// prague switch time (nil = no fork, 0 = already on prague)
uint64 prague_time = 24 [
(gogoproto.moretags) = "yaml:\"prague_time,omitempty\""
string prague_time = 24 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"prague_time\""
];
}
1 change: 1 addition & 0 deletions scripts/geth-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"berlinBlock": 0,
"yoloV3Block": 0,
"londonBlock": 0,
"shanghaiTime": 0,
"clique": {
"period": 2,
"epoch": 30000
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/expected_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
EXPECTED_CONTRACT_CREATE_TRACER = {
"from": "0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2",
"gas": "0x7ef9d",
"gasUsed": "0x96651",
"gasUsed": "0x966fd",
"input": "0x608060405234801561001057600080fd5b50604080518082018252600981526805465737445524332360bc1b60208083019182528351808501909452600484526315195cdd60e21b90840152815191929161005c91600391610156565b508051610070906004906020840190610156565b50505061008e336a52b7d2dcc80cd2e400000061009360201b60201c565b610250565b6001600160a01b0382166100ed5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546100ff91906101ef565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b82805461016290610215565b90600052602060002090601f01602090048101928261018457600085556101ca565b82601f1061019d57805160ff19168380011785556101ca565b828001600101855582156101ca579182015b828111156101ca5782518255916020019190600101906101af565b506101d69291506101da565b5090565b5b808211156101d657600081556001016101db565b6000821982111561021057634e487b7160e01b600052601160045260246000fd5b500190565b600181811c9082168061022957607f821691505b6020821081141561024a57634e487b7160e01b600052602260045260246000fd5b50919050565b61085d8061025f6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012357806370a082311461013657806395d89b411461015f578063a457c2d714610167578063a9059cbb1461017a578063dd62ed3e1461018d57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101a0565b6040516100c3919061069a565b60405180910390f35b6100df6100da36600461070b565b610232565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610735565b61024a565b604051601281526020016100c3565b6100df61013136600461070b565b61026e565b6100f3610144366004610771565b6001600160a01b031660009081526020819052604090205490565b6100b6610290565b6100df61017536600461070b565b61029f565b6100df61018836600461070b565b61031f565b6100f361019b366004610793565b61032d565b6060600380546101af906107c6565b80601f01602080910402602001604051908101604052809291908181526020018280546101db906107c6565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b5050505050905090565b600033610240818585610358565b5060019392505050565b60003361025885828561047c565b6102638585856104f6565b506001949350505050565b600033610240818585610281838361032d565b61028b9190610801565b610358565b6060600480546101af906107c6565b600033816102ad828661032d565b9050838110156103125760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6102638286868403610358565b6000336102408185856104f6565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103ba5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610309565b6001600160a01b03821661041b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610309565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610488848461032d565b905060001981146104f057818110156104e35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610309565b6104f08484848403610358565b50505050565b6001600160a01b03831661055a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610309565b6001600160a01b0382166105bc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610309565b6001600160a01b038316600090815260208190526040902054818110156106345760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610309565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36104f0565b600060208083528351808285015260005b818110156106c7578581018301518582016040015282016106ab565b818111156106d9576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b038116811461070657600080fd5b919050565b6000806040838503121561071e57600080fd5b610727836106ef565b946020939093013593505050565b60008060006060848603121561074a57600080fd5b610753846106ef565b9250610761602085016106ef565b9150604084013590509250925092565b60006020828403121561078357600080fd5b61078c826106ef565b9392505050565b600080604083850312156107a657600080fd5b6107af836106ef565b91506107bd602084016106ef565b90509250929050565b600181811c908216806107da57607f821691505b602082108114156107fb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000821982111561082257634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220fee840cc9e1cfac46e073588ade030be1401c580c5849dd4e63f659a75eb220c64736f6c634300080a0033", # noqa: E501
"output": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461012357806370a082311461013657806395d89b411461015f578063a457c2d714610167578063a9059cbb1461017a578063dd62ed3e1461018d57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101a0565b6040516100c3919061069a565b60405180910390f35b6100df6100da36600461070b565b610232565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610735565b61024a565b604051601281526020016100c3565b6100df61013136600461070b565b61026e565b6100f3610144366004610771565b6001600160a01b031660009081526020819052604090205490565b6100b6610290565b6100df61017536600461070b565b61029f565b6100df61018836600461070b565b61031f565b6100f361019b366004610793565b61032d565b6060600380546101af906107c6565b80601f01602080910402602001604051908101604052809291908181526020018280546101db906107c6565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b5050505050905090565b600033610240818585610358565b5060019392505050565b60003361025885828561047c565b6102638585856104f6565b506001949350505050565b600033610240818585610281838361032d565b61028b9190610801565b610358565b6060600480546101af906107c6565b600033816102ad828661032d565b9050838110156103125760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6102638286868403610358565b6000336102408185856104f6565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103ba5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610309565b6001600160a01b03821661041b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610309565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000610488848461032d565b905060001981146104f057818110156104e35760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610309565b6104f08484848403610358565b50505050565b6001600160a01b03831661055a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610309565b6001600160a01b0382166105bc5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610309565b6001600160a01b038316600090815260208190526040902054818110156106345760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610309565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36104f0565b600060208083528351808285015260005b818110156106c7578581018301518582016040015282016106ab565b818111156106d9576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b038116811461070657600080fd5b919050565b6000806040838503121561071e57600080fd5b610727836106ef565b946020939093013593505050565b60008060006060848603121561074a57600080fd5b610753846106ef565b9250610761602085016106ef565b9150604084013590509250925092565b60006020828403121561078357600080fd5b61078c826106ef565b9392505050565b600080604083850312156107a657600080fd5b6107af836106ef565b91506107bd602084016106ef565b90509250929050565b600181811c908216806107da57607f821691505b602082108114156107fb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000821982111561082257634e487b7160e01b600052601160045260246000fd5b50019056fea2646970667358221220fee840cc9e1cfac46e073588ade030be1401c580c5849dd4e63f659a75eb220c64736f6c634300080a0033", # noqa: E501
"to": "0x8c76cfc1934d5120cc673b6e5ddf7b88feb1c18c",
Expand Down
2 changes: 1 addition & 1 deletion x/evm/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func (suite *EvmTestSuite) TestERC20TransferReverted() {
}

func (suite *EvmTestSuite) TestContractDeploymentRevert() {
intrinsicGas := uint64(134180)
intrinsicGas := uint64(134510)
testCases := []struct {
msg string
gasLimit uint64
Expand Down
4 changes: 2 additions & 2 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
}
},
true,
1186778,
1187108,
false,
},
// estimate gas of an erc20 transfer, the exact gas number is checked with geth
Expand Down Expand Up @@ -652,7 +652,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
}
},
true,
1186778,
1187108,
true,
},
{
Expand Down
4 changes: 1 addition & 3 deletions x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ func (suite *KeeperTestSuite) SetupAppWithT(checkTx bool, t require.TestingT) {
evmGenesis.Params.ChainConfig.ArrowGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt
evmGenesis.Params.ChainConfig.ShanghaiTime = math.MaxUint64
evmGenesis.Params.ChainConfig.CancunTime = math.MaxUint64
evmGenesis.Params.ChainConfig.PragueTime = math.MaxUint64
evmGenesis.Params.ChainConfig.ShanghaiTime = &maxInt
genesis[types.ModuleName] = app.AppCodec().MustMarshalJSON(evmGenesis)
}
return genesis
Expand Down
11 changes: 10 additions & 1 deletion x/evm/keeper/state_transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ func (suite *KeeperTestSuite) TestGetCoinbaseAddress() {
}
}

// toWordSize returns the ceiled word size required for init code payment calculation.
func toWordSize(size uint64) uint64 {
if size > math.MaxUint64-31 {
return math.MaxUint64/32 + 1
}

return (size + 31) / 32
}

func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() {
testCases := []struct {
name string
Expand Down Expand Up @@ -206,7 +215,7 @@ func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() {
1,
true,
true,
params.TxGas + params.TxDataNonZeroGasFrontier*1,
params.TxGas + params.TxDataNonZeroGasFrontier*1 + toWordSize(1)*params.InitCodeWordGas,
},
{
"no data, one accesslist, not contract creation, not homestead, not istanbul",
Expand Down
2 changes: 2 additions & 0 deletions x/evm/migrations/v6/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func MigrateStore(
bz := store.Get(types.KeyPrefixParams)
cdc.MustUnmarshal(bz, &params)
newParams = params.ToParams()
shanghaiTime := sdk.ZeroInt()
newParams.ChainConfig.ShanghaiTime = &shanghaiTime
if err := newParams.Validate(); err != nil {
return err
}
Expand Down
Loading

0 comments on commit c9b139b

Please sign in to comment.