Skip to content

Commit

Permalink
Merge tag 'v4.1.8-evm-devnet' into firehose/evm-devnet
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/eth_replay.go
#	go.mod
#	go.sum
#	precompiles/wasmd/wasmd.go
#	precompiles/wasmd/wasmd_test.go
#	scripts/initialize_local_chain.sh
#	x/evm/keeper/msg_server.go
#	x/evm/module.go
#	x/evm/state/state.go
#	x/evm/state/statedb.go
  • Loading branch information
maoueh committed Apr 16, 2024
2 parents 7e9ed15 + c432d1e commit 64f5659
Show file tree
Hide file tree
Showing 127 changed files with 5,818 additions and 622 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/eth_blocktests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ETH Blocktests

on:
push:
branches:
- seiv2
pull_request:
branches:
- seiv2

defaults:
run:
shell: bash

env:
TOTAL_RUNNERS: 5

jobs:
runner-indexes:
runs-on: ubuntu-latest
name: Generate runner indexes
outputs:
json: ${{ steps.generate-index-list.outputs.json }}
steps:
- id: generate-index-list
run: |
MAX_INDEX=$((${{ env.TOTAL_RUNNERS }}-1))
INDEX_LIST=$(seq 0 ${MAX_INDEX})
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST})
echo "json=${INDEX_JSON}" >> $GITHUB_OUTPUT
eth-blocktests:
name: "Run ETH Blocktests ${{ matrix.runner-index }}"
runs-on: ubuntu-latest
needs: runner-indexes
strategy:
fail-fast: false
matrix:
# generate runner index array from 0 to total-runners
runner-index: ${{fromJson(needs.runner-indexes.outputs.json)}}
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Clone ETH Blocktests
run: git clone https://github.com/ethereum/tests.git ethtests

- name: "Run ETH Blocktest"
run: ./run_blocktests.sh ./ethtests/BlockchainTests/ ${{ matrix.runner-index }} ${{ env.TOTAL_RUNNERS }}
6 changes: 4 additions & 2 deletions app/antedecorators/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
const (
OraclePriority = math.MaxInt64 - 100
EVMAssociatePriority = math.MaxInt64 - 101
// This is the max priority a non oracle or associate tx can take
MaxPriority = math.MaxInt64 - 1000
)

type PriorityDecorator struct{}
Expand All @@ -27,9 +29,9 @@ func intMin(a, b int64) int64 {

// Assigns higher priority to certain types of transactions including oracle
func (pd PriorityDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// Cap priority to MAXINT64 - 1000
// Cap priority
// Use higher priorities for tiers including oracle tx's
priority := intMin(ctx.Priority(), math.MaxInt64-1000)
priority := intMin(ctx.Priority(), MaxPriority)

if isOracleTx(tx) {
priority = OraclePriority
Expand Down
14 changes: 11 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ import (
evmante "github.com/sei-protocol/sei-chain/x/evm/ante"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
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"
evmtracers "github.com/sei-protocol/sei-chain/x/evm/tracers"
"github.com/sei-protocol/sei-chain/x/evm/tracing"
Expand Down Expand Up @@ -595,11 +596,16 @@ func New(

app.EvmKeeper = *evmkeeper.NewKeeper(keys[evmtypes.StoreKey], memKeys[evmtypes.MemStoreKey],
app.GetSubspace(evmtypes.ModuleName), app.BankKeeper, &app.AccountKeeper, &app.StakingKeeper,
app.TransferKeeper)
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))
}
evmQueryConfig, err := querier.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading evm query config due to %s", err))
}
app.EvmKeeper.QueryConfig = &evmQueryConfig
ethReplayConfig, err := replay.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading eth replay config due to %s", err))
Expand Down Expand Up @@ -658,7 +664,8 @@ func New(
AddRoute(dexmoduletypes.RouterKey, dexmodule.NewProposalHandler(app.DexKeeper)).
AddRoute(minttypes.RouterKey, mint.NewProposalHandler(app.MintKeeper)).
AddRoute(tokenfactorytypes.RouterKey, tokenfactorymodule.NewProposalHandler(app.TokenFactoryKeeper)).
AddRoute(acltypes.ModuleName, aclmodule.NewProposalHandler(app.AccessControlKeeper))
AddRoute(acltypes.ModuleName, aclmodule.NewProposalHandler(app.AccessControlKeeper)).
AddRoute(evmtypes.RouterKey, evm.NewProposalHandler(app.EvmKeeper))
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}
Expand Down Expand Up @@ -826,8 +833,8 @@ func New(
oracletypes.ModuleName,
tokenfactorytypes.ModuleName,
epochmoduletypes.ModuleName,
evmtypes.ModuleName,
wasm.ModuleName,
evmtypes.ModuleName,
acltypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)
Expand Down Expand Up @@ -1463,6 +1470,7 @@ func (app *App) ProcessTXsWithOCC(ctx sdk.Context, txs [][]byte, typedTxs []sdk.
GasUsed: r.Response.GasUsed,
Events: r.Response.Events,
Codespace: r.Response.Codespace,
EvmTxInfo: r.Response.EvmTxInfo,
})
}

