Skip to content

Commit

Permalink
Merge tag 'v5.1.2' into release/firehose
Browse files Browse the repository at this point in the history
# Conflicts:
#	x/evm/keeper/msg_server.go
#	x/evm/module.go
#	x/evm/module_test.go
  • Loading branch information
maoueh committed May 2, 2024
2 parents e73963a + 7f1037f commit aa512a8
Show file tree
Hide file tree
Showing 108 changed files with 3,824 additions and 717 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,25 @@ jobs:
],
},
{
name: "Hardhat tests",
name: "SeiDB State Store",
scripts: [
"docker exec sei-node-0 integration_test/contracts/deploy_wasm_contracts.sh",
"docker exec sei-node-0 integration_test/contracts/create_tokenfactory_denoms.sh",
"python3 integration_test/scripts/runner.py integration_test/seidb/state_store_test.yaml",
]
},
{
name: "EVM Module",
scripts: [
"python3 integration_test/scripts/runner.py integration_test/evm_module/hardhat_test.yaml",
"./scripts/hardhat.sh"
"./integration_test/evm_module/scripts/evm_tests.sh",
]
},
{
name: "SeiDB State Store",
name: "EVM Interoperability",
scripts: [
"docker exec sei-node-0 integration_test/contracts/deploy_wasm_contracts.sh",
"docker exec sei-node-0 integration_test/contracts/create_tokenfactory_denoms.sh",
"python3 integration_test/scripts/runner.py integration_test/seidb/state_store_test.yaml",
"python3 integration_test/scripts/runner.py integration_test/evm_module/hardhat_test.yaml",
"./integration_test/evm_module/scripts/evm_interoperability_tests.sh"
]
},
]
Expand All @@ -127,7 +134,7 @@ jobs:
python-version: '3.10'
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'

