Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ sei-chain
* On a pruned node, debug_trace* and eth_getTransactionByBlockNumberAndIndex at "earliest" or 0x0 use the earliest available block, not the genesis initial height.
* eth_getLogs and filters clamp "earliest" and 0x0 bounds to the earliest available receipts instead of erroring.
* eth_call, eth_estimateGas and debug_traceCall state overrides cannot move Sei precompiles, and a `code` override at a Sei precompile address is ignored.
* Activate Osaka and Sei's Amsterdam subset (CON-528) with the v6.9 binary. App-hash breaking; minor-version upgrade only.
* Osaka: CLZ (EIP-7939), MODEXP input bounds and repricing (EIP-7823, EIP-7883), P256VERIFY precompile at 0x100 (EIP-7951), and a 2^24 per-transaction gas cap enforced in CheckTx and execution (EIP-7825).
* Amsterdam subset: ETH transfer logs (EIP-7708; value sent to the payable Sei precompiles is not logged yet and is left to giga's precompile conversions), 64 KiB code and 128 KiB initcode limits (EIP-7954), DUPN/SWAPN/EXCHANGE (EIP-8024), and SELFDESTRUCT no longer burns, so a self-destructed account keeps its balance (EIP-8246).
* eth_sendRawTransaction returns the CheckTx log of a rejected transaction, such as `transaction gas limit too high (cap: 16777216, tx: 16777217): out of gas`, instead of only the registered error's message or `: unknown`.
* [#4319](https://github.com/sei-protocol/sei-chain/pull/4319) Remove the oracle module behind the v6.8 upgrade: module, store, protobuf schema, wasm query route and tooling are gone; only the oracle Msg types remain decodable so historical blocks still trace. App-hash breaking at the upgrade height.
* [#4332](https://github.com/sei-protocol/sei-chain/pull/4332) Bump sei-protocol/go-ethereum to v1.15.7-sei-21
* [#4329](https://github.com/sei-protocol/sei-chain/pull/4329) Add Giga fetch/serve and BlockDB prune metrics
Expand Down
7 changes: 3 additions & 4 deletions app/ante/evm_checktx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ante

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

Expand All @@ -12,7 +11,6 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/sei-protocol/sei-chain/app/antedecorators"
cryptotypes "github.com/sei-protocol/sei-chain/sei-cosmos/crypto/types"
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
Expand Down Expand Up @@ -102,8 +100,9 @@ func EvmStatelessChecks(ctx sdk.Context, tx sdk.Tx, chainID *big.Int) error {
return nil
}
etx, _ := msg.AsTransaction()
if etx.To() == nil && len(etx.Data()) > params.MaxInitCodeSize {
return fmt.Errorf("%w: code size %v, limit %v", vm.ErrMaxInitCodeSizeExceeded, len(etx.Data()), params.MaxInitCodeSize)
rules := evmtypes.EthereumRules(ctx.BlockTime().Unix())
if err := evmtypes.ValidateTxLimits(etx, &rules); err != nil {
return err
}

if etx.Value().Sign() < 0 {
Expand Down
13 changes: 11 additions & 2 deletions evmrpc/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (s *SendAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (
} else if res == nil {
err = errors.New("missing broadcast response")
} else if res.CheckTx.Code != 0 {
err = sdkerrors.ABCIError(sdkerrors.RootCodespace, res.CheckTx.Code, "")
err = checkTxError(res.CheckTx.Codespace, res.CheckTx.Code, res.CheckTx.Log)
}
} else {
res, broadcastError := s.tmClient.BroadcastTx(ctx, txbz)
Expand All @@ -153,12 +153,21 @@ func (s *SendAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (
} else if res == nil {
err = errors.New("missing broadcast response")
} else if res.Code != 0 {
err = sdkerrors.ABCIError(sdkerrors.RootCodespace, res.Code, "")
err = checkTxError(res.Codespace, res.Code, res.Log)
}
}
return
}

// checkTxError returns the error a rejected CheckTx reported: its log when it has one, otherwise
// the registered error for its codespace and code.
func checkTxError(codespace string, code uint32, log string) error {
if log == "" {
return sdkerrors.ABCIError(codespace, code, "")
}
return errors.New(log)
}

func getSender(tx *ethtypes.Transaction, chainID *big.Int) (common.Address, error) {
return ethtypes.LatestSignerForChainID(chainID).Sender(tx)
}
Expand Down
44 changes: 43 additions & 1 deletion evmrpc/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/sei-protocol/sei-chain/sei-cosmos/client"
"github.com/sei-protocol/sei-chain/sei-cosmos/crypto/hd"
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
sdkerrors "github.com/sei-protocol/sei-chain/sei-cosmos/types/errors"
abci "github.com/sei-protocol/sei-chain/sei-tendermint/abci/types"
"github.com/sei-protocol/sei-chain/sei-tendermint/libs/utils"
"github.com/sei-protocol/sei-chain/sei-tendermint/rpc/coretypes"
tmtypes "github.com/sei-protocol/sei-chain/sei-tendermint/types"
Expand Down Expand Up @@ -126,7 +128,7 @@ func TestSendRawTransaction(t *testing.T) {
// bad server
resObj = sendRequestBad(t, "sendRawTransaction", payload)
errMap = resObj["error"].(map[string]interface{})
require.Equal(t, ": invalid sequence", errMap["message"].(string))
require.Equal(t, "log", errMap["message"].(string))
}

func TestSendRawTransactionUsesProxy(t *testing.T) {
Expand Down Expand Up @@ -249,6 +251,46 @@ func TestSendRawTransactionSlowOnCometUsesBroadcastTxCommit(t *testing.T) {
require.Equal(t, 1, tmClient.commitCount)
}

type sendRejectClient struct {
*MockClient
codespace string
code uint32
log string
}

func (c *sendRejectClient) BroadcastTx(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTx, error) {
return &coretypes.ResultBroadcastTx{Code: c.code, Codespace: c.codespace, Log: c.log}, nil
}

func (c *sendRejectClient) BroadcastTxCommit(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
return &coretypes.ResultBroadcastTxCommit{CheckTx: abci.ResponseCheckTx{Code: c.code, Codespace: c.codespace, Log: c.log}}, nil
}

// A rejected CheckTx reaches the client with its log, or its registered error when there is none.
func TestSendRawTransactionReportsCheckTxRejection(t *testing.T) {
ethTxBytes, _ := mustSignTestTx(t)
outOfGas := sdkerrors.ErrOutOfGas
for _, tc := range []struct {
name string
slow bool
log string
want string
}{
{name: "sync_with_log", log: "transaction gas limit too high: out of gas", want: "transaction gas limit too high: out of gas"},
{name: "commit_with_log", slow: true, log: "transaction gas limit too high: out of gas", want: "transaction gas limit too high: out of gas"},
{name: "sync_without_log", want: ": out of gas"},
} {
t.Run(tc.name, func(t *testing.T) {
tmClient := &sendRejectClient{MockClient: &MockClient{}, codespace: outOfGas.Codespace(), code: outOfGas.ABCICode(), log: tc.log}
sendAPI := newTestSendAPI(tmClient, evmrpc.NewSendConfig(tc.slow, false, false))

_, err := sendAPI.SendRawTransaction(context.Background(), hexutil.Bytes(ethTxBytes))

require.EqualError(t, err, tc.want)
})
}
}

func mustSignTestTx(t *testing.T) ([]byte, *ethtypes.Transaction) {
t.Helper()
to := common.HexToAddress("010203")
Expand Down
6 changes: 3 additions & 3 deletions evmrpc/tests/receipt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func TestReceiptLogIndex(t *testing.T) {
SetupTestServer(t, [][][]byte{{tx1Bz, tx2Bz}}, erc20Initializer()).Run(
func(port int) {
res := sendRequestWithNamespace("eth", port, "getTransactionReceipt", tx2.Hash().Hex())
// both tx 1 and tx2 have 1 log. Log of tx 1 will have log index 0x0 and
// log of tx 2 will have log index 0x1.
require.Equal(t, "0x1", res["result"].(map[string]interface{})["logs"].([]interface{})[0].(map[string]interface{})["logIndex"])
// tx 1 has an EIP-7708 transfer log and a Deposit log (0x0, 0x1), so the
// log of tx 2 has log index 0x2.
require.Equal(t, "0x2", res["result"].(map[string]interface{})["logs"].([]interface{})[0].(map[string]interface{})["logIndex"])
},
)
}
8 changes: 6 additions & 2 deletions giga/deps/xevm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (s *DBImpl) SetTransientState(addr common.Address, key, val common.Hash) {

// SelfDestruct marks acc self-destructed; transient state is kept for the rest of the tx.
func (s *DBImpl) SelfDestruct(acc common.Address) {
if seiAddr, ok := s.k.GetSeiAddress(s.ctx, acc); ok {
// remove the association
// EIP-8246 keeps the balance, so keep the association that holds it.
if seiAddr, ok := s.k.GetSeiAddress(s.ctx, acc); ok && !types.EthereumRules(s.ctx.BlockTime().Unix()).IsSeiAmsterdam {
s.k.DeleteAddressMapping(s.ctx, seiAddr, acc)
}
// The balance is left alone: the SELFDESTRUCT opcode transfers or burns it
Expand Down Expand Up @@ -178,6 +178,10 @@ func (s *DBImpl) RevertToSnapshot(rev int) {
}

func (s *DBImpl) handleResidualFundsInDestructedAccounts(st *TemporaryState) {
// EIP-8246 keeps a self-destructed account's balance.
if types.EthereumRules(s.ctx.BlockTime().Unix()).IsSeiAmsterdam {
return
}
for a, status := range st.transientAccounts {
if !bytes.Equal(status, AccountDeleted) {
continue
Expand Down
13 changes: 7 additions & 6 deletions giga/deps/xevm/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ func TestSelfDestructAssociated(t *testing.T) {
require.Equal(t, uint256.NewInt(1), statedb.GetBalance(evmAddr))
statedb.Finalize()
require.Equal(t, common.Hash{}, statedb.GetState(evmAddr, key))
// association should also be removed
_, ok := k.GetSeiAddress(statedb.Ctx(), evmAddr)
require.False(t, ok)
// balance in destructed account should be cleared and transferred to coinbase
require.Equal(t, uint256.NewInt(0), statedb.GetBalance(evmAddr))
// EIP-8246: the association is kept with the balance
gotSei, ok := k.GetSeiAddress(statedb.Ctx(), evmAddr)
require.True(t, ok)
require.Equal(t, seiAddr, gotSei)
// EIP-8246: the destructed account keeps its balance
require.Equal(t, uint256.NewInt(1), statedb.GetBalance(evmAddr))
fc, _ := k.GetFeeCollectorAddress(statedb.Ctx())
require.Equal(t, uint256.NewInt(1), statedb.GetBalance(fc))
require.Equal(t, uint256.NewInt(0), statedb.GetBalance(fc))
}

// TestEIP6780WithPrefundedAddress verifies that EIP-6780 selfdestruct works correctly
Expand Down
14 changes: 14 additions & 0 deletions giga/deps/xevm/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
var CancunTime int64 = 0
var PragueTime int64 = 0

// OsakaTime and SeiAmsterdamTime activate Osaka and Sei's Amsterdam subset (EIP-7708,
// 7954, 8024, 8246) with the v6.9 binary; -1 disables.
var OsakaTime int64 = 0
var SeiAmsterdamTime int64 = 0

/*
*
XXBlock/Time fields indicate upgrade heights/timestamps. For example, a BerlinBlock
Expand Down Expand Up @@ -45,6 +50,8 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig {
ShanghaiTime: getUpgradeTimestamp(0),
CancunTime: getUpgradeTimestamp(cc.CancunTime),
PragueTime: getUpgradeTimestamp(cc.PragueTime),
OsakaTime: getUpgradeTimestamp(cc.OsakaTime),
SeiAmsterdamTime: getUpgradeTimestamp(cc.SeiAmsterdamTime),
UBTTime: getUpgradeTimestamp(cc.VerkleTime),
BlobScheduleConfig: params.DefaultBlobSchedule,
}
Expand All @@ -60,11 +67,18 @@ func DefaultChainConfig() ChainConfig {
return ChainConfig{
CancunTime: CancunTime,
PragueTime: PragueTime,
OsakaTime: OsakaTime,
SeiAmsterdamTime: SeiAmsterdamTime,
VerkleTime: -1,
SeiSstoreSetGasEip2200: DefaultSeiSstoreSetGasEIP2200,
}
}

// EthereumRules returns the go-ethereum fork rules active at blockTime.
func EthereumRules(blockTime int64) params.Rules {
return DefaultChainConfig().EthereumConfig(nil).Rules(utils.Big0, true, uint64(blockTime)) //nolint:gosec
}

func getUpgradeTimestamp(i int64) *uint64 {
if i < 0 {
return nil
Expand Down
112 changes: 93 additions & 19 deletions giga/deps/xevm/types/config.pb.go

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

Loading
Loading