diff --git a/ethereum/rpc/account.go b/ethereum/rpc/account.go index 17add7f..37d8076 100644 --- a/ethereum/rpc/account.go +++ b/ethereum/rpc/account.go @@ -6,6 +6,7 @@ import ( "math/big" "time" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -27,7 +28,6 @@ import ( "github.com/artela-network/artela-rollkit/ethereum/rpc/types" types2 "github.com/artela-network/artela-rollkit/ethereum/types" "github.com/artela-network/artela-rollkit/ethereum/utils" - "github.com/artela-network/artela-rollkit/x/evm/txs" evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" ) @@ -155,7 +155,7 @@ func (b *BackendImpl) Sign(address common.Address, data hexutil.Bytes) (hexutil. } // Sign the requested hash with the wallet - signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data, nil) + signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data, signing.SignMode_SIGN_MODE_DIRECT) if err != nil { return nil, err } @@ -235,7 +235,7 @@ func (b *BackendImpl) getAccountNonce(accAddr common.Address, pending bool, heig // only supports `MsgEthereumTx` style tx for _, tx := range pendingTxs { for _, msg := range (*tx).GetMsgs() { - ethMsg, ok := msg.(*txs.MsgEthereumTx) + ethMsg, ok := msg.(*evmtypes.MsgEthereumTx) if !ok { // not ethereum tx break diff --git a/ethereum/rpc/filters/api.go b/ethereum/rpc/filters/api.go index d819564..d8b295b 100644 --- a/ethereum/rpc/filters/api.go +++ b/ethereum/rpc/filters/api.go @@ -331,16 +331,16 @@ func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, er return } - data, ok := ev.Data.(tmtypes.EventDataNewBlockHeader) + data, ok := ev.Data.(tmtypes.EventDataNewBlock) if !ok { api.logger.Debug("event data type mismatch", "type", fmt.Sprintf("%T", ev.Data)) continue } - baseFee := types.BaseFeeFromEvents(data.ResultBeginBlock.Events) + baseFee := types.BaseFeeFromEvents(data.ResultFinalizeBlock.Events) // TODO: fetch bloom from events - header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee) + header := types.EthHeaderFromTendermint(data.Block.Header, ethtypes.Bloom{}, baseFee) _ = notifier.Notify(rpcSub.ID, header) case <-rpcSub.Err(): headersSub.Unsubscribe(api.events) @@ -402,7 +402,7 @@ func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteri return } - logs := FilterLogs(support.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics) + logs := FilterLogs(evmtypes.LogsToEthereum(txResponse.Logs), crit.FromBlock, crit.ToBlock, crit.Addresses, crit.Topics) for _, log := range logs { _ = notifier.Notify(rpcSub.ID, log) @@ -485,7 +485,7 @@ func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, return } - logs := FilterLogs(support.LogsToEthereum(txResponse.Logs), criteria.FromBlock, criteria.ToBlock, criteria.Addresses, criteria.Topics) + logs := FilterLogs(evmtypes.LogsToEthereum(txResponse.Logs), criteria.FromBlock, criteria.ToBlock, criteria.Addresses, criteria.Topics) api.filtersMu.Lock() if f, found := api.filters[filterID]; found { diff --git a/ethereum/rpc/tx.go b/ethereum/rpc/tx.go index cac9aae..6dab1cb 100644 --- a/ethereum/rpc/tx.go +++ b/ethereum/rpc/tx.go @@ -212,7 +212,7 @@ func (b *BackendImpl) GetTxByEthHash(hash common.Hash) (*types.TxResult, error) // fallback to tendermint tx indexer query := fmt.Sprintf("%s.%s='%s'", evmtypes.TypeMsgEthereumTx, evmtypes.AttributeKeyEthereumTxHash, hash.Hex()) txResult, err := b.queryCosmosTxIndexer(query, func(txs *rpctypes.ParsedTxs) *rpctypes.ParsedTx { - return evmtypes.GetTxByHash(hash) + return txs.GetTxByHash(hash) }) if err != nil { return nil, fmt.Errorf("GetTxByEthHash %s, %w", hash.Hex(), err) @@ -329,10 +329,10 @@ func (b *BackendImpl) queryCosmosTxIndexer(query string, txGetter func(*rpctypes if err != nil { return nil, err } - if len(resevmtypes.Txs) == 0 { + if len(resTxs.Txs) == 0 { return nil, errors.New("ethereum tx not found") } - txResult := resevmtypes.Txs[0] + txResult := resTxs.Txs[0] if !rpctypes.TxSuccessOrExceedsBlockGasLimit(&txResult.TxResult) { return nil, errors.New("invalid ethereum tx") } diff --git a/go.mod b/go.mod index 9c10a2c..72b712c 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,6 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 cosmossdk.io/tools/confix v0.1.1 - cosmossdk.io/tools/rosetta v0.2.1 cosmossdk.io/x/circuit v0.1.0 cosmossdk.io/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 @@ -40,7 +39,6 @@ require ( github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/bufbuild/buf v1.30.0 github.com/cometbft/cometbft v0.38.7 - github.com/cometbft/cometbft-db v0.9.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.50.6 @@ -59,7 +57,6 @@ require ( github.com/holiman/uint256 v1.2.2 github.com/json-iterator/go v1.1.12 github.com/pkg/errors v0.9.1 - github.com/rollkit/cosmos-sdk-starter v0.0.0-20240711025550-2ec636be897c github.com/rollkit/rollkit v0.13.6 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.1 @@ -71,6 +68,7 @@ require ( github.com/tidwall/sjson v1.2.5 github.com/tyler-smith/go-bip39 v1.1.0 golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + golang.org/x/sync v0.7.0 golang.org/x/text v0.16.0 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 @@ -122,7 +120,7 @@ require ( github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect - github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect + github.com/cometbft/cometbft-db v0.9.1 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect @@ -132,7 +130,6 @@ require ( github.com/cosmos/iavl v1.1.2 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect @@ -381,7 +378,6 @@ require ( golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index 0ed7918..5e34d2e 100644 --- a/go.sum +++ b/go.sum @@ -221,8 +221,6 @@ cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8= cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ= -cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= -cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= @@ -477,8 +475,6 @@ github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b/go.mod h1:TkdVs github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= github.com/cometbft/cometbft v0.38.7 h1:ULhIOJ9+LgSy6nLekhq9ae3juX3NnQUMMPyVdhZV6Hk= github.com/cometbft/cometbft v0.38.7/go.mod h1:HIyf811dFMI73IE0F7RrnY/Fr+d1+HuJAgtkEpQjCMY= github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= @@ -533,8 +529,6 @@ github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZD github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= -github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -1895,8 +1889,6 @@ github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4 github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/rollkit/cosmos-sdk-starter v0.0.0-20240711025550-2ec636be897c h1:3xEE0If9YPRpBTLrSwrsQknVgzKXBzCGQg6+1BdBrp0= -github.com/rollkit/cosmos-sdk-starter v0.0.0-20240711025550-2ec636be897c/go.mod h1:TbhhDFoyHzKouPMcFQ1uzzffsCZ6ohMhVvBWM+/2K5U= github.com/rollkit/go-da v0.5.0 h1:sQpZricNS+2TLx3HMjNWhtRfqtvVC/U4pWHpfUz3eN4= github.com/rollkit/go-da v0.5.0/go.mod h1:VsUeAoPvKl4Y8wWguu/VibscYiFFePkkrvZWyTjZHww= github.com/rollkit/rollkit v0.13.6 h1:ZdIBG5D5RuQvnnJSY8s3m46dR3A3F6jHN+01zX+Avt0=