- name: Pyyaml
run: |
Expand Down
4 changes: 2 additions & 2 deletions aclmapping/evm/mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ func (suite *KeeperTestSuite) buildSendMsgTo(to common.Address, amt *big.Int) *t
To: &to,
Value: amt,
Data: []byte(""),
ChainID: suite.App.EvmKeeper.ChainID(),
ChainID: suite.App.EvmKeeper.ChainID(suite.Ctx),
}
ethCfg := types.DefaultChainConfig().EthereumConfig(suite.App.EvmKeeper.ChainID())
ethCfg := types.DefaultChainConfig().EthereumConfig(suite.App.EvmKeeper.ChainID(suite.Ctx))
signer := ethtypes.MakeSigner(ethCfg, big.NewInt(suite.Ctx.BlockHeight()), uint64(suite.Ctx.BlockTime().Unix()))
tx := ethtypes.NewTx(&txData)
tx, err := ethtypes.SignTx(tx, signer, suite.sender)
Expand Down
2 changes: 1 addition & 1 deletion app/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestEvmAnteErrorHandler(t *testing.T) {
Data: []byte{},
Nonce: 1, // will cause ante error
}
chainID := testkeeper.EVMTestApp.EvmKeeper.ChainID()
chainID := testkeeper.EVMTestApp.EvmKeeper.ChainID(ctx)
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
Expand Down
6 changes: 1 addition & 5 deletions app/antedecorators/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ import (

func GetGasMeterSetter(pk paramskeeper.Keeper) func(bool, sdk.Context, uint64, sdk.Tx) sdk.Context {
return func(simulate bool, ctx sdk.Context, gasLimit uint64, tx sdk.Tx) sdk.Context {
if ctx.BlockHeight() == 0 {
return ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

cosmosGasParams := pk.GetCosmosGasParams(ctx)

// In simulation, still use multiplier but with infinite gas limit
if simulate {
if simulate || ctx.BlockHeight() == 0 {
return ctx.WithGasMeter(types.NewInfiniteMultiplierGasMeter(cosmosGasParams.CosmosGasMultiplierNumerator, cosmosGasParams.CosmosGasMultiplierDenominator))
}

Expand Down
44 changes: 27 additions & 17 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ import (
"github.com/sei-protocol/sei-chain/x/evm"
evmante "github.com/sei-protocol/sei-chain/x/evm/ante"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
evmconfig "github.com/sei-protocol/sei-chain/x/evm/config"
evmkeeper "github.com/sei-protocol/sei-chain/x/evm/keeper"
"github.com/sei-protocol/sei-chain/x/evm/querier"
"github.com/sei-protocol/sei-chain/x/evm/replay"
Expand Down Expand Up @@ -425,7 +424,7 @@ func New(
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, dexmoduletypes.MemStoreKey, banktypes.DeferredCacheStoreKey, evmtypes.MemStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, dexmoduletypes.MemStoreKey, banktypes.DeferredCacheStoreKey, evmtypes.MemStoreKey, oracletypes.MemStoreKey)

app := &App{
BaseApp: bApp,
Expand Down Expand Up @@ -520,7 +519,7 @@ func New(
app.EvidenceKeeper = *evidenceKeeper

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec, keys[oracletypes.StoreKey], app.GetSubspace(oracletypes.ModuleName),
appCodec, keys[oracletypes.StoreKey], memKeys[oracletypes.MemStoreKey], app.GetSubspace(oracletypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.DistrKeeper, &stakingKeeper, distrtypes.ModuleName,
)

Expand Down Expand Up @@ -596,13 +595,9 @@ func New(
wasmOpts...,
)

evmConfig, err := evmconfig.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading EVM config due to %s", err))
}
app.EvmKeeper = *evmkeeper.NewKeeper(keys[evmtypes.StoreKey], memKeys[evmtypes.MemStoreKey],
app.GetSubspace(evmtypes.ModuleName), app.BankKeeper, &app.AccountKeeper, &app.StakingKeeper,
app.TransferKeeper, wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), &evmConfig)
app.TransferKeeper, wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper))
app.evmRPCConfig, err = evmrpc.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading EVM config due to %s", err))
Expand Down Expand Up @@ -630,15 +625,6 @@ func New(
app.EvmKeeper.EthClient = ethclient.NewClient(rpcclient)
}

if app.evmRPCConfig.LiveEVMTracer != "" {
chainConfig := evmtypes.DefaultChainConfig().EthereumConfig(app.EvmKeeper.ChainID())
evmTracer, err := evmtracers.NewBlockchainTracer(evmtracers.GlobalLiveTracerRegistry, app.evmRPCConfig.LiveEVMTracer, chainConfig)
if err != nil {
panic(fmt.Sprintf("error creating EVM tracer due to %s", err))
}
app.evmTracer = evmTracer
}

customDependencyGenerators := aclmapping.NewCustomDependencyGenerator()
aclOpts = append(aclOpts, aclkeeper.WithResourceTypeToStoreKeyMap(aclutils.ResourceTypeToStoreKeyMap))
aclOpts = append(aclOpts, aclkeeper.WithDependencyGeneratorMappings(customDependencyGenerators.GetCustomDependencyGenerators(app.EvmKeeper)))
Expand Down Expand Up @@ -971,6 +957,15 @@ func New(
app.HardForkManager = upgrades.NewHardForkManager(app.ChainID)
app.HardForkManager.RegisterHandler(v0upgrade.NewHardForkUpgradeHandler(100_000, upgrades.ChainIDSeiHardForkTest, app.WasmKeeper))

if app.evmRPCConfig.LiveEVMTracer != "" {
chainConfig := evmtypes.DefaultChainConfig().EthereumConfig(app.EvmKeeper.ChainID(app.GetCheckCtx()))
evmTracer, err := evmtracers.NewBlockchainTracer(evmtracers.GlobalLiveTracerRegistry, app.evmRPCConfig.LiveEVMTracer, chainConfig)
if err != nil {
panic(fmt.Sprintf("error creating EVM tracer due to %s", err))
}
app.evmTracer = evmTracer
}

return app
}

Expand Down Expand Up @@ -1023,6 +1018,15 @@ func (app *App) SetStoreUpgradeHandlers() {
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if upgradeInfo.Name == "v5.1.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{evmtypes.StoreKey},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

// AppName returns the name of the App
Expand Down Expand Up @@ -1132,6 +1136,9 @@ func (app *App) FinalizeBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock)
if !app.optimisticProcessingInfo.Aborted && bytes.Equal(app.optimisticProcessingInfo.Hash, req.Hash) {
metrics.IncrementOptimisticProcessingCounter(true)
app.SetProcessProposalStateToCommit()
if app.EvmKeeper.EthReplayConfig.Enabled || app.EvmKeeper.EthBlockTestConfig.Enabled {
return &abci.ResponseFinalizeBlock{}, nil
}
appHash := app.WriteStateToCommitAndGetWorkingHash()
resp := app.getFinalizeBlockResponse(appHash, app.optimisticProcessingInfo.Events, app.optimisticProcessingInfo.TxRes, app.optimisticProcessingInfo.EndBlockResp)
return &resp, nil
Expand All @@ -1144,6 +1151,9 @@ func (app *App) FinalizeBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock)
events, txResults, endBlockResp, _ := app.ProcessBlock(ctx, req.Txs, req, req.DecidedLastCommit)

app.SetDeliverStateToCommit()
if app.EvmKeeper.EthReplayConfig.Enabled || app.EvmKeeper.EthBlockTestConfig.Enabled {
return &abci.ResponseFinalizeBlock{}, nil
}
appHash := app.WriteStateToCommitAndGetWorkingHash()
resp := app.getFinalizeBlockResponse(appHash, events, txResults, endBlockResp)
return &resp, nil
Expand Down
3 changes: 2 additions & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/sei-protocol/sei-chain/app"
testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper"
dextypes "github.com/sei-protocol/sei-chain/x/dex/types"
"github.com/sei-protocol/sei-chain/x/evm/config"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
"github.com/sei-protocol/sei-chain/x/evm/types/ethtx"
oracletypes "github.com/sei-protocol/sei-chain/x/oracle/types"
Expand Down Expand Up @@ -372,7 +373,7 @@ func TestDecodeTransactionsConcurrently(t *testing.T) {
Data: []byte("abc"),
}
chainCfg := evmtypes.DefaultChainConfig()
ethCfg := chainCfg.EthereumConfig(big.NewInt(713715))
ethCfg := chainCfg.EthereumConfig(big.NewInt(config.DefaultChainID))
signer := ethtypes.MakeSigner(ethCfg, big.NewInt(1), uint64(123))
tx, err := ethtypes.SignTx(ethtypes.NewTx(&txData), signer, key)
ethtxdata, _ := ethtx.NewTxDataFromTx(tx)
Expand Down
4 changes: 3 additions & 1 deletion app/eth_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func Replay(a *App) {
a.Logger().Info(fmt.Sprintf("Verifying tx %s", tx.Hash().Hex()))
if tx.To() != nil {
a.EvmKeeper.VerifyBalance(ctx, *tx.To())
a.EvmKeeper.VerifyState(ctx, *tx.To())
if a.EvmKeeper.EthReplayConfig.ContractStateChecks {
a.EvmKeeper.VerifyState(ctx, *tx.To())
}
}
a.EvmKeeper.VerifyTxResult(ctx, tx.Hash())
}
Expand Down
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var upgradesList = []string{
"v4.2.0-evm-devnet",
"v5.0.0",
"v5.0.1",
"v5.1.0",
}

// if there is an override list, use that instead, for integration tests
Expand Down
8 changes: 1 addition & 7 deletions cmd/seid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/sei-protocol/sei-chain/evmrpc"
"github.com/sei-protocol/sei-chain/tools"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
evmconfig "github.com/sei-protocol/sei-chain/x/evm/config"
"github.com/sei-protocol/sei-chain/x/evm/querier"
"github.com/sei-protocol/sei-chain/x/evm/replay"
"github.com/spf13/cast"
Expand Down Expand Up @@ -382,8 +381,6 @@ func initAppConfig() (string, interface{}) {
ETHBlockTest blocktest.Config `mapstructure:"eth_block_test"`

EvmQuery querier.Config `mapstructure:"evm_query"`

EvmModule evmconfig.Config `mapstructure:"evm_module"`
}

// Optionally allow the chain developer to overwrite the SDK's default
Expand Down Expand Up @@ -427,7 +424,6 @@ func initAppConfig() (string, interface{}) {
ETHReplay: replay.DefaultConfig,
ETHBlockTest: blocktest.DefaultConfig,
EvmQuery: querier.DefaultConfig,
EvmModule: evmconfig.DefaultConfig,
}

customAppTemplate := serverconfig.DefaultConfigTemplate + `
Expand Down Expand Up @@ -509,16 +505,14 @@ max_blocks_for_log = {{ .EVM.MaxBlocksForLog }}
eth_replay_enabled = {{ .ETHReplay.Enabled }}
eth_rpc = "{{ .ETHReplay.EthRPC }}"
eth_data_dir = "{{ .ETHReplay.EthDataDir }}"
eth_replay_contract_state_checks = {{ .ETHReplay.ContractStateChecks }}
[eth_blocktest]
eth_blocktest_enabled = {{ .ETHBlockTest.Enabled }}
eth_blocktest_test_data_path = "{{ .ETHBlockTest.TestDataPath }}"
[evm_query]
evm_query_gas_limit = {{ .EvmQuery.GasLimit }}
[evm_module]
evm_chain_id = {{ .EvmModule.ChainID }}
`

return customAppTemplate, customAppConfig
Expand Down
12 changes: 6 additions & 6 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ module.exports = {
address: ["0xF87A299e6bC7bEba58dbBe5a5Aa21d49bCD16D52"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e"], // Replace with your private key
},
sei: {
url: "https://evm-devnet.seinetwork.io", // Replace with your JSON-RPC URL
address: ["0x07dc55085b721947d5c1645a07929eac9f1cc750"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e"], // Replace with your private key
},
seilocal: {
url: "http://127.0.0.1:8545",
address: ["0xF87A299e6bC7bEba58dbBe5a5Aa21d49bCD16D52", "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"], // Replace with your private key
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"],
},
devnet: {
url: "https://evm-rpc.arctic-1.seinetwork.io/",
address: ["0xF87A299e6bC7bEba58dbBe5a5Aa21d49bCD16D52"],
accounts: ["0x57acb95d82739866a5c29e40b0aa2590742ae50425b7dd5b5d279a986370189e", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"],
}
},
};
4 changes: 2 additions & 2 deletions contracts/src/CW721ERC721Pointer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ contract CW721ERC721Pointer is ERC721 {
string memory spender = _formatPayload("spender", _doubleQuotes(AddrPrecompile.getSeiAddr(approved)));
string memory tId = _formatPayload("token_id", _doubleQuotes(Strings.toString(tokenId)));
string memory req = _curlyBrace(_formatPayload("approve", _curlyBrace(_join(spender, tId, ","))));
_execute(bytes(req));
emit Approval(ownerOf(tokenId), approved, tokenId);
_execute(bytes(req));
emit Approval(ownerOf(tokenId), approved, tokenId);
}

function setApprovalForAll(address operator, bool approved) public override {
Expand Down
37 changes: 37 additions & 0 deletions contracts/src/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,43 @@ contract ERC721 is IERC721 {
}

contract MyNFT is ERC721 {

// needed to concatenate the token ID to the URI
function uintToString(uint _num) internal pure returns (string memory) {
if (_num == 0) {
return "0";
}
uint j = _num;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
while (_num != 0) {
k = k-1;
uint8 temp = (48 + uint8(_num - _num / 10 * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_num /= 10;
}
return string(bstr);
}

function name() external pure returns (string memory _name) {
return "MyNFT";
}

function symbol() external pure returns (string memory _symbol) {
return "MYNFT";
}

function tokenURI(uint256 tokenId) external pure returns (string memory) {
string memory numAsString = uintToString(tokenId);
return string(abi.encodePacked("https://sei.io/token/", numAsString));
}

function mint(address to, uint id) external {
_mint(to, id);
}
Expand Down
Loading

0 comments on commit aa512a8

Please sign in to comment.