Expand Down
32 changes: 32 additions & 0 deletions app/eth_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import (
"fmt"
"math/big"
"path/filepath"
"strings"
"time"

"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
ethcore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/tracing"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -89,6 +92,7 @@ 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())
}
a.EvmKeeper.VerifyTxResult(ctx, tx.Hash())
}
Expand Down Expand Up @@ -133,18 +137,23 @@ func BlockTest(a *App, bt *ethtests.BlockTest) {
for key, value := range genesisAccount.Storage {
a.EvmKeeper.SetState(a.GetContextForDeliverTx([]byte{}), addr, key, value)
}
params := a.EvmKeeper.GetParams(a.GetContextForDeliverTx([]byte{}))
params.MinimumFeePerGas = sdk.NewDecFromInt(sdk.NewInt(0))
a.EvmKeeper.SetParams(a.GetContextForDeliverTx([]byte{}), params)
}

if len(bt.Json.Blocks) == 0 {
panic("no blocks found")
}

ethblocks := make([]*ethtypes.Block, 0)
for i, btBlock := range bt.Json.Blocks {
h := int64(i + 1)
b, err := btBlock.Decode()
if err != nil {
panic(err)
}
ethblocks = append(ethblocks, b)
hash := make([]byte, 8)
binary.BigEndian.PutUint64(hash, uint64(h))
_, err = a.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{
Expand All @@ -167,6 +176,15 @@ func BlockTest(a *App, bt *ethtests.BlockTest) {
// Check post-state after all blocks are run
ctx := a.GetCheckCtx()
for addr, accountData := range bt.Json.Post {
if IsWithdrawalAddress(addr, ethblocks) {
fmt.Println("Skipping withdrawal address: ", addr)
continue
}
// Not checking compliance with EIP-4788
if addr == params.BeaconRootsStorageAddress {
fmt.Println("Skipping beacon roots storage address: ", addr)
continue
}
a.EvmKeeper.VerifyAccount(ctx, addr, accountData)
fmt.Println("Successfully verified account: ", addr)
}
Expand All @@ -186,6 +204,9 @@ func encodeTx(tx *ethtypes.Transaction, txConfig client.TxConfig) []byte {
txData, err = ethtx.NewBlobTx(tx)
}
if err != nil {
if strings.Contains(err.Error(), ethcore.ErrTipAboveFeeCap.Error()) {
return nil
}
panic(err)
}
msg, err := evmtypes.NewMsgEVMTransaction(txData)
Expand All @@ -202,3 +223,14 @@ func encodeTx(tx *ethtypes.Transaction, txConfig client.TxConfig) []byte {
}
return txbz
}

func IsWithdrawalAddress(addr common.Address, blocks []*ethtypes.Block) bool {
for _, block := range blocks {
for _, w := range block.Withdrawals() {
if w.Address == addr {
return true
}
}
}
return false
}
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ var upgradesList = []string{
"v4.1.5-evm-devnet",
"v4.1.6-evm-devnet",
"v4.1.7-evm-devnet",
"v4.1.8-evm-devnet",
}

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

ETHBlockTest blocktest.Config `mapstructure:"eth_block_test"`

EvmQuery querier.Config `mapstructure:"evm_query"`
}

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

customAppTemplate := serverconfig.DefaultConfigTemplate + `
Expand Down Expand Up @@ -496,6 +500,9 @@ eth_data_dir = "{{ .ETHReplay.EthDataDir }}"
[eth_blocktest]
eth_blocktest_enabled = {{ .ETHBlockTest.Enabled }}
eth_blocktest_test_data_path = "{{ .ETHBlockTest.TestDataPath }}"
[evm_query]
evm_query_gas_limit = {{ .EvmQuery.GasLimit }}
`

return customAppTemplate, customAppConfig
Expand Down
30 changes: 15 additions & 15 deletions contracts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@openzeppelin/hardhat-upgrades": "^3.0.2",
"@openzeppelin/test-helpers": "^0.5.16",
"dotenv": "^16.3.1",
"ethers": "^6.9.0",
"ethers": "^6.11.1",
"hardhat": "^2.20.1"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions contracts/src/CW721ERC721Pointer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ contract CW721ERC721Pointer is ERC721 {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
require(from == ownerOf(tokenId), "`from` must be the owner");
string memory recipient = _formatPayload("recipient", _doubleQuotes(AddrPrecompile.getSeiAddr(to)));
string memory tId = _formatPayload("token_id", _doubleQuotes(Strings.toString(tokenId)));
string memory req = _curlyBrace(_formatPayload("transfer_nft", _curlyBrace(_join(recipient, tId, ","))));
Expand Down
Loading

0 comments on commit 64f5659

Please sign in to comment.