diff --git a/.golangci.yml b/.golangci.yml index e26302f8..d3b603f4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,84 +1,80 @@ -# Refer to golangci-lint's example config file for more options and information: -# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml - run: - timeout: 20m - tests: true - # default is true. Enables skipping of directories: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true - skip-files: - - core/genesis_alloc.go - modules-download-mode: readonly - + tests: false + timeout: 5m - linters: - disable-all: true - enable: - - depguard - - dogsled - - exportloopref - - goconst - - gocritic - - gofumpt - - gosec - - gosimple - - govet - - ineffassign - - misspell - - nakedret - - nolintlint - - staticcheck - - stylecheck - - typecheck - - unconvert - - unused +linters: + enable: + - bodyclose + - dogsled + - dupl + - errcheck + - goconst + - gocritic + - revive + - gosec + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - prealloc + - exportloopref + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - nolintlint + - asciicheck + - exportloopref + - whitespace + # - gomodguard # TODO: disable for now, too many false positives + # - gofumpt # TODO: rules too strict fix all the errors later + # - depguard # TODO: enable depguard later, it reports too many false positives + # - lll # TODO: enable lll linter later, long text sometimes is not avoidable - issues: - exclude-rules: - - text: "Use of weak random number generator" - linters: - - gosec - - text: "ST1003:" - linters: - - stylecheck - # FIXME: Disabled until golangci-lint updates stylecheck with this fix: - # https://github.com/dominikh/go-tools/issues/389 - - text: "ST1016:" - linters: - - stylecheck - - path: "migrations" - text: "SA1019:" - linters: - - staticcheck - - path: crypto/bn256/cloudflare/optate.go - linters: - - deadcode - - staticcheck - - path: internal/build/pgp.go - text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated: this package is unmaintained except for security fixes.' - - path: core/vm/contracts.go - text: 'SA1019: "golang.org/x/crypto/ripemd160" is deprecated: RIPEMD-160 is a legacy hash and should not be used for new applications.' - - path: accounts/usbwallet/trezor.go - text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.' - - path: accounts/usbwallet/trezor/ - text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.' - exclude: - - 'SA1019: event.TypeMux is deprecated: use Feed' - - 'SA1019: strings.Title is deprecated' - - 'SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.' - - 'SA1029: should not use built-in type string as key for value' - max-issues-per-linter: 10000 - max-same-issues: 10000 +issues: + exclude-rules: + - path: _test\.go + linters: + - gosec + - path: x/evm/artela/contract/handlers.go + linters: + - nakedret + - path: _pb\.go + linters: + - gosec + - linters: + - lll + source: "https://" + max-same-issues: 50 - linters-settings: - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - nolintlint: - allow-unused: false - allow-leading-space: true - require-explanation: false - require-specific: false \ No newline at end of file +linters-settings: + lll: + line-length: 150 + dogsled: + max-blank-identifiers: 3 + golint: + min-confidence: 0 + maligned: + suggest-new: true + gocritic: + disabled-checks: + - ifElseChain + misspell: + locale: US + nolintlint: + allow-unused: false + allow-leading-space: true + require-explanation: false + require-specific: false +# gomodguard: +# blocked: +# versions: # List of blocked module version constraints +# - https://github.com/etcd-io/etcd: # Blocked module with version constraint +# version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons +# reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional) +# - https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint +# version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons +# reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional) \ No newline at end of file diff --git a/app/ante/cosmos/fee_checker.go b/app/ante/cosmos/fee_checker.go index e8c5cc2d..0dac711d 100644 --- a/app/ante/cosmos/fee_checker.go +++ b/app/ante/cosmos/fee_checker.go @@ -144,7 +144,8 @@ func (dfd DeductFeeDecorator) deductFee(ctx cosmos.Context, sdkTx cosmos.Tx, fee // deductFeesFromBalanceOrUnclaimedStakingRewards tries to deduct the fees from the account balance. // If the account balance is not enough, it tries to claim enough staking rewards to cover the fees. -// nolint:unused +// +//nolint:unused func deductFeesFromBalanceOrUnclaimedStakingRewards( ctx cosmos.Context, dfd DeductFeeDecorator, deductFeesFromAcc authtypes.AccountI, fees cosmos.Coins, ) error { diff --git a/app/ante/cosmos/msg_checker.go b/app/ante/cosmos/msg_checker.go index 4b6f9520..23f12bfa 100644 --- a/app/ante/cosmos/msg_checker.go +++ b/app/ante/cosmos/msg_checker.go @@ -2,9 +2,10 @@ package cosmos import ( errorsmod "cosmossdk.io/errors" - evmmodule "github.com/artela-network/artela/x/evm/txs" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + + evmmodule "github.com/artela-network/artela/x/evm/txs" ) // RejectMessagesDecorator prevents invalid msg types from being executed diff --git a/app/ante/cosmos/sig_checker.go b/app/ante/cosmos/sig_checker.go index f20658e6..cb13d0ed 100644 --- a/app/ante/cosmos/sig_checker.go +++ b/app/ante/cosmos/sig_checker.go @@ -3,8 +3,6 @@ package cosmos import ( "fmt" - artela "github.com/artela-network/artela/ethereum/types" - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" @@ -22,7 +20,7 @@ import ( "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" "github.com/artela-network/artela/ethereum/eip712" - + artela "github.com/artela-network/artela/ethereum/types" evmmodule "github.com/artela-network/artela/x/evm/types" ) diff --git a/app/ante/decorator.go b/app/ante/decorator.go index 90e4be02..0935ce89 100644 --- a/app/ante/decorator.go +++ b/app/ante/decorator.go @@ -1,10 +1,8 @@ package ante import ( - "github.com/artela-network/artela/x/evm/txs" - "github.com/cosmos/cosmos-sdk/baseapp" - errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" @@ -12,18 +10,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/ante" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authmodule "github.com/cosmos/cosmos-sdk/x/auth/types" + sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - anteutils "github.com/artela-network/artela/app/ante/utils" - "github.com/artela-network/artela/app/interfaces" - cosmosante "github.com/artela-network/artela/app/ante/cosmos" evmante "github.com/artela-network/artela/app/ante/evm" + anteutils "github.com/artela-network/artela/app/ante/utils" + "github.com/artela-network/artela/app/interfaces" + "github.com/artela-network/artela/x/evm/txs" evmmodule "github.com/artela-network/artela/x/evm/types" - // vestingtypes "github.com/artela-network/artela/x/vesting/types" - sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" ) // AnteDecorators defines the list of module keepers required to run the Artela @@ -155,7 +152,7 @@ func newLegacyCosmosAnteHandlerEip712(options AnteDecorators) cosmos.AnteHandler ante.NewValidateSigCountDecorator(options.AccountKeeper), ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), // Note: signature verification uses EIP instead of the cosmos signature validator - // nolint: staticcheck + //nolint: staticcheck cosmosante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), ante.NewIncrementSequenceDecorator(options.AccountKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), diff --git a/app/ante/evm/aspect_context.go b/app/ante/evm/aspect_context.go index cd6ce872..3b65f428 100644 --- a/app/ante/evm/aspect_context.go +++ b/app/ante/evm/aspect_context.go @@ -1,19 +1,21 @@ package evm import ( - errorsmod "cosmossdk.io/errors" "fmt" - "github.com/artela-network/artela/x/evm/artela/provider" - "github.com/artela-network/artela/x/evm/states" - inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/baseapp" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" "github.com/artela-network/artela/app/interfaces" + "github.com/artela-network/artela/x/evm/artela/provider" "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/states" "github.com/artela-network/artela/x/evm/txs" + inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" ) // CreateAspectRuntimeContextDecorator prepare the aspect runtime context diff --git a/app/ante/evm/basic_checker.go b/app/ante/evm/basic_checker.go index 888e083e..2729c3c7 100644 --- a/app/ante/evm/basic_checker.go +++ b/app/ante/evm/basic_checker.go @@ -6,19 +6,18 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - "github.com/artela-network/artela/app/interfaces" - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/txs/support" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" anteutils "github.com/artela-network/artela/app/ante/utils" + "github.com/artela-network/artela/app/interfaces" + artela "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/x/evm/keeper" "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/txs/support" evmmodule "github.com/artela-network/artela/x/evm/types" - - "github.com/ethereum/go-ethereum/common" ) // EthAccountVerificationDecorator validates an account balance checks @@ -149,7 +148,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx, evmParams := egcd.evmKeeper.GetParams(ctx) evmDenom := evmParams.GetEvmDenom() chainCfg := evmParams.GetChainConfig() - ethCfg := chainCfg.EthereumConfig(egcd.evmKeeper.ChainID()) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), egcd.evmKeeper.ChainID()) blockHeight := big.NewInt(ctx.BlockHeight()) homestead := ethCfg.IsHomestead(blockHeight) @@ -265,7 +264,7 @@ func NewCanTransferDecorator(evmKeeper interfaces.EVMKeeper) CanTransferDecorato // see if the address can execute the transaction. func (ctd CanTransferDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx, simulate bool, next cosmos.AnteHandler) (cosmos.Context, error) { params := ctd.evmKeeper.GetParams(ctx) - ethCfg := params.ChainConfig.EthereumConfig(ctd.evmKeeper.ChainID()) + ethCfg := params.ChainConfig.EthereumConfig(ctx.BlockHeight(), ctd.evmKeeper.ChainID()) for _, msg := range tx.GetMsgs() { msgEthTx, ok := msg.(*txs.MsgEthereumTx) diff --git a/app/ante/evm/context_checker.go b/app/ante/evm/context_checker.go index bf762299..ab2e8292 100644 --- a/app/ante/evm/context_checker.go +++ b/app/ante/evm/context_checker.go @@ -4,8 +4,6 @@ import ( "errors" "strconv" - "github.com/artela-network/artela/x/evm/txs" - errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -15,6 +13,7 @@ import ( ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/artela-network/artela/app/interfaces" + "github.com/artela-network/artela/x/evm/txs" evmmodule "github.com/artela-network/artela/x/evm/types" ) @@ -145,7 +144,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx evmParams := vbd.evmKeeper.GetParams(ctx) chainCfg := evmParams.GetChainConfig() chainID := vbd.evmKeeper.ChainID() - ethCfg := chainCfg.EthereumConfig(chainID) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), chainID) baseFee := vbd.evmKeeper.GetBaseFee(ctx, ethCfg) enableCreate := evmParams.GetEnableCreate() enableCall := evmParams.GetEnableCall() diff --git a/app/ante/evm/fee_checker.go b/app/ante/evm/fee_checker.go index ec809e46..0507b3c3 100644 --- a/app/ante/evm/fee_checker.go +++ b/app/ante/evm/fee_checker.go @@ -3,18 +3,16 @@ package evm import ( "math" - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/txs" - errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" - cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" anteutils "github.com/artela-network/artela/app/ante/utils" "github.com/artela-network/artela/app/interfaces" + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/txs" ) // NewDynamicFeeChecker returns a `TxFeeChecker` that applies a dynamic fee to @@ -34,7 +32,7 @@ func NewDynamicFeeChecker(k interfaces.DynamicFeeEVMKeeper) anteutils.TxFeeCheck params := k.GetParams(ctx) denom := params.EvmDenom - ethCfg := params.ChainConfig.EthereumConfig(k.ChainID()) + ethCfg := params.ChainConfig.EthereumConfig(ctx.BlockHeight(), k.ChainID()) baseFee := k.GetBaseFee(ctx, ethCfg) if baseFee == nil { diff --git a/app/ante/evm/gasprice_checker.go b/app/ante/evm/gasprice_checker.go index 33e652fe..95fd2f6b 100644 --- a/app/ante/evm/gasprice_checker.go +++ b/app/ante/evm/gasprice_checker.go @@ -58,7 +58,7 @@ func (empd EthMinGasPriceDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx, evmParams := empd.evmKeeper.GetParams(ctx) chainCfg := evmParams.GetChainConfig() - ethCfg := chainCfg.EthereumConfig(empd.evmKeeper.ChainID()) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), empd.evmKeeper.ChainID()) baseFee := empd.evmKeeper.GetBaseFee(ctx, ethCfg) for _, msg := range tx.GetMsgs() { @@ -117,7 +117,7 @@ func (mfd EthMempoolFeeDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx, s } evmParams := mfd.evmKeeper.GetParams(ctx) chainCfg := evmParams.GetChainConfig() - ethCfg := chainCfg.EthereumConfig(mfd.evmKeeper.ChainID()) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), mfd.evmKeeper.ChainID()) baseFee := mfd.evmKeeper.GetBaseFee(ctx, ethCfg) // skip check as the London hard fork and EIP-1559 are enabled diff --git a/app/ante/evm/gaswanted_checker.go b/app/ante/evm/gaswanted_checker.go index d20d9a17..d9a1a7d5 100644 --- a/app/ante/evm/gaswanted_checker.go +++ b/app/ante/evm/gaswanted_checker.go @@ -3,12 +3,12 @@ package evm import ( "math/big" - "github.com/artela-network/artela/app/interfaces" - "github.com/artela-network/artela/ethereum/types" - errorsmod "cosmossdk.io/errors" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/artela-network/artela/app/interfaces" + "github.com/artela-network/artela/ethereum/types" ) // GasWantedDecorator keeps track of the gasWanted amount on the current block in transient store @@ -33,7 +33,7 @@ func NewGasWantedDecorator( func (gwd GasWantedDecorator) AnteHandle(ctx cosmos.Context, tx cosmos.Tx, simulate bool, next cosmos.AnteHandler) (newCtx cosmos.Context, err error) { evmParams := gwd.evmKeeper.GetParams(ctx) chainCfg := evmParams.GetChainConfig() - ethCfg := chainCfg.EthereumConfig(gwd.evmKeeper.ChainID()) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), gwd.evmKeeper.ChainID()) blockHeight := big.NewInt(ctx.BlockHeight()) isLondon := ethCfg.IsLondon(blockHeight) diff --git a/app/ante/evm/sig_checker.go b/app/ante/evm/sig_checker.go index afdfc3c8..fc6a1102 100644 --- a/app/ante/evm/sig_checker.go +++ b/app/ante/evm/sig_checker.go @@ -1,13 +1,13 @@ package evm import ( - "github.com/artela-network/artela/app/interfaces" - "github.com/artela-network/artela/x/evm/txs" - "github.com/cosmos/cosmos-sdk/baseapp" - errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/baseapp" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/artela-network/artela/app/interfaces" + "github.com/artela-network/artela/x/evm/txs" ) // EthSigVerificationDecorator validates an ethereum signatures diff --git a/app/ante/validator.go b/app/ante/validator.go index 0d432e84..505c7e5e 100644 --- a/app/ante/validator.go +++ b/app/ante/validator.go @@ -36,7 +36,6 @@ func SigVerificationGasConsumer( ) error { pubkey := sig.PubKey switch pubkey := pubkey.(type) { - case *ethsecp256k1.PubKey: // Ethereum keys meter.ConsumeGas(Secp256k1VerifyCost, "ante verify: eth_secp256k1") diff --git a/app/app.go b/app/app.go index 2794469d..c0cc78c2 100644 --- a/app/app.go +++ b/app/app.go @@ -112,6 +112,7 @@ import ( "github.com/spf13/cast" "github.com/artela-network/artela/app/upgrades/v047rc7" + "github.com/artela-network/artela/app/upgrades/v048rc8" evmmodule "github.com/artela-network/artela/x/evm" evmmodulekeeper "github.com/artela-network/artela/x/evm/keeper" evmmoduletypes "github.com/artela-network/artela/x/evm/types" @@ -121,15 +122,18 @@ import ( // this line is used by starport scaffolding # stargate/app/moduleImport - aspecttypes "github.com/artela-network/aspect-core/types" - "github.com/artela-network/artela/app/ante" ethante "github.com/artela-network/artela/app/ante/evm" appparams "github.com/artela-network/artela/app/params" "github.com/artela-network/artela/app/post" + "github.com/artela-network/artela/common" "github.com/artela-network/artela/docs" srvflags "github.com/artela-network/artela/ethereum/server/flags" artela "github.com/artela-network/artela/ethereum/types" + aspecttypes "github.com/artela-network/aspect-core/types" + + // do not remove this, this will register the native evm tracers + _ "github.com/artela-network/artela-evm/tracers/native" ) const ( @@ -222,7 +226,6 @@ func init() { // manually update the power reduction cosmos.DefaultPowerReduction = artela.PowerReduction - } // Artela extends an ABCI application, but with most of its parameters exported. @@ -356,7 +359,7 @@ func NewArtela( ) // set the runner cache capacity of aspect-runtime - aspecttypes.InitRuntimePool(context.Background(), app.Logger(), cast.ToInt32(appOpts.Get(srvflags.ApplyPoolSize)), cast.ToInt32(appOpts.Get(srvflags.QueryPoolSize))) + aspecttypes.InitRuntimePool(context.Background(), common.WrapLogger(app.Logger()), cast.ToInt32(appOpts.Get(srvflags.ApplyPoolSize)), cast.ToInt32(appOpts.Get(srvflags.QueryPoolSize))) // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) @@ -996,7 +999,7 @@ func (app *Artela) ModuleManager() *module.Manager { } func (app *Artela) setupUpgradeHandlers() { - // v16 upgrade handler + // v0.4.7-rc7 upgrade handler app.UpgradeKeeper.SetUpgradeHandler( v047rc7.UpgradeName, v047rc7.CreateUpgradeHandler( @@ -1004,6 +1007,14 @@ func (app *Artela) setupUpgradeHandlers() { ), ) + // v0.4.8-rc8 upgrade handler + app.UpgradeKeeper.SetUpgradeHandler( + v048rc8.UpgradeName, + v048rc8.CreateUpgradeHandler( + app.mm, app.configurator, + ), + ) + // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it // This will read that value, and execute the preparations for the upgrade. @@ -1021,6 +1032,8 @@ func (app *Artela) setupUpgradeHandlers() { switch upgradeInfo.Name { case v047rc7.UpgradeName: // no store upgrades + case v048rc8.UpgradeName: + // no store upgrades in v048rc8 default: // no-op } diff --git a/app/codec.go b/app/codec.go index bb52751f..16c7294b 100644 --- a/app/codec.go +++ b/app/codec.go @@ -1,12 +1,13 @@ package app import ( - codec2 "github.com/artela-network/artela/ethereum/crypto/codec" - "github.com/artela-network/artela/ethereum/types" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" + + codec2 "github.com/artela-network/artela/ethereum/crypto/codec" + "github.com/artela-network/artela/ethereum/types" ) // RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. diff --git a/app/interfaces/interfaces.go b/app/interfaces/interfaces.go index ca15bda1..4c5e6400 100644 --- a/app/interfaces/interfaces.go +++ b/app/interfaces/interfaces.go @@ -3,25 +3,22 @@ package interfaces import ( "math/big" - artvmtype "github.com/artela-network/artela/x/evm/artela/types" - - ethereum "github.com/ethereum/go-ethereum/core/types" - - "github.com/artela-network/artela/x/evm/states" - "github.com/artela-network/artela-evm/vm" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + artvmtype "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/states" evmtypes "github.com/artela-network/artela/x/evm/txs/support" feemodule "github.com/artela-network/artela/x/fee/types" ) // EVMKeeper defines the expected keeper interface used on the AnteHandler -type EVMKeeper interface { // nolint: revive +type EVMKeeper interface { states.Keeper DynamicFeeEVMKeeper diff --git a/app/post/decorator.go b/app/post/decorator.go index 44e1e916..bb382393 100644 --- a/app/post/decorator.go +++ b/app/post/decorator.go @@ -3,9 +3,9 @@ package post import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/baseapp" + cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - cosmos "github.com/cosmos/cosmos-sdk/types" // vestingtypes "github.com/artela-network/artela/x/vesting/types" "github.com/artela-network/artela/app/interfaces" evmpost "github.com/artela-network/artela/app/post/evm" diff --git a/app/post/evm/aspect_context.go b/app/post/evm/aspect_context.go index 82b635ac..9ed6efa2 100644 --- a/app/post/evm/aspect_context.go +++ b/app/post/evm/aspect_context.go @@ -25,7 +25,7 @@ func NewAspectRuntimeContextDecorator(app *baseapp.BaseApp, ek interfaces.EVMKee } func (aspd AspectRuntimeContextDecorator) PostHandle(ctx cosmos.Context, tx cosmos.Tx, simulate, success bool, next cosmos.PostHandler) (newCtx cosmos.Context, err error) { - // Aspect Runtime Context Lifecycle: destory AspectRuntimeContext + // Aspect Runtime Context Lifecycle: destroy AspectRuntimeContext aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) if !ok { return ctx, errors.New("EthereumTx: unwrap AspectRuntimeContext failed") diff --git a/app/upgrades/v047rc7/upgrades.go b/app/upgrades/v047rc7/upgrades.go index fa2b6ddf..ff00772d 100644 --- a/app/upgrades/v047rc7/upgrades.go +++ b/app/upgrades/v047rc7/upgrades.go @@ -9,7 +9,7 @@ import ( ) // CreateUpgradeHandler creates an SDK upgrade handler for v17.0.0 -func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, keeper bankkeeper.Keeper, accountKeeper authkeeper.AccountKeeper) upgradetypes.UpgradeHandler { +func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, _ bankkeeper.Keeper, _ authkeeper.AccountKeeper) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", UpgradeName) diff --git a/app/upgrades/v048rc8/constants.go b/app/upgrades/v048rc8/constants.go new file mode 100644 index 00000000..701b5b60 --- /dev/null +++ b/app/upgrades/v048rc8/constants.go @@ -0,0 +1,5 @@ +package v048rc8 + +const ( + UpgradeName = "v048rc8" +) diff --git a/app/upgrades/v048rc8/upgrades.go b/app/upgrades/v048rc8/upgrades.go new file mode 100644 index 00000000..bd827397 --- /dev/null +++ b/app/upgrades/v048rc8/upgrades.go @@ -0,0 +1,18 @@ +package v048rc8 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// CreateUpgradeHandler creates an SDK upgrade handler for v17.0.0 +func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + logger := ctx.Logger().With("upgrade", UpgradeName) + + // Leave modules are as-is to avoid running InitGenesis. + logger.Debug("v048rc8 running module migrations ...") + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/client/config.go b/client/config.go index 22bd7c70..b2bf352b 100644 --- a/client/config.go +++ b/client/config.go @@ -5,14 +5,13 @@ import ( "os" "path" - "github.com/artela-network/artela/ethereum/types" - "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/cometbft/cometbft/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/artela-network/artela/ethereum/types" ) // InitConfig adds the chain-id, encoding and output flags to the persistent flag set. diff --git a/client/debug/debug.go b/client/debug/debug.go index 00bc51d8..0bd4973a 100644 --- a/client/debug/debug.go +++ b/client/debug/debug.go @@ -1,32 +1,34 @@ package debug import ( + "encoding/base64" "encoding/hex" "encoding/json" "fmt" + "log" "strconv" "strings" - artela "github.com/artela-network/artela/ethereum/types" - - authclient "github.com/cosmos/cosmos-sdk/x/auth/client" "github.com/pkg/errors" - - "github.com/artela-network/artela/ethereum/eip712" - - "github.com/cometbft/cometbft/libs/bytes" "github.com/spf13/cobra" - "github.com/ethereum/go-ethereum/common" - + "github.com/cometbft/cometbft/libs/bytes" + cometbftTypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/ethereum/go-ethereum/common" + + appparams "github.com/artela-network/artela/app/params" + "github.com/artela-network/artela/ethereum/eip712" + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/txs" ) // Cmd creates a main CLI command -func Cmd() *cobra.Command { +func Cmd(encodingConfig appparams.EncodingConfig) *cobra.Command { cmd := &cobra.Command{ Use: "debug", Short: "Tool for helping with debugging your application", @@ -37,6 +39,7 @@ func Cmd() *cobra.Command { cmd.AddCommand(AddrCmd()) cmd.AddCommand(RawBytesCmd()) cmd.AddCommand(LegacyEIP712Cmd()) + cmd.AddCommand(CosmosTxHash(encodingConfig)) return cmd } @@ -54,7 +57,7 @@ func PubkeyCmd() *cobra.Command { Short: "Decode a pubkey from proto JSON", Long: "Decode a pubkey from proto JSON and display it's address", Example: fmt.Sprintf( - `"$ %s debug pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}'`, //nolint:gitleaks + `"$ %s debug pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}'`, version.AppName, ), Args: cobra.ExactArgs(1), @@ -178,3 +181,45 @@ func LegacyEIP712Cmd() *cobra.Command { }, } } + +func CosmosTxHash(encodingConfig appparams.EncodingConfig) *cobra.Command { + return &cobra.Command{ + Use: "tx [base64 encoded tx]", + Short: "Get the ethereum tx of cosmos tx", + Example: "", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + txBytes, err := base64.StdEncoding.DecodeString(args[0]) + if err != nil { + log.Fatalf("Failed to decode base64: %v", err) + } + + cometbftTx := cometbftTypes.Tx(txBytes) + + tx, err := encodingConfig.TxConfig.TxDecoder()(cometbftTx) + if err != nil { + fmt.Println(err) + } + + for i, msg := range tx.GetMsgs() { + ethMsg, ok := msg.(*txs.MsgEthereumTx) + if !ok { + fmt.Printf("message %d is not etherum tx\n", i) + continue + } + + fmt.Println("this is a ethereum tx:") + ethMsg.Hash = ethMsg.AsTransaction().Hash().Hex() + // result = append(result, ethMsg) + ethTx := ethMsg.AsTransaction() + fmt.Printf(" hash: %s\n to: %s\n value: %s\n data: %s\n", + ethTx.Hash().String(), + ethTx.To().String(), + ethTx.Value().String(), + common.Bytes2Hex(ethTx.Data()), + ) + } + return nil + }, + } +} diff --git a/client/export.go b/client/export.go index 4273e1a4..dd3e890e 100644 --- a/client/export.go +++ b/client/export.go @@ -5,17 +5,17 @@ import ( "fmt" "strings" - ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela/ethereum/crypto/hd" + "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/ethereum/go-ethereum/common/hexutil" ethcrypto "github.com/ethereum/go-ethereum/crypto" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/crypto/keyring" + ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela/ethereum/crypto/hd" ) // UnsafeExportEthKeyCommand exports a key with the given name as a private key in hex format. diff --git a/client/import.go b/client/import.go index 8b092c90..13b9f37e 100644 --- a/client/import.go +++ b/client/import.go @@ -3,15 +3,15 @@ package client import ( "bufio" - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela/ethereum/crypto/hd" - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto" "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela/ethereum/crypto/hd" ) // UnsafeImportKeyCommand imports private keys from a keyfile. diff --git a/client/keys.go b/client/keys.go index c987830d..d289d0a5 100644 --- a/client/keys.go +++ b/client/keys.go @@ -3,18 +3,17 @@ package client import ( "bufio" - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela/ethereum/crypto/hd" + "github.com/spf13/cobra" "github.com/cometbft/cometbft/libs/cli" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/crypto/keyring" clientkeys "github.com/artela-network/artela/client/keys" + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela/ethereum/crypto/hd" ) // KeyCommands registers a sub-tree of commands to interact with diff --git a/client/keys/add.go b/client/keys/add.go index f61cd6a0..70848cb5 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -7,10 +7,6 @@ import ( "fmt" "sort" - "github.com/artela-network/artela/ethereum/crypto/codec" - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - cryptohd "github.com/artela-network/artela/ethereum/crypto/hd" - "github.com/cosmos/go-bip39" "github.com/spf13/cobra" @@ -23,6 +19,10 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/artela-network/artela/ethereum/crypto/codec" + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + cryptohd "github.com/artela-network/artela/ethereum/crypto/hd" ) const ( diff --git a/client/keys/utils.go b/client/keys/utils.go index 7e409594..eee8e4c8 100644 --- a/client/keys/utils.go +++ b/client/keys/utils.go @@ -4,11 +4,11 @@ import ( "fmt" "io" - "github.com/artela-network/artela/ethereum/crypto/codec" - "sigs.k8s.io/yaml" cryptokeyring "github.com/cosmos/cosmos-sdk/crypto/keyring" + + "github.com/artela-network/artela/ethereum/crypto/codec" ) // available output formats. diff --git a/client/testnet.go b/client/testnet.go index bf326fe3..8798ed6a 100644 --- a/client/testnet.go +++ b/client/testnet.go @@ -10,22 +10,12 @@ import ( "os" "path/filepath" - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela/ethereum/crypto/hd" - "github.com/artela-network/artela/ethereum/server/config" - srvflags "github.com/artela-network/artela/ethereum/server/flags" - types2 "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/txs/support" - - "github.com/ethereum/go-ethereum/common" + "github.com/spf13/cobra" tmconfig "github.com/cometbft/cometbft/config" tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -45,8 +35,16 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" mintypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela/ethereum/crypto/hd" + "github.com/artela-network/artela/ethereum/server/config" + srvflags "github.com/artela-network/artela/ethereum/server/flags" + types2 "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/testutil/network" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/txs/support" evmtypes "github.com/artela-network/artela/x/evm/types" ) @@ -414,7 +412,7 @@ func initGenFiles( var govGenState govv1.GenesisState clientCtx.Codec.MustUnmarshalJSON(appGenState[govtypes.ModuleName], &govGenState) - // nolint:staticcheck + //nolint:staticcheck govGenState.DepositParams.MinDeposit[0].Denom = coinDenom appGenState[govtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&govGenState) diff --git a/cmd/artelad/cmd/genaccounts.go b/cmd/artelad/cmd/genaccounts.go index e5b38bb5..ba1103be 100644 --- a/cmd/artelad/cmd/genaccounts.go +++ b/cmd/artelad/cmd/genaccounts.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/artela-network/artela/ethereum/crypto/hd" + "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -18,7 +18,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/spf13/cobra" + + "github.com/artela-network/artela/ethereum/crypto/hd" ) const ( diff --git a/cmd/artelad/cmd/gencontract.go b/cmd/artelad/cmd/gencontract.go index 66d59c4f..9c05e584 100644 --- a/cmd/artelad/cmd/gencontract.go +++ b/cmd/artelad/cmd/gencontract.go @@ -7,14 +7,8 @@ import ( "fmt" "os" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/cobra" - ethtypes "github.com/artela-network/artela/ethereum/types" - evmstate "github.com/artela-network/artela/x/evm/txs/support" - evmtypes "github.com/artela-network/artela/x/evm/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -23,6 +17,12 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" + + ethtypes "github.com/artela-network/artela/ethereum/types" + evmstate "github.com/artela-network/artela/x/evm/txs/support" + evmtypes "github.com/artela-network/artela/x/evm/types" ) // AddGenesisContractCmd returns add-genesis-contract cobra Command. diff --git a/cmd/artelad/cmd/keyinfo.go b/cmd/artelad/cmd/keyinfo.go index dc7d8601..c8923f54 100644 --- a/cmd/artelad/cmd/keyinfo.go +++ b/cmd/artelad/cmd/keyinfo.go @@ -8,11 +8,12 @@ import ( "fmt" "os" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/version" jose "github.com/dvsekhvalnov/jose2go" "github.com/ethereum/go-ethereum/crypto" - "github.com/spf13/cobra" ) const ( diff --git a/cmd/artelad/cmd/root.go b/cmd/artelad/cmd/root.go index 2b1be096..1e86662d 100644 --- a/cmd/artelad/cmd/root.go +++ b/cmd/artelad/cmd/root.go @@ -7,12 +7,9 @@ import ( "path/filepath" "strings" - artclient "github.com/artela-network/artela/client" - server2 "github.com/artela-network/artela/ethereum/server" - config2 "github.com/artela-network/artela/ethereum/server/config" - - artelakeyring "github.com/artela-network/artela/ethereum/crypto/keyring" - "github.com/artela-network/artela/ethereum/eip712" + "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/spf13/pflag" dbm "github.com/cometbft/cometbft-db" tmcfg "github.com/cometbft/cometbft/config" @@ -38,15 +35,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/spf13/cast" - "github.com/spf13/cobra" - "github.com/spf13/pflag" // this line is used by starport scaffolding # root/moduleImport "github.com/artela-network/artela/app" appparams "github.com/artela-network/artela/app/params" + artclient "github.com/artela-network/artela/client" "github.com/artela-network/artela/client/debug" + artelakeyring "github.com/artela-network/artela/ethereum/crypto/keyring" + "github.com/artela-network/artela/ethereum/eip712" + server2 "github.com/artela-network/artela/ethereum/server" + config2 "github.com/artela-network/artela/ethereum/server/config" ) // NewRootCmd creates a new root command for a Cosmos SDK application @@ -135,7 +134,7 @@ func initRootCmd( AddGenesisContractCmd(app.DefaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), NewTestnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), - debug.Cmd(), + debug.Cmd(encodingConfig), config.Cmd(), // this line is used by starport scaffolding # root/commands KeyInfoCmd(), @@ -312,6 +311,7 @@ func (a appCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server2.FlagIAVLCacheSize))), baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server2.FlagDisableIAVLFastNode))), baseapp.SetChainID(chainID), + baseapp.SetForceCompactInterval(cast.ToInt64(appOpts.Get(server2.FlagForceCompactInterval))), ) } diff --git a/cmd/artelad/cmd/testnet.go b/cmd/artelad/cmd/testnet.go index 2a715c3c..cfa97cc6 100644 --- a/cmd/artelad/cmd/testnet.go +++ b/cmd/artelad/cmd/testnet.go @@ -10,13 +10,12 @@ import ( "os" "path/filepath" + "github.com/spf13/cobra" + tmconfig "github.com/cometbft/cometbft/config" tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" - "github.com/ethereum/go-ethereum/common" - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -35,19 +34,18 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" "github.com/artela-network/artela/ethereum/crypto/hd" + artelakeyring "github.com/artela-network/artela/ethereum/crypto/keyring" "github.com/artela-network/artela/ethereum/server/config" srvflags "github.com/artela-network/artela/ethereum/server/flags" - artelatypes "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/ethereum/utils" + "github.com/artela-network/artela/testutil/network" "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/txs/support" evmtypes "github.com/artela-network/artela/x/evm/types" - - artelakeyring "github.com/artela-network/artela/ethereum/crypto/keyring" - "github.com/artela-network/artela/ethereum/utils" - "github.com/artela-network/artela/testutil/network" ) var ( diff --git a/common/aspect/aspect_abi.go b/common/aspect/aspect_abi.go new file mode 100644 index 00000000..68c6b2c7 --- /dev/null +++ b/common/aspect/aspect_abi.go @@ -0,0 +1,169 @@ +package aspect + +import ( + "encoding/hex" + + errorsmod "cosmossdk.io/errors" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/aspect-core/types" +) + +var ( + Uint256, _ = abi.NewType("uint256", "", nil) + Uint64, _ = abi.NewType("uint64", "", nil) + Uint32, _ = abi.NewType("uint32", "", nil) + Uint16, _ = abi.NewType("uint16", "", nil) + Uint8, _ = abi.NewType("uint8", "", nil) + + String, _ = abi.NewType("string", "", nil) + Bool, _ = abi.NewType("bool", "", nil) + Bytes, _ = abi.NewType("bytes", "", nil) + Bytes32, _ = abi.NewType("bytes32", "", nil) + Address, _ = abi.NewType("address", "", nil) + Uint64Arr, _ = abi.NewType("uint64[]", "", nil) + AddressArr, _ = abi.NewType("address[]", "", nil) + Int8, _ = abi.NewType("int8", "", nil) + // Special types for testing + Uint32Arr2, _ = abi.NewType("uint32[2]", "", nil) + Uint64Arr2, _ = abi.NewType("uint64[2]", "", nil) + Uint256Arr, _ = abi.NewType("uint256[]", "", nil) + Uint256Arr2, _ = abi.NewType("uint256[2]", "", nil) + Uint256Arr3, _ = abi.NewType("uint256[3]", "", nil) + Uint256ArrNested, _ = abi.NewType("uint256[2][2]", "", nil) + Uint8ArrNested, _ = abi.NewType("uint8[][2]", "", nil) + Uint8SliceNested, _ = abi.NewType("uint8[][]", "", nil) + KvPair, _ = abi.NewType("tuple", "struct Overloader.F", []abi.ArgumentMarshaling{ + {Name: "key", Type: "bytes"}, + {Name: "value", Type: "bytes"}, + }) + KvPairArr, _ = abi.NewType("tuple[]", "struct Overloader.F", []abi.ArgumentMarshaling{ + {Name: "key", Type: "string"}, + {Name: "value", Type: "bytes"}, + }) + AspectBoundInfoArr, _ = abi.NewType("tuple[]", "struct Overloader.F", []abi.ArgumentMarshaling{ + {Name: "aspectId", Type: "address"}, + {Name: "version", Type: "uint64"}, + {Name: "priority", Type: "int8"}, + }) +) + +var methods = map[string]abi.Method{ + "deploy": abi.NewMethod("deploy", "deploy", abi.Function, "", false, false, []abi.Argument{ + {Name: "code", Type: Bytes, Indexed: false}, + {Name: "initdata", Type: Bytes, Indexed: false}, + {Name: "properties", Type: KvPairArr, Indexed: false}, + {Name: "account", Type: Address, Indexed: false}, + {Name: "proof", Type: Bytes, Indexed: false}, + {Name: "joinPoints", Type: Uint256, Indexed: false}, + }, nil), + "upgrade": abi.NewMethod("upgrade", "upgrade", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + {Name: "code", Type: Bytes, Indexed: false}, + {Name: "properties", Type: KvPairArr, Indexed: false}, + {Name: "joinPoints", Type: Uint256, Indexed: false}, + }, nil), + "bind": abi.NewMethod("bind", "bind", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + {Name: "aspectVersion", Type: Uint256, Indexed: false}, + {Name: "contract", Type: Address, Indexed: false}, + {Name: "priority", Type: Int8, Indexed: false}, + }, nil), + "unbind": abi.NewMethod("unbind", "unbind", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + {Name: "contract", Type: Address, Indexed: false}, + }, nil), + "changeVersion": abi.NewMethod("changeVersion", "changeVersion", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + {Name: "contract", Type: Address, Indexed: false}, + {Name: "version", Type: Uint64, Indexed: false}, + }, nil), + "versionOf": abi.NewMethod("versionOf", "versionOf", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + }, []abi.Argument{ + {Name: "version", Type: Uint64, Indexed: false}, + }), + "aspectsOf": abi.NewMethod("aspectsOf", "aspectsOf", abi.Function, "", false, false, []abi.Argument{ + {Name: "contract", Type: Address, Indexed: false}, + }, []abi.Argument{ + {Name: "aspectBoundInfo", Type: AspectBoundInfoArr, Indexed: false}, + }), + "boundAddressesOf": abi.NewMethod("boundAddressesOf", "boundAddressesOf", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + }, []abi.Argument{ + {Name: "account", Type: AddressArr, Indexed: false}, + }), + "entrypoint": abi.NewMethod("entrypoint", "entrypoint", abi.Function, "", false, false, []abi.Argument{ + {Name: "aspectId", Type: Address, Indexed: false}, + {Name: "optArgs", Type: Bytes, Indexed: false}, + }, []abi.Argument{ + {Name: "resultMap", Type: Bytes, Indexed: false}, + }), +} + +var methodsLookup = AbiMap() + +var AbiMap = func() map[string]string { + abiIndex := make(map[string]string) + for name, expM := range methods { + abiIndex[hex.EncodeToString(expM.ID)] = name + } + return abiIndex +} + +func GetMethodName(callData []byte) (string, error) { + methodID := hex.EncodeToString(callData[:4]) + methodName, ok := methodsLookup[methodID] + if !ok { + return "", errorsmod.Wrapf(errortypes.ErrInvalidRequest, "method with id %s not found", methodID) + } + return methodName, nil +} + +func ParseMethod(callData []byte) (*abi.Method, map[string]interface{}, error) { + methodName, err := GetMethodName(callData) + if err != nil { + return nil, nil, err + } + + method, ok := methods[methodName] + if !ok { + return nil, nil, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "method %s is not valid", methodName) + } + + argsMap := make(map[string]interface{}) + if err := method.Inputs.UnpackIntoMap(argsMap, callData[4:]); err != nil { + return nil, nil, err + } + + return &method, argsMap, nil +} + +func ParseInput(tx []byte) (*abi.Method, map[string]interface{}, error) { + methodId := hex.EncodeToString(tx[:4]) + methodName, exist := AbiMap()[methodId] + if !exist { + return nil, nil, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "method with id %s not found", methodId) + } + method := methods[methodName] + argsMap := make(map[string]interface{}) + inputs := method.Inputs + err := inputs.UnpackIntoMap(argsMap, tx[4:]) + if err != nil { + return nil, nil, err + } + + return &method, argsMap, nil +} + +func IsAspectDeploy(to *common.Address, callData []byte) bool { + if !types.IsAspectContractAddr(to) { + return false + } + + methodName, err := GetMethodName(callData) + return err == nil && methodName == "deploy" +} diff --git a/x/evm/artela/types/aspect_abi_test.go b/common/aspect/aspect_abi_test.go similarity index 83% rename from x/evm/artela/types/aspect_abi_test.go rename to common/aspect/aspect_abi_test.go index 891f7181..cc20c23a 100644 --- a/x/evm/artela/types/aspect_abi_test.go +++ b/common/aspect/aspect_abi_test.go @@ -1,4 +1,4 @@ -package types +package aspect import ( "encoding/hex" @@ -6,15 +6,17 @@ import ( "reflect" "testing" + pq "github.com/emirpasic/gods/queues/priorityqueue" + "github.com/emirpasic/gods/sets/treeset" "github.com/holiman/uint256" jsoniter "github.com/json-iterator/go" - pq "github.com/emirpasic/gods/queues/priorityqueue" - "github.com/emirpasic/gods/sets/treeset" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + + "github.com/artela-network/artela/x/evm/artela/types" ) func TestAbi(t *testing.T) { @@ -102,32 +104,32 @@ func TestPack(t *testing.T) { func TestAspectsOfPack(t *testing.T) { ma := make(map[string]interface{}, 2) - ma[AspectIdMapKey] = "1111" - ma[VersionMapKey] = 0 - ma[PriorityMapKey] = 1 + ma[types.AspectIDMapKey] = "1111" + ma[types.VersionMapKey] = 0 + ma[types.PriorityMapKey] = 1 mb := make(map[string]interface{}, 2) - mb[AspectIdMapKey] = "2222" - mb[VersionMapKey] = 1 - mb[PriorityMapKey] = -10 + mb[types.AspectIDMapKey] = "2222" + mb[types.VersionMapKey] = 1 + mb[types.PriorityMapKey] = -10 mc := make(map[string]interface{}, 2) - mc[AspectIdMapKey] = "3333" - mc[VersionMapKey] = 2 - mc[PriorityMapKey] = 3 + mc[types.AspectIDMapKey] = "3333" + mc[types.VersionMapKey] = 2 + mc[types.PriorityMapKey] = 3 - queue := pq.NewWith(ByMapKeyPriority) // empty - queue.Enqueue(ma) // {a 1} - queue.Enqueue(mb) // {c 3}, {a 1} + queue := pq.NewWith(types.ByMapKeyPriority) // empty + queue.Enqueue(ma) // {a 1} + queue.Enqueue(mb) // {c 3}, {a 1} queue.Enqueue(mc) - outputs := make([]AspectMeta, 0) + outputs := make([]types.AspectMeta, 0) iterator := queue.Iterator() for iterator.Next() { m := iterator.Value().(map[string]interface{}) - e := AspectMeta{ - Id: common.HexToAddress(m[AspectIdMapKey].(string)), - Priority: int64(m[PriorityMapKey].(int)), - Version: uint256.NewInt(m[VersionMapKey].(uint64)), + e := types.AspectMeta{ + Id: common.HexToAddress(m[types.AspectIDMapKey].(string)), + Priority: int64(m[types.PriorityMapKey].(int)), + Version: uint256.NewInt(m[types.VersionMapKey].(uint64)), } outputs = append(outputs, e) } diff --git a/common/logger.go b/common/logger.go new file mode 100644 index 00000000..6d1ea421 --- /dev/null +++ b/common/logger.go @@ -0,0 +1,21 @@ +package common + +import ( + "github.com/cometbft/cometbft/libs/log" + + "github.com/artela-network/aspect-runtime/types" +) + +var _ types.Logger = (*runtimeLoggerWrapper)(nil) + +type runtimeLoggerWrapper struct { + log.Logger +} + +func WrapLogger(logger log.Logger) types.Logger { + return &runtimeLoggerWrapper{logger} +} + +func (r runtimeLoggerWrapper) With(keyvals ...interface{}) types.Logger { + return &runtimeLoggerWrapper{r.Logger.With(keyvals...)} +} diff --git a/docs/docs.go b/docs/docs.go index 2a914712..c8b0a8e9 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -28,7 +28,7 @@ func RegisterOpenAPIService(appName string, rtr *mux.Router) { func handler(title string) http.HandlerFunc { t, _ := httptemplate.ParseFS(template, indexFile) - return func(w http.ResponseWriter, req *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { err := t.Execute(w, struct { Title string URL string diff --git a/ethereum/crypto/codec/amino.go b/ethereum/crypto/codec/amino.go index 4fb6626e..54d813a8 100644 --- a/ethereum/crypto/codec/amino.go +++ b/ethereum/crypto/codec/amino.go @@ -1,11 +1,12 @@ package codec import ( - ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" + + ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" ) var KeysCdc *codec.LegacyAmino diff --git a/ethereum/crypto/codec/codec.go b/ethereum/crypto/codec/codec.go index baf66966..f50ebb9b 100644 --- a/ethereum/crypto/codec/codec.go +++ b/ethereum/crypto/codec/codec.go @@ -1,9 +1,10 @@ package codec import ( - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" ) // RegisterInterfaces register the Artela key concrete types. diff --git a/ethereum/crypto/ethsecp256k1/ethsecp256k1.go b/ethereum/crypto/ethsecp256k1/ethsecp256k1.go index 043b7143..a5ee0232 100644 --- a/ethereum/crypto/ethsecp256k1/ethsecp256k1.go +++ b/ethereum/crypto/ethsecp256k1/ethsecp256k1.go @@ -7,12 +7,13 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela/ethereum/eip712" tmcrypto "github.com/cometbft/cometbft/crypto" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" + + "github.com/artela-network/artela/ethereum/eip712" ) const ( diff --git a/ethereum/crypto/ethsecp256k1/keys.pb.go b/ethereum/crypto/ethsecp256k1/keys.pb.go index f0e6666b..e6551ad4 100644 --- a/ethereum/crypto/ethsecp256k1/keys.pb.go +++ b/ethereum/crypto/ethsecp256k1/keys.pb.go @@ -32,41 +32,41 @@ type PubKey struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` } -func (m *PubKey) Reset() { *m = PubKey{} } +func (pubKey *PubKey) Reset() { *pubKey = PubKey{} } func (*PubKey) ProtoMessage() {} func (*PubKey) Descriptor() ([]byte, []int) { return fileDescriptor_56b55ddbae0a9542, []int{0} } -func (m *PubKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (pubKey *PubKey) XXX_Unmarshal(b []byte) error { + return pubKey.Unmarshal(b) } -func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (pubKey *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PubKey.Marshal(b, m, deterministic) + return xxx_messageInfo_PubKey.Marshal(b, pubKey, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := pubKey.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *PubKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PubKey.Merge(m, src) +func (pubKey *PubKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKey.Merge(pubKey, src) } -func (m *PubKey) XXX_Size() int { - return m.Size() +func (pubKey *PubKey) XXX_Size() int { + return pubKey.Size() } -func (m *PubKey) XXX_DiscardUnknown() { - xxx_messageInfo_PubKey.DiscardUnknown(m) +func (pubKey *PubKey) XXX_DiscardUnknown() { + xxx_messageInfo_PubKey.DiscardUnknown(pubKey) } var xxx_messageInfo_PubKey proto.InternalMessageInfo -func (m *PubKey) GetKey() []byte { - if m != nil { - return m.Key +func (pubKey *PubKey) GetKey() []byte { + if pubKey != nil { + return pubKey.Key } return nil } @@ -78,42 +78,42 @@ type PrivKey struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` } -func (m *PrivKey) Reset() { *m = PrivKey{} } -func (m *PrivKey) String() string { return proto.CompactTextString(m) } -func (*PrivKey) ProtoMessage() {} +func (privKey *PrivKey) Reset() { *privKey = PrivKey{} } +func (privKey *PrivKey) String() string { return proto.CompactTextString(privKey) } +func (*PrivKey) ProtoMessage() {} func (*PrivKey) Descriptor() ([]byte, []int) { return fileDescriptor_56b55ddbae0a9542, []int{1} } -func (m *PrivKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (privKey *PrivKey) XXX_Unmarshal(b []byte) error { + return privKey.Unmarshal(b) } -func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (privKey *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PrivKey.Marshal(b, m, deterministic) + return xxx_messageInfo_PrivKey.Marshal(b, privKey, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := privKey.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *PrivKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PrivKey.Merge(m, src) +func (privKey *PrivKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PrivKey.Merge(privKey, src) } -func (m *PrivKey) XXX_Size() int { - return m.Size() +func (privKey *PrivKey) XXX_Size() int { + return privKey.Size() } -func (m *PrivKey) XXX_DiscardUnknown() { - xxx_messageInfo_PrivKey.DiscardUnknown(m) +func (privKey *PrivKey) XXX_DiscardUnknown() { + xxx_messageInfo_PrivKey.DiscardUnknown(privKey) } var xxx_messageInfo_PrivKey proto.InternalMessageInfo -func (m *PrivKey) GetKey() []byte { - if m != nil { - return m.Key +func (privKey *PrivKey) GetKey() []byte { + if privKey != nil { + return privKey.Key } return nil } @@ -144,60 +144,60 @@ var fileDescriptor_56b55ddbae0a9542 = []byte{ 0x00, 0x00, 0xff, 0xff, 0x8e, 0xb4, 0xc3, 0x6c, 0x02, 0x01, 0x00, 0x00, } -func (m *PubKey) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (pubKey *PubKey) Marshal() (dAtA []byte, err error) { + size := pubKey.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := pubKey.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *PubKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (pubKey *PubKey) MarshalTo(dAtA []byte) (int, error) { + size := pubKey.Size() + return pubKey.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (pubKey *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + if len(pubKey.Key) > 0 { + i -= len(pubKey.Key) + copy(dAtA[i:], pubKey.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(pubKey.Key))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *PrivKey) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (privKey *PrivKey) Marshal() (dAtA []byte, err error) { + size := privKey.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := privKey.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *PrivKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (privKey *PrivKey) MarshalTo(dAtA []byte) (int, error) { + size := privKey.Size() + return privKey.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (privKey *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintKeys(dAtA, i, uint64(len(m.Key))) + if len(privKey.Key) > 0 { + i -= len(privKey.Key) + copy(dAtA[i:], privKey.Key) + i = encodeVarintKeys(dAtA, i, uint64(len(privKey.Key))) i-- dAtA[i] = 0xa } @@ -215,26 +215,26 @@ func encodeVarintKeys(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *PubKey) Size() (n int) { - if m == nil { +func (pubKey *PubKey) Size() (n int) { + if pubKey == nil { return 0 } var l int _ = l - l = len(m.Key) + l = len(pubKey.Key) if l > 0 { n += 1 + l + sovKeys(uint64(l)) } return n } -func (m *PrivKey) Size() (n int) { - if m == nil { +func (privKey *PrivKey) Size() (n int) { + if privKey == nil { return 0 } var l int _ = l - l = len(m.Key) + l = len(privKey.Key) if l > 0 { n += 1 + l + sovKeys(uint64(l)) } @@ -247,7 +247,7 @@ func sovKeys(x uint64) (n int) { func sozKeys(x uint64) (n int) { return sovKeys(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *PubKey) Unmarshal(dAtA []byte) error { +func (pubKey *PubKey) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -305,9 +305,9 @@ func (m *PubKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} + pubKey.Key = append(pubKey.Key[:0], dAtA[iNdEx:postIndex]...) + if pubKey.Key == nil { + pubKey.Key = []byte{} } iNdEx = postIndex default: @@ -331,7 +331,7 @@ func (m *PubKey) Unmarshal(dAtA []byte) error { } return nil } -func (m *PrivKey) Unmarshal(dAtA []byte) error { +func (privKey *PrivKey) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -389,9 +389,9 @@ func (m *PrivKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} + privKey.Key = append(privKey.Key[:0], dAtA[iNdEx:postIndex]...) + if privKey.Key == nil { + privKey.Key = []byte{} } iNdEx = postIndex default: diff --git a/ethereum/crypto/hd/algorithm.go b/ethereum/crypto/hd/algorithm.go index 041a640c..d81d86d3 100644 --- a/ethereum/crypto/hd/algorithm.go +++ b/ethereum/crypto/hd/algorithm.go @@ -1,17 +1,17 @@ package hd import ( - ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcutil/hdkeychain" bip39 "github.com/tyler-smith/go-bip39" - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/crypto" - "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/crypto" + + ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" ) const ( diff --git a/ethereum/crypto/hd/algorithm_test.go b/ethereum/crypto/hd/algorithm_test.go index 829fe6b3..d3272bd9 100644 --- a/ethereum/crypto/hd/algorithm_test.go +++ b/ethereum/crypto/hd/algorithm_test.go @@ -5,16 +5,16 @@ import ( "strings" "testing" - artelatypes "github.com/artela-network/artela/ethereum/types" + "github.com/stretchr/testify/require" amino "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" "github.com/artela-network/artela/app" cryptocodec "github.com/artela-network/artela/ethereum/crypto/codec" + artelatypes "github.com/artela-network/artela/ethereum/types" ) var TestCodec amino.Codec diff --git a/ethereum/crypto/hd/benchmark_test.go b/ethereum/crypto/hd/benchmark_test.go index 07351f71..bca1d200 100644 --- a/ethereum/crypto/hd/benchmark_test.go +++ b/ethereum/crypto/hd/benchmark_test.go @@ -3,9 +3,9 @@ package hd import ( "testing" - "github.com/artela-network/artela/ethereum/types" - "github.com/cosmos/cosmos-sdk/crypto/keyring" + + "github.com/artela-network/artela/ethereum/types" ) func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) { diff --git a/ethereum/crypto/hd/utils_test.go b/ethereum/crypto/hd/utils_test.go index a9d58735..53f07191 100644 --- a/ethereum/crypto/hd/utils_test.go +++ b/ethereum/crypto/hd/utils_test.go @@ -7,13 +7,13 @@ import ( "os" "sync" - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg" bip39 "github.com/tyler-smith/go-bip39" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) const issue179FixEnvar = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" diff --git a/ethereum/crypto/keyring/options.go b/ethereum/crypto/keyring/options.go index 3dc9fec3..13e01551 100644 --- a/ethereum/crypto/keyring/options.go +++ b/ethereum/crypto/keyring/options.go @@ -1,10 +1,11 @@ package keyring import ( - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela/ethereum/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/types" + + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela/ethereum/crypto/hd" ) // AppName defines the Ledger app used for signing. Artela uses the Ethereum app diff --git a/ethereum/eip712/eip712_legacy.go b/ethereum/eip712/eip712_legacy.go index b015c4c8..e2fbcbcf 100644 --- a/ethereum/eip712/eip712_legacy.go +++ b/ethereum/eip712/eip712_legacy.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/signer/core/apitypes" diff --git a/ethereum/eip712/encoding.go b/ethereum/eip712/encoding.go index c9b016d6..5b421ede 100644 --- a/ethereum/eip712/encoding.go +++ b/ethereum/eip712/encoding.go @@ -4,18 +4,14 @@ import ( "errors" "fmt" - artelatypes "github.com/artela-network/artela/ethereum/types" - - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" - + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" txTypes "github.com/cosmos/cosmos-sdk/types/tx" - + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/ethereum/go-ethereum/signer/core/apitypes" "github.com/artela-network/artela/app/params" - - "github.com/cosmos/cosmos-sdk/codec" + artelatypes "github.com/artela-network/artela/ethereum/types" ) var ( diff --git a/ethereum/eip712/encoding_legacy.go b/ethereum/eip712/encoding_legacy.go index 633fb3cd..cd1ce01d 100644 --- a/ethereum/eip712/encoding_legacy.go +++ b/ethereum/eip712/encoding_legacy.go @@ -5,14 +5,12 @@ import ( "errors" "fmt" - artela "github.com/artela-network/artela/ethereum/types" - - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" - sdk "github.com/cosmos/cosmos-sdk/types" txTypes "github.com/cosmos/cosmos-sdk/types/tx" - + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/ethereum/go-ethereum/signer/core/apitypes" + + artela "github.com/artela-network/artela/ethereum/types" ) type aminoMessage struct { diff --git a/ethereum/eip712/message.go b/ethereum/eip712/message.go index b1b72413..835e98a1 100644 --- a/ethereum/eip712/message.go +++ b/ethereum/eip712/message.go @@ -3,11 +3,11 @@ package eip712 import ( "fmt" - errorsmod "cosmossdk.io/errors" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/tidwall/gjson" "github.com/tidwall/sjson" + + errorsmod "cosmossdk.io/errors" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" ) type eip712MessagePayload struct { diff --git a/ethereum/eip712/preprocess.go b/ethereum/eip712/preprocess.go index dc63641d..b28a3ebb 100644 --- a/ethereum/eip712/preprocess.go +++ b/ethereum/eip712/preprocess.go @@ -3,13 +3,13 @@ package eip712 import ( "fmt" - types2 "github.com/artela-network/artela/ethereum/types" - "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cosmoskr "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + + types2 "github.com/artela-network/artela/ethereum/types" ) // PreprocessLedgerTx reformats Ledger-signed Cosmos transactions to match the fork expected by Artela diff --git a/ethereum/eip712/types.go b/ethereum/eip712/types.go index 1b740f45..ea009516 100644 --- a/ethereum/eip712/types.go +++ b/ethereum/eip712/types.go @@ -6,14 +6,13 @@ import ( "sort" "strings" + "github.com/tidwall/gjson" "golang.org/x/text/cases" "golang.org/x/text/language" errorsmod "cosmossdk.io/errors" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/ethereum/go-ethereum/signer/core/apitypes" - "github.com/tidwall/gjson" ) const ( diff --git a/ethereum/rpc/account.go b/ethereum/rpc/account.go index ea10bde5..46844956 100644 --- a/ethereum/rpc/account.go +++ b/ethereum/rpc/account.go @@ -25,7 +25,6 @@ import ( "github.com/artela-network/artela/ethereum/crypto/hd" ethapi2 "github.com/artela-network/artela/ethereum/rpc/ethapi" "github.com/artela-network/artela/ethereum/rpc/types" - rpctypes "github.com/artela-network/artela/ethereum/rpc/types" types2 "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/ethereum/utils" "github.com/artela-network/artela/x/evm/txs" @@ -131,7 +130,11 @@ func (b *BackendImpl) SignTransaction(args *ethapi2.TransactionArgs) (*ethtypes. return nil, err } - signer := ethtypes.MakeSigner(b.ChainConfig(), new(big.Int).SetUint64(uint64(bn)), bt) + cfg, err := b.chainConfig() + if err != nil { + return nil, err + } + signer := ethtypes.MakeSigner(cfg, new(big.Int).SetUint64(uint64(bn)), bt) // LegacyTx derives chainID from the signature. To make sure the msg.ValidateBasic makes // the corresponding chainID validation, we need to sign the transaction before calling it @@ -166,18 +169,20 @@ func (b *BackendImpl) GetTransactionCount(address common.Address, blockNrOrHash if err != nil { return &n, err } - currentHeight := b.CurrentHeader().Number - if height.Int64() > currentHeight.Int64() { + header, err := b.CurrentHeader() + if err != nil { + return &n, err + } + if height.Int64() > header.Number.Int64() { return &n, fmt.Errorf( "cannot query with height in the future (current: %d, queried: %d); please provide a valid height", - currentHeight, height) + header.Number, height) } // Get nonce (sequence) from account from := sdktypes.AccAddress(address.Bytes()) accRet := b.clientCtx.AccountRetriever - err = accRet.EnsureExists(b.clientCtx, from) - if err != nil { + if err = accRet.EnsureExists(b.clientCtx, from); err != nil { // account doesn't exist yet, return 0 b.logger.Info("GetTransactionCount faild, return 0. Account doesn't exist yet", "account", address.Hex(), "error", err) return &n, nil @@ -263,7 +268,7 @@ func (b *BackendImpl) GetBalance(address common.Address, blockNrOrHash rpc.Block return nil, err } - res, err := b.queryClient.Balance(rpctypes.ContextWithHeight(blockNum.Int64()), req) + res, err := b.queryClient.Balance(types.ContextWithHeight(blockNum.Int64()), req) if err != nil { return nil, err } diff --git a/ethereum/rpc/api/debug.go b/ethereum/rpc/api/debug.go index f7654cb7..f3a7bede 100644 --- a/ethereum/rpc/api/debug.go +++ b/ethereum/rpc/api/debug.go @@ -16,18 +16,17 @@ import ( "sync" "time" - tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" - "github.com/davecgh/go-spew/spew" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rpc" - stderrors "github.com/pkg/errors" "github.com/cometbft/cometbft/libs/log" + tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/cosmos-sdk/server" + "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" evmtxs "github.com/artela-network/artela/x/evm/txs" evmsupport "github.com/artela-network/artela/x/evm/txs/support" @@ -128,7 +127,7 @@ func (a *DebugAPI) BlockProfile(file string, nsec uint) error { // CpuProfile turns on CPU profiling for nsec seconds and writes // profile data to file. -func (a *DebugAPI) CpuProfile(file string, nsec uint) error { // nolint: golint, stylecheck, revive +func (a *DebugAPI) CpuProfile(file string, nsec uint) error { a.logger.Debug("debug_cpuProfile", "file", file, "nsec", nsec) if err := a.StartCPUProfile(file); err != nil { return err @@ -300,7 +299,7 @@ func (a *DebugAPI) SetGCPercent(v int) int { // GetHeaderRlp retrieves the RLP encoded for of a single header. func (a *DebugAPI) GetHeaderRlp(number uint64) (hexutil.Bytes, error) { - header, err := a.backend.HeaderByNumber(nil, rpc.BlockNumber(number)) + header, err := a.backend.HeaderByNumber(context.TODO(), rpc.BlockNumber(number)) if err != nil { return nil, err } @@ -310,7 +309,7 @@ func (a *DebugAPI) GetHeaderRlp(number uint64) (hexutil.Bytes, error) { // GetBlockRlp retrieves the RLP encoded for of a single block. func (a *DebugAPI) GetBlockRlp(number uint64) (hexutil.Bytes, error) { - block, err := a.backend.BlockByNumber(nil, rpc.BlockNumber(number)) + block, err := a.backend.BlockByNumber(context.TODO(), rpc.BlockNumber(number)) if err != nil { return nil, err } @@ -320,7 +319,7 @@ func (a *DebugAPI) GetBlockRlp(number uint64) (hexutil.Bytes, error) { // PrintBlock retrieves a block and returns its pretty printed form. func (a *DebugAPI) PrintBlock(number uint64) (string, error) { - block, err := a.backend.BlockByNumber(nil, rpc.BlockNumber(number)) + block, err := a.backend.BlockByNumber(context.TODO(), rpc.BlockNumber(number)) if err != nil { return "", err } diff --git a/ethereum/rpc/apis.go b/ethereum/rpc/apis.go index 763cc60b..71754598 100644 --- a/ethereum/rpc/apis.go +++ b/ethereum/rpc/apis.go @@ -1,11 +1,10 @@ package rpc import ( - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/rpc" - rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" "github.com/cosmos/cosmos-sdk/client" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/rpc" "github.com/artela-network/artela/ethereum/rpc/api" "github.com/artela-network/artela/ethereum/rpc/ethapi" @@ -13,7 +12,6 @@ import ( ) func GetAPIs(clientCtx client.Context, wsClient *rpcclient.WSClient, logger log.Logger, apiBackend *BackendImpl) []rpc.API { - nonceLock := new(ethapi.AddrLocker) return []rpc.API{ { diff --git a/ethereum/rpc/backend.go b/ethereum/rpc/backend.go index 935d20fd..bf00fe88 100644 --- a/ethereum/rpc/backend.go +++ b/ethereum/rpc/backend.go @@ -37,7 +37,6 @@ import ( rpctypes "github.com/artela-network/artela/ethereum/rpc/types" "github.com/artela-network/artela/ethereum/rpc/utils" "github.com/artela-network/artela/ethereum/server/config" - "github.com/artela-network/artela/ethereum/types" ethereumtypes "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/x/evm/txs" evmtypes "github.com/artela-network/artela/x/evm/types" @@ -158,13 +157,26 @@ func (b *BackendImpl) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { } func (b *BackendImpl) ChainConfig() *params.ChainConfig { + cfg, err := b.chainConfig() + if err != nil { + return nil + } + return cfg +} + +func (b *BackendImpl) chainConfig() (*params.ChainConfig, error) { params, err := b.queryClient.Params(b.ctx, &txs.QueryParamsRequest{}) if err != nil { b.logger.Info("queryClient.Params failed", err) - return nil + return nil, err + } + + currentHeader, err := b.CurrentHeader() + if err != nil { + return nil, err } - return params.Params.ChainConfig.EthereumConfig(b.chainID) + return params.Params.ChainConfig.EthereumConfig(currentHeader.Number.Int64(), b.chainID), nil } func (b *BackendImpl) FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, @@ -256,8 +268,8 @@ func (b *BackendImpl) FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, return &feeHistory, nil } -func (b *BackendImpl) ChainDb() ethdb.Database { //nolint:stylecheck // conforms to interface. - return ethdb.Database(nil) +func (b *BackendImpl) ChainDb() ethdb.Database { + return nil } func (b *BackendImpl) ExtRPCEnabled() bool { @@ -369,7 +381,7 @@ func (b *BackendImpl) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int for i := len(blockRes.BeginBlockEvents) - 1; i >= 0; i-- { evt := blockRes.BeginBlockEvents[i] if evt.Type == feetypes.EventTypeFee && len(evt.Attributes) > 0 { - baseFee, err := strconv.ParseInt(string(evt.Attributes[0].Value), 10, 64) + baseFee, err := strconv.ParseInt(evt.Attributes[0].Value, 10, 64) if err == nil { return big.NewInt(baseFee), nil } @@ -396,7 +408,7 @@ func (b *BackendImpl) GasPrice(ctx context.Context) (*hexutil.Big, error) { result *big.Int err error ) - if head := b.CurrentHeader(); head.BaseFee != nil { + if head, err := b.CurrentHeader(); err == nil && head.BaseFee != nil { result, err = b.SuggestGasTipCap(head.BaseFee) if err != nil { return nil, err @@ -422,14 +434,14 @@ func (b *BackendImpl) GasPrice(ctx context.Context) (*hexutil.Big, error) { func (b *BackendImpl) RPCMinGasPrice() int64 { evmParams, err := b.queryClient.Params(b.ctx, &txs.QueryParamsRequest{}) if err != nil { - return types.DefaultGasPrice + return ethereumtypes.DefaultGasPrice } minGasPrice := b.appConf.GetMinGasPrices() amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt64() if amt == 0 { b.logger.Debug("amt is 0, return DefaultGasPrice") - return types.DefaultGasPrice + return ethereumtypes.DefaultGasPrice } return amt diff --git a/ethereum/rpc/blocks.go b/ethereum/rpc/blocks.go index d31c6b7d..683c36b1 100644 --- a/ethereum/rpc/blocks.go +++ b/ethereum/rpc/blocks.go @@ -2,6 +2,7 @@ package rpc import ( "context" + "encoding/base64" "encoding/json" "errors" "fmt" @@ -10,7 +11,6 @@ import ( "sort" "strconv" - "github.com/artela-network/artela-evm/vm" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdktypes "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" @@ -19,7 +19,6 @@ import ( "github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rpc" @@ -29,6 +28,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "github.com/artela-network/artela-evm/vm" "github.com/artela-network/artela/ethereum/rpc/ethapi" rpctypes "github.com/artela-network/artela/ethereum/rpc/types" "github.com/artela-network/artela/ethereum/rpc/utils" @@ -82,26 +82,33 @@ func (b *BackendImpl) HeaderByNumberOrHash(ctx context.Context, return nil, errors.New("HeaderByNumberOrHash is not implemented") } -func (b *BackendImpl) CurrentHeader() *ethtypes.Header { +func (b *BackendImpl) CurrentHeader() (*ethtypes.Header, error) { block, err := b.BlockByNumber(context.Background(), rpc.LatestBlockNumber) - if err != nil || block == nil { - b.logger.Error("get CurrentHeader failed, error or block is nil", "error", err) - return nil + if err != nil { + return nil, err + } + if block == nil || block.Header() == nil { + return nil, errors.New("current block header not found") } - return block.Header() + return block.Header(), nil } func (b *BackendImpl) CurrentBlock() *rpctypes.Block { + block, _ := b.currentBlock() + return block +} + +func (b *BackendImpl) currentBlock() (*rpctypes.Block, error) { block, err := b.ArtBlockByNumber(context.Background(), rpc.LatestBlockNumber) if err != nil { b.logger.Error("get CurrentBlock failed", "error", err) - return nil + return nil, err } - return block + return block, nil } -func (b *BackendImpl) BlockByNumber(_ context.Context, number rpc.BlockNumber) (*ethtypes.Block, error) { - block, err := b.ArtBlockByNumber(context.Background(), number) +func (b *BackendImpl) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Block, error) { + block, err := b.ArtBlockByNumber(ctx, number) if err != nil { return nil, err } @@ -136,39 +143,39 @@ func (b *BackendImpl) BlockByHash(_ context.Context, hash common.Hash) (*rpctype return b.BlockFromCosmosBlock(resBlock, blockRes) } -func (b *BackendImpl) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*rpctypes.Block, error) { +func (b *BackendImpl) BlockByNumberOrHash(_ context.Context, _ rpc.BlockNumberOrHash) (*rpctypes.Block, error) { return nil, errors.New("BlockByNumberOrHash is not implemented") } func (b *BackendImpl) StateAndHeaderByNumber( - ctx context.Context, number rpc.BlockNumber, + _ context.Context, number rpc.BlockNumber, ) (*state.StateDB, *ethtypes.Header, error) { return nil, nil, errors.New("StateAndHeaderByNumber is not implemented") } func (b *BackendImpl) StateAndHeaderByNumberOrHash( - ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, + _ context.Context, _ rpc.BlockNumberOrHash, ) (*state.StateDB, *ethtypes.Header, error) { return nil, nil, errors.New("invalid arguments; neither block nor hash specified") } -func (b *BackendImpl) PendingBlockAndReceipts() (*ethtypes.Block, types.Receipts) { +func (b *BackendImpl) PendingBlockAndReceipts() (*ethtypes.Block, ethtypes.Receipts) { b.logger.Error("PendingBlockAndReceipts is not implemented") return nil, nil } // GetReceipts get receipts by block hash -func (b *BackendImpl) GetReceipts(_ context.Context, hash common.Hash) (types.Receipts, error) { +func (b *BackendImpl) GetReceipts(_ context.Context, _ common.Hash) (ethtypes.Receipts, error) { return nil, errors.New("GetReceipts is not implemented") } -func (b *BackendImpl) GetTd(_ context.Context, hash common.Hash) *big.Int { +func (b *BackendImpl) GetTd(_ context.Context, _ common.Hash) *big.Int { b.logger.Error("GetTd is not implemented") return nil } -func (b *BackendImpl) GetEVM(ctx context.Context, msg *core.Message, state *state.StateDB, - header *ethtypes.Header, vmConfig *vm.Config, _ *vm.BlockContext, +func (b *BackendImpl) GetEVM(_ context.Context, _ *core.Message, _ *state.StateDB, + _ *ethtypes.Header, _ *vm.Config, _ *vm.BlockContext, ) (*vm.EVM, func() error) { return nil, func() error { return errors.New("GetEVM is not impelemted") @@ -241,8 +248,11 @@ func (b *BackendImpl) blockNumberFromCosmos(blockNrOrHash rpc.BlockNumberOrHash) return rpc.BlockNumber(resBlock.Block.Height), nil case blockNrOrHash.BlockNumber != nil: if *blockNrOrHash.BlockNumber == rpc.LatestBlockNumber { - currentHeight := b.CurrentHeader().Number - return rpc.BlockNumber(currentHeight.Int64()), nil + currentHeader, err := b.CurrentHeader() + if err != nil { + return rpc.LatestBlockNumber, err + } + return rpc.BlockNumber(currentHeader.Number.Int64()), nil } return *blockNrOrHash.BlockNumber, nil default: @@ -335,7 +345,12 @@ func (b *BackendImpl) blockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethty for _, attr := range event.Attributes { if attr.Key == evmtypes.AttributeKeyEthereumBloom { - return ethtypes.BytesToBloom([]byte(attr.Value)), nil + encodedBloom, err := base64.StdEncoding.DecodeString(attr.Value) + if err != nil { + return ethtypes.Bloom{}, err + } + + return ethtypes.BytesToBloom(encodedBloom), nil } } } @@ -511,11 +526,14 @@ func (b *BackendImpl) processBlock( targetOneFeeHistory := &rpctypes.OneFeeHistory{} targetOneFeeHistory.BaseFee = blockBaseFee - cfg := b.ChainConfig() + cfg, err := b.chainConfig() + if err != nil { + return nil, err + } if cfg.IsLondon(big.NewInt(blockHeight + 1)) { - header := b.CurrentHeader() - if header == nil { - return nil, errors.New("header does not exist") + header, err := b.CurrentHeader() + if err != nil { + return nil, err } targetOneFeeHistory.NextBaseFee = misc.CalcBaseFee(cfg, header) } else { diff --git a/ethereum/rpc/config.go b/ethereum/rpc/config.go index 124dd83b..93ff27b0 100644 --- a/ethereum/rpc/config.go +++ b/ethereum/rpc/config.go @@ -8,9 +8,10 @@ import ( "github.com/BurntSushi/toml" - "github.com/artela-network/artela/ethereum/server/config" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/gasprice" + + "github.com/artela-network/artela/ethereum/server/config" ) const ( diff --git a/ethereum/rpc/ethapi/api.go b/ethereum/rpc/ethapi/api.go index ea366341..9cb73647 100644 --- a/ethereum/rpc/ethapi/api.go +++ b/ethereum/rpc/ethapi/api.go @@ -2,24 +2,20 @@ package ethapi import ( "context" - "encoding/hex" "errors" "fmt" "math/big" - "strings" "time" - "github.com/artela-network/artela-evm/vm" - sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/davecgh/go-spew/spew" + + sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus/misc" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -29,10 +25,10 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - "github.com/artela-network/artela/x/evm/txs" - + "github.com/artela-network/artela-evm/vm" rpctypes "github.com/artela-network/artela/ethereum/rpc/types" ethtypes "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/txs" ) // EthereumAPI provides an API to access Ethereum related information. @@ -47,24 +43,24 @@ func NewEthereumAPI(b Backend, logger log.Logger) *EthereumAPI { } // ProtocolVersion returns the supported Ethereum protocol version. -func (e *EthereumAPI) ProtocolVersion() hexutil.Uint { - e.logger.Debug("eth_protocolVersion") +func (s *EthereumAPI) ProtocolVersion() hexutil.Uint { + s.logger.Debug("eth_protocolVersion") return hexutil.Uint(ethtypes.ProtocolVersion) } // GasPrice returns a suggestion for a gas price for legacy transactions. -func (e *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { - e.logger.Debug("eth_gasPrice") - return e.b.GasPrice(ctx) +func (s *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { + s.logger.Debug("eth_gasPrice") + return s.b.GasPrice(ctx) } // MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions. -func (s *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error) { +func (s *EthereumAPI) MaxPriorityFeePerGas(_ context.Context) (*hexutil.Big, error) { return nil, errors.New("MaxPriorityFeePerGas is not implemented") } // FeeHistory returns the fee market history. -func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) { +func (s *EthereumAPI) FeeHistory(_ context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) { return s.b.FeeHistory(uint64(blockCount), lastBlock, rewardPercentiles) } @@ -97,7 +93,7 @@ func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction { } // ContentFrom returns the transactions contained within the transaction pool. -func (s *TxPoolAPI) ContentFrom(addr common.Address) map[string]map[string]*RPCTransaction { +func (s *TxPoolAPI) ContentFrom(_ common.Address) map[string]map[string]*RPCTransaction { // not implemented return nil } @@ -174,7 +170,7 @@ func (s *PersonalAccountAPI) ListWallets() []rawWallet { // connection and attempting to authenticate via the provided passphrase. Note, // the method may return an extra challenge requiring a second open (e.g. the // Trezor PIN matrix challenge). -func (s *PersonalAccountAPI) OpenWallet(url string, passphrase *string) error { +func (s *PersonalAccountAPI) OpenWallet(_ string, _ *string) error { return errors.New("OpenWallet is not implemented") } @@ -198,13 +194,13 @@ func (s *PersonalAccountAPI) ImportRawKey(privkey string, password string) (comm // UnlockAccount will unlock the account associated with the given address with // the given password for duration seconds. If duration is nil it will use a // default of 300 seconds. It returns an indication if the account was unlocked. -func (s *PersonalAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error) { +func (s *PersonalAccountAPI) UnlockAccount(_ context.Context, _ common.Address, _ string, duration *uint64) (bool, error) { // not implemented return false, errors.New("UnlockAccount is not implemented") } // LockAccount will lock the account associated with the given address when it's unlocked. -func (s *PersonalAccountAPI) LockAccount(addr common.Address) bool { +func (s *PersonalAccountAPI) LockAccount(_ common.Address) bool { // not implemented" return false } @@ -212,7 +208,7 @@ func (s *PersonalAccountAPI) LockAccount(addr common.Address) bool { // signTransaction sets defaults and signs the given transaction // NOTE: the caller needs to ensure that the nonceLock is held, if applicable, // and release it after the transaction has been submitted to the tx pool -func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *TransactionArgs, passwd string) (*types.Transaction, error) { +func (s *PersonalAccountAPI) signTransaction(_ context.Context, args *TransactionArgs, passwd string) (*types.Transaction, error) { // return s.b.SignTransaction(args, passwd) // TODO return nil, fmt.Errorf("signTransaction is not implemented, args: %v, passwd: %s", args, passwd) @@ -240,7 +236,7 @@ func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args Transacti // tries to sign it with the key associated with args.From. If the given passwd isn't // able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast // to other nodes -func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args TransactionArgs, passwd string) (*SignTransactionResult, error) { +func (s *PersonalAccountAPI) SignTransaction(_ context.Context, args TransactionArgs, passwd string) (*SignTransactionResult, error) { // TODO return nil, fmt.Errorf("SignTransaction is not implemented, args: %v, passwd: %s", args, passwd) } @@ -254,7 +250,7 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti // The key used to calculate the signature is decrypted with the given password. // // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign -func (s *PersonalAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error) { +func (s *PersonalAccountAPI) Sign(_ context.Context, _ hexutil.Bytes, _ common.Address, _ string) (hexutil.Bytes, error) { // TODO return nil, errors.New("Sign is not implemented") } @@ -269,7 +265,7 @@ func (s *PersonalAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr // the V value must be 27 or 28 for legacy reasons. // // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover -func (s *PersonalAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error) { +func (s *PersonalAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error) { if len(sig) != crypto.SignatureLength { return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength) } @@ -286,13 +282,13 @@ func (s *PersonalAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.By } // InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key. -func (s *PersonalAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error) { +func (s *PersonalAccountAPI) InitializeWallet(_ context.Context, _ string) (string, error) { return "", errors.New("InitializeWallet is not implemented") } // Unpair deletes a pairing between wallet and geth. -func (s *PersonalAccountAPI) Unpair(ctx context.Context, url string, pin string) error { - return errors.New("Unpair is not implemented") +func (s *PersonalAccountAPI) Unpair(_ context.Context, _ string, _ string) error { + return errors.New("unpair is not implemented") } // BlockChainAPI provides an API to access Ethereum blockchain data. @@ -312,12 +308,12 @@ func NewBlockChainAPI(b Backend, logger log.Logger) *BlockChainAPI { // returned, regardless of the current head block. We used to return an error when the chain // wasn't synced up to a block where EIP-155 is enabled, but this behavior caused issues // in CL clients. -func (api *BlockChainAPI) ChainId() *hexutil.Big { - return (*hexutil.Big)(api.b.ChainConfig().ChainID) +func (s *BlockChainAPI) ChainId() *hexutil.Big { + return (*hexutil.Big)(s.b.ChainConfig().ChainID) } -func (api *BlockChainAPI) Coinbase() (sdktypes.AccAddress, error) { - return api.b.GetCoinbase() +func (s *BlockChainAPI) Coinbase() (sdktypes.AccAddress, error) { + return s.b.GetCoinbase() } // BlockNumber returns the block number of the chain head. @@ -333,7 +329,7 @@ func (s *BlockChainAPI) BlockNumber() hexutil.Uint64 { // GetBalance returns the amount of wei for the given address in the states of the // given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta // block numbers are also allowed. -func (s *BlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) { +func (s *BlockChainAPI) GetBalance(_ context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) { return s.b.GetBalance(address, blockNrOrHash) } @@ -355,31 +351,11 @@ type StorageResult struct { } // GetProof returns the Merkle-proof for a given account and optionally some storage keys. -func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { +func (s *BlockChainAPI) GetProof(_ context.Context, address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { s.logger.Debug("eth_getProof", "address", address.Hex(), "keys", storageKeys, "block number or hash", blockNrOrHash) return s.b.GetProof(address, storageKeys, blockNrOrHash) } -// decodeHash parses a hex-encoded 32-byte hash. The input may optionally -// be prefixed by 0x and can have a byte length up to 32. -// nolint:unused -func decodeHash(s string) (common.Hash, error) { - if strings.HasPrefix(s, "0x") || strings.HasPrefix(s, "0X") { - s = s[2:] - } - if (len(s) & 1) > 0 { - s = "0" + s - } - b, err := hex.DecodeString(s) - if err != nil { - return common.Hash{}, errors.New("hex string invalid") - } - if len(b) > 32 { - return common.Hash{}, errors.New("hex string too long, want at most 32 bytes") - } - return common.BytesToHash(b), nil -} - // GetHeaderByNumber returns the requested canonical block header. // * When blockNr is -1 the chain head is returned. // * When blockNr is -2 the pending chain head is returned. @@ -492,14 +468,14 @@ func (s *BlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash } // GetCode returns the code stored at the given address in the states for the given block number. -func (s *BlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { +func (s *BlockChainAPI) GetCode(_ context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { return s.b.GetCode(address, blockNrOrHash) } // GetStorageAt returns the storage from the states at the given address, key and // block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block // numbers are also allowed. -func (s *BlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, hexKey string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { +func (s *BlockChainAPI) GetStorageAt(_ context.Context, address common.Address, hexKey string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { return s.b.GetStorageAt(address, hexKey, blockNrOrHash) } @@ -630,47 +606,13 @@ func (context *ChainContext) GetHeader(hash common.Hash, number uint64) *types.H return header } -// nolint:unused -func newRevertError(result *core.ExecutionResult) *revertError { - reason, errUnpack := abi.UnpackRevert(result.Revert()) - err := errors.New("execution reverted") - if errUnpack == nil { - err = fmt.Errorf("execution reverted: %v", reason) - } - return &revertError{ - error: err, - reason: hexutil.Encode(result.Revert()), - } -} - -// revertError is an API error that encompasses an EVM revertal with JSON error -// code and a binary data blob. -// nolint:unused -type revertError struct { - error - reason string // revert reason hex encoded -} - -// ErrorCode returns the JSON error code for a revertal. -// See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal -// nolint:unused -func (e *revertError) ErrorCode() int { - return 3 -} - -// ErrorData returns the hex encoded revert reason. -// nolint:unused -func (e *revertError) ErrorData() interface{} { - return e.reason -} - // Call executes the given transaction on the states for the given block number. // // Additionally, the caller can specify a batch of contract for fields overriding. // // Note, this function doesn't make and changes in the states/blockchain and is // useful to execute and retrieve values. -func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error) { +func (s *BlockChainAPI) Call(_ context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, _ *StateOverride, _ *BlockOverrides) (hexutil.Bytes, error) { data, err := s.b.DoCall(args, blockNrOrHash) if err != nil { return hexutil.Bytes{}, err @@ -755,7 +697,7 @@ func RPCMarshalBlock(block *rpctypes.Block, inclTx bool, fullTx bool, config *pa // rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires // a `BlockchainAPI`. -func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header, hash common.Hash) map[string]interface{} { +func (s *BlockChainAPI) rpcMarshalHeader(_ context.Context, header *types.Header, hash common.Hash) map[string]interface{} { fields := RPCMarshalHeader(header, hash) // fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, header.Hash())) return fields @@ -763,16 +705,8 @@ func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Head // rpcMarshalBlock uses the generalized output filler, then adds the total difficulty field, which requires // a `BlockchainAPI`. -func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *rpctypes.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) { - fields, err := RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig()) - if err != nil { - return nil, err - } - // nolint - if inclTx { - // fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, b.Hash())) - } - return fields, err +func (s *BlockChainAPI) rpcMarshalBlock(_ context.Context, b *rpctypes.Block, inclTx bool, fullTx bool) (map[string]interface{}, error) { + return RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig()) } // RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction @@ -803,6 +737,11 @@ type RPCTransaction struct { func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { signer := types.MakeSigner(config, new(big.Int).SetUint64(blockNumber), blockTime) from, _ := types.Sender(signer, tx) + + return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, from) +} + +func newRPCTransactionWithFrom(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, from common.Address) *RPCTransaction { v, r, s := tx.RawSignatureValues() result := &RPCTransaction{ Type: hexutil.Uint64(tx.Type()), @@ -862,6 +801,9 @@ func NewTransactionFromMsg( ) *RPCTransaction { tx := msg.AsTransaction() // use latest singer, so use time.now as block time. + if msg.From != "" { + return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, common.HexToAddress(msg.From)) + } return newRPCTransaction(tx, blockHash, blockNumber, uint64(time.Now().Unix()), index, baseFee, cfg) } @@ -899,10 +841,10 @@ func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.By return blob } -// accessListResult returns an optional accesslist +// AccessListResult returns an optional access list // It's the result of the `debug_createAccessList` RPC call. // It contains an error if the transaction itself failed. -type accessListResult struct { +type AccessListResult struct { Accesslist *types.AccessList `json:"accessList"` Error string `json:"error,omitempty"` GasUsed hexutil.Uint64 `json:"gasUsed"` @@ -910,7 +852,7 @@ type accessListResult struct { // CreateAccessList creates an EIP-2930 type AccessList for the given transaction. // Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain states. -func (s *BlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error) { +func (s *BlockChainAPI) CreateAccessList(_ context.Context, _ TransactionArgs, _ *rpc.BlockNumberOrHash) (*AccessListResult, error) { return nil, errors.New("CreateAccessList is not implemented") } @@ -979,7 +921,7 @@ func (s *TransactionAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Contex } // GetTransactionCount returns the number of transactions the given address has sent for the given block number -func (s *TransactionAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) { +func (s *TransactionAPI) GetTransactionCount(_ context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) { return s.b.GetTransactionCount(address, blockNrOrHash) } @@ -989,7 +931,7 @@ func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.H } // GetRawTransactionByHash returns the bytes of the transaction for the given hash. -func (s *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { +func (s *TransactionAPI) GetRawTransactionByHash(_ context.Context, _ common.Hash) (hexutil.Bytes, error) { // TODO return nil, errors.New("GetRawTransactionByHash is not implemented") } @@ -1021,7 +963,11 @@ func SubmitTransaction(ctx context.Context, logger log.Logger, b Backend, tx *ty return tx.Hash(), nil } - head := b.CurrentHeader() + head, err := b.CurrentHeader() + if err != nil { + return common.Hash{}, err + } + signer := types.MakeSigner(b.ChainConfig(), head.Number, head.Time) from, err := types.Sender(signer, tx) if err != nil { @@ -1124,7 +1070,7 @@ func (s *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error) { // Resend accepts an existing transaction and a new gas price and limit. It will remove // the given transaction from the pool and reinsert it with the new gas price and limit. -func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { +func (s *TransactionAPI) Resend(_ context.Context, _ TransactionArgs, _ *hexutil.Big, _ *hexutil.Uint64) (common.Hash, error) { // TODO return common.Hash{}, errors.New("Resend is not implemented") } @@ -1179,12 +1125,12 @@ func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNum } // GetRawReceipts retrieves the binary-encoded receipts of a single block. -func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) { +func (api *DebugAPI) GetRawReceipts(_ context.Context, _ rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) { return nil, errors.New("GetRawReceipts is not implemented") } // GetRawTransaction returns the bytes of the transaction for the given hash. -func (s *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { +func (api *DebugAPI) GetRawTransaction(_ context.Context, _ common.Hash) (hexutil.Bytes, error) { // TODO return hexutil.Bytes{}, errors.New("GetRawTransaction is not implemented") } @@ -1199,7 +1145,7 @@ func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, err } // ChaindbProperty returns leveldb properties of the key-value database. -func (api *DebugAPI) ChaindbProperty(property string) (string, error) { +func (api *DebugAPI) ChaindbProperty(_ string) (string, error) { return "", errors.New("ChaindbProperty is not implemented") } @@ -1210,7 +1156,7 @@ func (api *DebugAPI) ChaindbCompact() error { } // SetHead rewinds the head of the blockchain to a previous block. -func (api *DebugAPI) SetHead(number hexutil.Uint64) { +func (api *DebugAPI) SetHead(_ hexutil.Uint64) { // TODO } @@ -1253,21 +1199,11 @@ func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error { feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.Ether))) feeFloat, _ := feeEth.Float64() if feeFloat > cap { - return fmt.Errorf("tx fee (%.2f ether) exceeds the configured cap (%.2f ether)", feeFloat, cap) + return fmt.Errorf("tx fee (%.2f art) exceeds the configured cap (%.2f art)", feeFloat, cap) } return nil } -// toHexSlice creates a slice of hex-strings based on []byte. -// nolint:unused -func toHexSlice(b [][]byte) []string { - r := make([]string, len(b)) - for i := range b { - r[i] = hexutil.Encode(b[i]) - } - return r -} - func isCustomizedVerificationRequired(tx *types.Transaction) bool { zero := big.NewInt(0) v, r, s := tx.RawSignatureValues() diff --git a/ethereum/rpc/ethapi/backend.go b/ethereum/rpc/ethapi/backend.go index ee9d755d..bf5a3525 100644 --- a/ethereum/rpc/ethapi/backend.go +++ b/ethereum/rpc/ethapi/backend.go @@ -4,7 +4,6 @@ import ( "context" "math/big" - "github.com/artela-network/artela-evm/vm" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -12,10 +11,10 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" + "github.com/artela-network/artela-evm/vm" rpctypes "github.com/artela-network/artela/ethereum/rpc/types" "github.com/artela-network/artela/x/evm/txs" ) @@ -38,7 +37,7 @@ type Backend interface { HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) - CurrentHeader() *types.Header + CurrentHeader() (*types.Header, error) CurrentBlock() *rpctypes.Block BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) ArtBlockByNumber(ctx context.Context, number rpc.BlockNumber) (*rpctypes.Block, error) @@ -54,7 +53,7 @@ type Backend interface { // Transaction pool API SendTx(ctx context.Context, signedTx *types.Transaction) error GetTransaction(ctx context.Context, txHash common.Hash) (*RPCTransaction, error) - SignTransaction(args *TransactionArgs) (*ethtypes.Transaction, error) + SignTransaction(args *TransactionArgs) (*types.Transaction, error) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) RPCTxFeeCap() float64 UnprotectedAllowed() bool diff --git a/ethereum/rpc/ethapi/dbapi.go b/ethereum/rpc/ethapi/dbapi.go index c0be1f3e..1675375a 100644 --- a/ethereum/rpc/ethapi/dbapi.go +++ b/ethereum/rpc/ethapi/dbapi.go @@ -7,14 +7,14 @@ import ( ) // DbGet returns the raw value of a key stored in the database. -func (api *DebugAPI) DbGet(key string) (hexutil.Bytes, error) { +func (api *DebugAPI) DbGet(_ string) (hexutil.Bytes, error) { // not implement return nil, errors.New("not implemented") } // DbAncient retrieves an ancient binary blob from the append-only immutable files. // It is a mapping to the `AncientReaderOp.Ancient` method -func (api *DebugAPI) DbAncient(kind string, number uint64) (hexutil.Bytes, error) { +func (api *DebugAPI) DbAncient(_ string, _ uint64) (hexutil.Bytes, error) { // not implement return nil, errors.New("not implemented") } diff --git a/ethereum/rpc/ethapi/transaction_args.go b/ethereum/rpc/ethapi/transaction_args.go index 642c3132..0684e9cb 100644 --- a/ethereum/rpc/ethapi/transaction_args.go +++ b/ethereum/rpc/ethapi/transaction_args.go @@ -7,8 +7,6 @@ import ( "fmt" "math/big" - "github.com/artela-network/artela/x/evm/txs" - sdkmath "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -17,6 +15,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + + "github.com/artela-network/artela/x/evm/txs" ) // TransactionArgs represents the arguments to construct a new transaction @@ -74,7 +74,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { if err != nil { return err } - args.Nonce = (*hexutil.Uint64)(nonce) + args.Nonce = nonce // TODO set nonce } if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) { @@ -141,7 +141,11 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro return nil } // Now attempt to fill in default value depending on whether London is active or not. - head := b.CurrentHeader() + head, err := b.CurrentHeader() + if err != nil { + return err + } + if b.ChainConfig().IsLondon(head.Number) { // London is active, set maxPriorityFeePerGas and maxFeePerGas. if err := args.setLondonFeeDefaults(ctx, head, b); err != nil { @@ -162,7 +166,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro } // setLondonFeeDefaults fills in reasonable default fee values for unspecified fields. -func (args *TransactionArgs) setLondonFeeDefaults(ctx context.Context, head *types.Header, b Backend) error { +func (args *TransactionArgs) setLondonFeeDefaults(_ context.Context, head *types.Header, b Backend) error { // Set maxPriorityFeePerGas if it is missing. if args.MaxPriorityFeePerGas == nil { tip, err := b.SuggestGasTipCap(head.BaseFee) diff --git a/ethereum/rpc/filters/api.go b/ethereum/rpc/filters/api.go index 350a5cf1..c1a179b6 100644 --- a/ethereum/rpc/filters/api.go +++ b/ethereum/rpc/filters/api.go @@ -10,7 +10,6 @@ import ( rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/filters" diff --git a/ethereum/rpc/filters/filter_system.go b/ethereum/rpc/filters/filter_system.go index aad0a9e2..6f2cde78 100644 --- a/ethereum/rpc/filters/filter_system.go +++ b/ethereum/rpc/filters/filter_system.go @@ -13,15 +13,13 @@ import ( coretypes "github.com/cometbft/cometbft/rpc/core/types" rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" tmtypes "github.com/cometbft/cometbft/types" - + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/artela-network/artela/ethereum/rpc/pubsub" evmtypes "github.com/artela-network/artela/x/evm/types" ) diff --git a/ethereum/rpc/filters/filters.go b/ethereum/rpc/filters/filters.go index 6f7dc46d..b6409924 100644 --- a/ethereum/rpc/filters/filters.go +++ b/ethereum/rpc/filters/filters.go @@ -9,7 +9,6 @@ import ( "github.com/pkg/errors" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -49,7 +48,7 @@ func NewRangeFilter(logger log.Logger, backend Backend, begin, end int64, addres // Flatten the address and topic filter clauses into a single bloombits filter // system. Since the bloombits are not positional, nil topics are permitted, // which get flattened into a nil byte slice. - var filtersBz [][][]byte //nolint: prealloc + filtersBz := make([][][]byte, 0, len(topics)+1) if len(addresses) > 0 { filter := make([][]byte, len(addresses)) for i, address := range addresses { diff --git a/ethereum/rpc/pubsub/pubsub.go b/ethereum/rpc/pubsub/pubsub.go index c7547acc..745b188e 100644 --- a/ethereum/rpc/pubsub/pubsub.go +++ b/ethereum/rpc/pubsub/pubsub.go @@ -70,7 +70,6 @@ func (m *memEventBus) RemoveTopic(name string) { m.topicsMux.Lock() defer m.topicsMux.Unlock() delete(m.topics, name) - } func (m *memEventBus) Subscribe(name string) (<-chan coretypes.ResultEvent, UnsubscribeFunc, error) { diff --git a/ethereum/rpc/pubsub/pubsub_test.go b/ethereum/rpc/pubsub/pubsub_test.go index 6bdac986..fc816a65 100644 --- a/ethereum/rpc/pubsub/pubsub_test.go +++ b/ethereum/rpc/pubsub/pubsub_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/stretchr/testify/require" + + coretypes "github.com/cometbft/cometbft/rpc/core/types" ) func TestAddTopic(t *testing.T) { diff --git a/ethereum/rpc/service.go b/ethereum/rpc/service.go index 1711e3fb..4b67d7df 100644 --- a/ethereum/rpc/service.go +++ b/ethereum/rpc/service.go @@ -4,32 +4,19 @@ import ( rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" - - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/eth/ethconfig" - "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" "github.com/artela-network/artela/ethereum/rpc/types" ) -// nolint:unused -var defaultEthConfig = ethconfig.Config{ - SyncMode: 0, - FilterLogCacheSize: 0, -} - type ArtelaService struct { clientCtx client.Context wsClient *rpcclient.WSClient cfg *Config stack types.NetworkingStack backend *BackendImpl - // nolint:unused - filterSystem *filters.FilterSystem - logger log.Logger + logger log.Logger } func NewArtelaService( @@ -38,7 +25,6 @@ func NewArtelaService( wsClient *rpcclient.WSClient, cfg *Config, stack types.NetworkingStack, - am *accounts.Manager, logger log.Logger, ) *ArtelaService { art := &ArtelaService{ @@ -53,26 +39,6 @@ func NewArtelaService( return art } -func Accounts(clientCtx client.Context) ([]common.Address, error) { - addresses := make([]common.Address, 0) // return [] instead of nil if empty - - infos, err := clientCtx.Keyring.List() - if err != nil { - return addresses, err - } - - for _, info := range infos { - pubKey, err := info.GetPubKey() - if err != nil { - return nil, err - } - addressBytes := pubKey.Address().Bytes() - addresses = append(addresses, common.BytesToAddress(addressBytes)) - } - - return addresses, nil -} - func (art *ArtelaService) APIs() []rpc.API { return GetAPIs(art.clientCtx, art.wsClient, art.logger, art.backend) } @@ -94,24 +60,5 @@ func (art *ArtelaService) Shutdown() error { // RegisterAPIs register apis and create graphql instance. func (art *ArtelaService) registerAPIs() error { art.stack.RegisterAPIs(art.APIs()) - // art.filterSystem = RegisterFilterAPI(art.stack, art.backend, &defaultEthConfig) - - // create graphql - // if err := graphql.New(art.stack, art.backend, art.filterSystem, []string{"*"}, []string{"*"}); err != nil { - // return err - // } - return nil } - -// func RegisterFilterAPI(stack types.NetworkingStack, backend ethapi.Backend, ethcfg *ethconfig.Config) *filters.FilterSystem { -// isLightClient := ethcfg.SyncMode == downloader.LightSync -// filterSystem := filters.NewFilterSystem(backend, filters.Config{ -// LogCacheSize: ethcfg.FilterLogCacheSize, -// }) -// stack.RegisterAPIs([]rpc.API{{ -// Namespace: "eth", -// Service: filters.NewFilterAPI(filterSystem, isLightClient), -// }}) -// return filterSystem -// } diff --git a/ethereum/rpc/tracing.go b/ethereum/rpc/tracing.go index a74dab78..485b3c62 100644 --- a/ethereum/rpc/tracing.go +++ b/ethereum/rpc/tracing.go @@ -5,14 +5,14 @@ import ( "fmt" "math" + "github.com/pkg/errors" + tmrpcclient "github.com/cometbft/cometbft/rpc/client" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc" - "github.com/pkg/errors" - rpctypes "github.com/artela-network/artela/ethereum/rpc/types" evmtxs "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/txs/support" @@ -133,7 +133,6 @@ func (b *BackendImpl) TraceTransaction(hash common.Hash, config *support.TraceCo } return decodedResult, nil - } // TraceBlock configures a new tracer according to the provided configuration, and diff --git a/ethereum/rpc/tx.go b/ethereum/rpc/tx.go index 94c52b8e..1db030a8 100644 --- a/ethereum/rpc/tx.go +++ b/ethereum/rpc/tx.go @@ -7,25 +7,22 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" - tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" + "github.com/cosmos/cosmos-sdk/client/flags" + sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" - ctypes "github.com/ethereum/go-ethereum/core/types" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rpc" - "github.com/artela-network/artela/ethereum/types" - - "github.com/cosmos/cosmos-sdk/client/flags" - sdktypes "github.com/cosmos/cosmos-sdk/types" - + "github.com/artela-network/artela/common/aspect" "github.com/artela-network/artela/ethereum/rpc/ethapi" rpctypes "github.com/artela-network/artela/ethereum/rpc/types" "github.com/artela-network/artela/ethereum/rpc/utils" + "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/x/evm/txs" evmtypes "github.com/artela-network/artela/x/evm/types" ) @@ -104,6 +101,7 @@ func (b *BackendImpl) GetTransaction(ctx context.Context, txHash common.Hash) (* if !ok { return nil, errors.New("invalid ethereum tx") } + msg.From = res.Sender blockRes, err := b.CosmosBlockResultByNumber(&block.Block.Height) if err != nil { @@ -132,17 +130,22 @@ func (b *BackendImpl) GetTransaction(ctx context.Context, txHash common.Hash) (* b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", blockRes.Height, "error", err) } + cfg, err := b.chainConfig() + if err != nil { + return nil, err + } + return ethapi.NewTransactionFromMsg( msg, common.BytesToHash(block.BlockID.Hash.Bytes()), uint64(res.Height), uint64(res.EthTxIndex), baseFee, - b.ChainConfig(), + cfg, ), nil } -func (b *BackendImpl) GetPoolTransactions() (ctypes.Transactions, error) { +func (b *BackendImpl) GetPoolTransactions() (ethtypes.Transactions, error) { b.logger.Debug("called eth.rpc.backend.GetPoolTransactions") return nil, errors.New("GetPoolTransactions is not implemented") } @@ -162,14 +165,14 @@ func (b *BackendImpl) Stats() (int, int) { } func (b *BackendImpl) TxPoolContent() ( - map[common.Address]ctypes.Transactions, map[common.Address]ctypes.Transactions, + map[common.Address]ethtypes.Transactions, map[common.Address]ethtypes.Transactions, ) { b.logger.Error("TxPoolContent is not implemented") return nil, nil } func (b *BackendImpl) TxPoolContentFrom(addr common.Address) ( - ctypes.Transactions, ctypes.Transactions, + ethtypes.Transactions, ethtypes.Transactions, ) { return nil, nil } @@ -180,12 +183,21 @@ func (b *BackendImpl) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Sub // Version returns the current ethereum protocol version. func (b *BackendImpl) Version() string { - chainID := b.ChainConfig().ChainID - if chainID == nil { + v, _ := b.version() + return v +} + +func (b *BackendImpl) version() (string, error) { + cfg, err := b.chainConfig() + if err != nil { + return "", err + } + + if cfg.ChainID == nil { b.logger.Error("eth.rpc.backend.Version", "ChainID is nil") - return "-1" + return "", errors.New("chain id is not valid") } - return chainID.String() + return cfg.ChainID.String(), nil } func (b *BackendImpl) Engine() consensus.Engine { @@ -250,11 +262,6 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has status = hexutil.Uint(ethtypes.ReceiptStatusSuccessful) } - from, err := b.GetSender(ethMsg, b.chainID) - if err != nil { - return nil, err - } - // parse tx logs from events msgIndex := int(res.MsgIndex) logs, _ := utils.TxLogsFromEvents(blockRes.TxsResults[res.TxIndex].Events, msgIndex) @@ -294,7 +301,7 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has "transactionIndex": hexutil.Uint64(res.EthTxIndex), // sender and receiver (contract or EOA) addreses - "from": from, + "from": res.Sender, "to": txData.GetTo(), "type": hexutil.Uint(ethMsg.AsTransaction().Type()), } @@ -304,8 +311,8 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has } // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation - if txData.GetTo() == nil { - receipt["contractAddress"] = crypto.CreateAddress(from, txData.GetNonce()) + if txData.GetTo() == nil || aspect.IsAspectDeploy(txData.GetTo(), txData.GetData()) { + receipt["contractAddress"] = crypto.CreateAddress(common.HexToAddress(res.Sender), txData.GetNonce()) } if dynamicTx, ok := txData.(*txs.DynamicFeeTx); ok { @@ -343,11 +350,6 @@ func (b *BackendImpl) queryCosmosTxIndexer(query string, txGetter func(*rpctypes return rpctypes.ParseTxIndexerResult(txResult, tx, txGetter) } -// nolint:unused -func (b *BackendImpl) txResult(ctx context.Context, hash common.Hash, prove bool) (*tmrpctypes.ResultTx, error) { - return b.clientCtx.Client.Tx(ctx, hash.Bytes(), prove) -} - // getTransactionByHashPending find pending tx from mempool func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.RPCTransaction, error) { hexTx := txHash.Hex() @@ -365,6 +367,10 @@ func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.R continue } + cfg, err := b.chainConfig() + if err != nil { + return nil, err + } if msg.Hash == hexTx { // use zero block values since it's not included in a block yet rpctx := ethapi.NewTransactionFromMsg( @@ -373,7 +379,7 @@ func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.R uint64(0), uint64(0), nil, - b.ChainConfig(), + cfg, ) return rpctx, nil } diff --git a/ethereum/rpc/types/block.go b/ethereum/rpc/types/block.go index 540b1789..6676e99e 100644 --- a/ethereum/rpc/types/block.go +++ b/ethereum/rpc/types/block.go @@ -9,16 +9,15 @@ import ( "math/big" "strings" - "github.com/artela-network/artela/ethereum/types" - "github.com/spf13/cast" "google.golang.org/grpc/metadata" + grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" - grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + "github.com/artela-network/artela/ethereum/types" ) type Block struct { diff --git a/ethereum/rpc/types/events.go b/ethereum/rpc/types/events.go index 710f560c..69f3577f 100644 --- a/ethereum/rpc/types/events.go +++ b/ethereum/rpc/types/events.go @@ -4,14 +4,13 @@ import ( "fmt" "strconv" - "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/txs" - abci "github.com/cometbft/cometbft/abci/types" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/txs" evmtypes "github.com/artela-network/artela/x/evm/types" ) @@ -54,6 +53,7 @@ type ParsedTx struct { MsgIndex int // the following fields are parsed from events + From common.Address Hash common.Hash // -1 means uninitialized @@ -85,6 +85,7 @@ func ParseTxResult(result *abci.ResponseDeliverTx, tx sdk.Tx) (*ParsedTxs, error p := &ParsedTxs{ TxHashes: make(map[common.Hash]int), } + for _, event := range result.Events { if event.Type != evmtypes.EventTypeEthereumTx { continue @@ -121,6 +122,39 @@ func ParseTxResult(result *abci.ResponseDeliverTx, tx sdk.Tx) (*ParsedTxs, error } } + // loop the second time to update the parsed tx from + for _, event := range result.Events { + if event.Type != sdk.EventTypeMessage { + continue + } + + // filter only the event module message + fromEvmModule := false + for _, attr := range event.Attributes { + if attr.Key == sdk.AttributeKeyModule { + if attr.Value == evmtypes.ModuleName { + fromEvmModule = true + } + } + } + + // ignore non-evm module messages + if !fromEvmModule { + continue + } + + // fill the from address + for _, attr := range event.Attributes { + if attr.Key == sdk.AttributeKeySender { + // update all parsed txs + for i := 0; i < len(p.Txs); i++ { + p.Txs[i].From = common.HexToAddress(attr.Value) + } + break + } + } + } + // some old versions miss some events, fill it with txs result gasUsed := uint64(result.GasUsed) // #nosec G701 if len(p.Txs) == 1 { @@ -153,6 +187,7 @@ func ParseTxIndexerResult(txResult *tmrpctypes.ResultTx, tx sdk.Tx, getter func( } index := uint32(parsedTx.MsgIndex) // #nosec G701 return &types.TxResult{ + Sender: parsedTx.From.Hex(), Height: txResult.Height, TxIndex: txResult.Index, MsgIndex: index, diff --git a/ethereum/rpc/types/query_client.go b/ethereum/rpc/types/query_client.go index d3a6e5e5..09427577 100644 --- a/ethereum/rpc/types/query_client.go +++ b/ethereum/rpc/types/query_client.go @@ -3,15 +3,12 @@ package types import ( "fmt" - "github.com/cosmos/cosmos-sdk/types/tx" - - evmtypes "github.com/artela-network/artela/x/evm/txs" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/proto/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/tx" + evmtypes "github.com/artela-network/artela/x/evm/txs" feetypes "github.com/artela-network/artela/x/fee/types" ) diff --git a/ethereum/rpc/types/utils.go b/ethereum/rpc/types/utils.go index 7cd39998..342cd8e3 100644 --- a/ethereum/rpc/types/utils.go +++ b/ethereum/rpc/types/utils.go @@ -7,22 +7,19 @@ import ( "math/big" "strings" - evmtypes "github.com/artela-network/artela/x/evm/txs" - + errorsmod "cosmossdk.io/errors" abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - - feetypes "github.com/artela-network/artela/x/fee/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + + evmtypes "github.com/artela-network/artela/x/evm/txs" + feetypes "github.com/artela-network/artela/x/fee/types" ) // ExceedBlockGasLimitError defines the error message when txs execution exceeds the block gas limit. @@ -224,7 +221,7 @@ func BaseFeeFromEvents(events []abci.Event) *big.Int { for _, attr := range event.Attributes { if bytes.Equal([]byte(attr.Key), []byte(feetypes.AttributeKeyBaseFee)) { - result, success := new(big.Int).SetString(string(attr.Value), 10) + result, success := new(big.Int).SetString(attr.Value, 10) if success { return result } @@ -251,7 +248,7 @@ func CheckTxFee(gasPrice *big.Int, gas uint64, cap float64) error { // no need to check error from parsing feeFloat, _ := feeEth.Float64() if feeFloat > cap { - return fmt.Errorf("txs fee (%.2f ether) exceeds the configured cap (%.2f ether)", feeFloat, cap) + return fmt.Errorf("txs fee (%.2f art) exceeds the configured cap (%.2f art)", feeFloat, cap) } return nil } diff --git a/ethereum/rpc/websockets.go b/ethereum/rpc/websockets.go index 6285545b..c5e9477b 100644 --- a/ethereum/rpc/websockets.go +++ b/ethereum/rpc/websockets.go @@ -3,6 +3,7 @@ package rpc import ( "bytes" "context" + "encoding/base64" "encoding/json" "fmt" "io" @@ -12,20 +13,19 @@ import ( "strconv" "sync" - "github.com/cosmos/cosmos-sdk/client" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gorilla/mux" "github.com/gorilla/websocket" "github.com/pkg/errors" + rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/filters" - "github.com/ethereum/go-ethereum/rpc" - - rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" - tmtypes "github.com/cometbft/cometbft/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/rpc" rpcfilter "github.com/artela-network/artela/ethereum/rpc/filters" "github.com/artela-network/artela/ethereum/rpc/pubsub" @@ -108,7 +108,7 @@ func (s *websocketsServer) Start() { } if err != nil { - if err == http.ErrServerClosed { + if errors.Is(err, http.ErrServerClosed) { return } @@ -137,7 +137,6 @@ func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { conn: conn, }) s.logger.Info("Success HTTP server for WS ") - } func (s *websocketsServer) sendErrResponse(wsConn *wsConn, msg string) { @@ -260,7 +259,9 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) { } if err := wsConn.WriteJSON(res); err != nil { - break + _ = wsConn.Close() // #nosec G703 + s.logger.Error("error writing subscription response", "error", err) + return } case "eth_unsubscribe": params, ok := s.getParamsAndCheckValid(msg, wsConn) @@ -288,12 +289,15 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) { } if err := wsConn.WriteJSON(res); err != nil { - break + _ = wsConn.Close() // #nosec G703 + s.logger.Error("error writing unsubscribe response", "error", err) + return } default: // otherwise, call the usual rpc server to respond if err := s.tcpGetAndSendResponse(wsConn, mb); err != nil { s.sendErrResponse(wsConn, err.Error()) + s.logger.Error("error sending response", "error", err) } } } @@ -426,7 +430,17 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un for _, attr := range et.Attributes { if attr.Key == evmtypes.AttributeKeyEthereumBloom { - bloom = ethtypes.BytesToBloom([]byte(attr.Value)) + encodedBloom, deCodeErr := base64.StdEncoding.DecodeString(attr.Value) + + sprintf := fmt.Sprintf("subscribeNewHeads event %d bloom %s header %d, ", len(bloom.Bytes()), attr.Value, data.Header.Height) + api.logger.Info(sprintf) + + if len(encodedBloom) != 256 { + continue + } + if deCodeErr == nil { + bloom = ethtypes.BytesToBloom(encodedBloom) + } } } } @@ -469,7 +483,7 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un api.logger.Error("error writing header, will drop peer", "error", err.Error()) try(func() { - if err != websocket.ErrCloseSent { + if !errors.Is(websocket.ErrCloseSent, err) { _ = wsConn.Close() // #nosec G703 } }, api.logger, "closing websocket peer sub") @@ -523,10 +537,6 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac return nil, err } - if ok { - crit.Addresses = []common.Address{common.HexToAddress(address)} - } - if isSlice { crit.Addresses = []common.Address{} for _, addr := range addresses { @@ -539,6 +549,8 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac crit.Addresses = append(crit.Addresses, common.HexToAddress(address)) } + } else { + crit.Addresses = []common.Address{common.HexToAddress(address)} } } @@ -649,7 +661,7 @@ func (api *pubSubAPI) subscribeLogs(wsConn *wsConn, subID rpc.ID, extra interfac err = wsConn.WriteJSON(res) if err != nil { try(func() { - if err != websocket.ErrCloseSent { + if !errors.Is(websocket.ErrCloseSent, err) { _ = wsConn.Close() // #nosec G703 } }, api.logger, "closing websocket peer sub") @@ -707,7 +719,7 @@ func (api *pubSubAPI) subscribePendingTransactions(wsConn *wsConn, subID rpc.ID) api.logger.Debug("error writing header, will drop peer", "error", err.Error()) try(func() { - if err != websocket.ErrCloseSent { + if !errors.Is(websocket.ErrCloseSent, err) { _ = wsConn.Close() // #nosec G703 } }, api.logger, "closing websocket peer sub") diff --git a/ethereum/server/config/config.go b/ethereum/server/config/config.go index 6516aff0..298eec06 100644 --- a/ethereum/server/config/config.go +++ b/ethereum/server/config/config.go @@ -8,9 +8,8 @@ import ( "github.com/spf13/viper" - "github.com/cometbft/cometbft/libs/strings" - errorsmod "cosmossdk.io/errors" + "github.com/cometbft/cometbft/libs/strings" clientflags "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server/config" pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" @@ -301,11 +300,11 @@ func DefaultAspectConfig() *AspectConfig { // Validate returns an error if the tracer type is invalid. func (a AspectConfig) Validate() error { if a.ApplyPoolSize < 0 { - return errors.New("Aspect apply-pool-size cannot be negative") + return errors.New("aspect apply-pool-size cannot be negative") } if a.QueryPoolSize < 0 { - return errors.New("Aspect query-pool-size cannot be negative") + return errors.New("aspect query-pool-size cannot be negative") } return nil diff --git a/ethereum/server/flags/flags.go b/ethereum/server/flags/flags.go index ecf121f8..0069e57c 100644 --- a/ethereum/server/flags/flags.go +++ b/ethereum/server/flags/flags.go @@ -1,10 +1,11 @@ package flags import ( - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/spf13/cobra" "github.com/spf13/viper" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" ) // Tendermint/cosmos-sdk full-node start flags diff --git a/ethereum/server/start.go b/ethereum/server/start.go index 384a89e9..5895a39f 100644 --- a/ethereum/server/start.go +++ b/ethereum/server/start.go @@ -11,10 +11,12 @@ import ( "runtime/pprof" "time" - "github.com/artela-network/artela/ethereum/rpc" - "github.com/artela-network/artela/ethereum/server/config" - artelaflag "github.com/artela-network/artela/ethereum/server/flags" + "github.com/spf13/cobra" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "cosmossdk.io/tools/rosetta" + crgserver "cosmossdk.io/tools/rosetta/lib/server" "github.com/cometbft/cometbft/abci/server" tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" "github.com/cometbft/cometbft/node" @@ -22,12 +24,6 @@ import ( pvm "github.com/cometbft/cometbft/privval" "github.com/cometbft/cometbft/proxy" "github.com/cometbft/cometbft/rpc/client/local" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "cosmossdk.io/tools/rosetta" - crgserver "cosmossdk.io/tools/rosetta/lib/server" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" @@ -41,6 +37,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" + "github.com/artela-network/artela/ethereum/rpc" + "github.com/artela-network/artela/ethereum/server/config" + artelaflag "github.com/artela-network/artela/ethereum/server/flags" aspecttypes "github.com/artela-network/aspect-core/types" ) @@ -59,14 +58,15 @@ const ( FlagTrace = "trace" FlagInvCheckPeriod = "inv-check-period" - FlagPruning = "pruning" - FlagPruningKeepRecent = "pruning-keep-recent" - FlagPruningInterval = "pruning-interval" - FlagIndexEvents = "index-events" - FlagMinRetainBlocks = "min-retain-blocks" - FlagIAVLCacheSize = "iavl-cache-size" - FlagDisableIAVLFastNode = "iavl-disable-fastnode" - FlagIAVLLazyLoading = "iavl-lazy-loading" + FlagPruning = "pruning" + FlagPruningKeepRecent = "pruning-keep-recent" + FlagPruningInterval = "pruning-interval" + FlagIndexEvents = "index-events" + FlagMinRetainBlocks = "min-retain-blocks" + FlagIAVLCacheSize = "iavl-cache-size" + FlagDisableIAVLFastNode = "iavl-disable-fastnode" + FlagIAVLLazyLoading = "iavl-lazy-loading" + FlagForceCompactInterval = "force-compact-interval" // states sync-related flags FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" diff --git a/ethereum/server/util.go b/ethereum/server/util.go index 38918311..77441d6e 100644 --- a/ethereum/server/util.go +++ b/ethereum/server/util.go @@ -11,17 +11,14 @@ import ( "github.com/spf13/cobra" - "github.com/ethereum/go-ethereum/accounts" - ethlog "github.com/ethereum/go-ethereum/log" - dbm "github.com/cometbft/cometbft-db" tmcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/server" sdkserver "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/version" + ethlog "github.com/ethereum/go-ethereum/log" ethrpc "github.com/artela-network/artela/ethereum/rpc" "github.com/artela-network/artela/ethereum/server/config" @@ -58,7 +55,7 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type } // CreateJSONRPC starts the JSON-RPC server -func CreateJSONRPC(ctx *server.Context, +func CreateJSONRPC(ctx *sdkserver.Context, clientCtx client.Context, tmRPCAddr, tmEndpoint string, @@ -105,8 +102,7 @@ func CreateJSONRPC(ctx *server.Context, wsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) - am := accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: false}) - serv := ethrpc.NewArtelaService(ctx, clientCtx, wsClient, cfg, stack, am, nodeCfg.Logger) + serv := ethrpc.NewArtelaService(ctx, clientCtx, wsClient, cfg, stack, nodeCfg.Logger) // allocate separate WS connection to Tendermint tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) diff --git a/ethereum/types/account.go b/ethereum/types/account.go index 1844b909..4fbfccd4 100644 --- a/ethereum/types/account.go +++ b/ethereum/types/account.go @@ -5,7 +5,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" ) diff --git a/ethereum/types/coin.go b/ethereum/types/coin.go index 53c103c5..330a95e4 100644 --- a/ethereum/types/coin.go +++ b/ethereum/types/coin.go @@ -4,7 +4,6 @@ import ( "math/big" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/ethereum/types/indexer.pb.go b/ethereum/types/indexer.pb.go index 1e9819c5..5e3d3255 100644 --- a/ethereum/types/indexer.pb.go +++ b/ethereum/types/indexer.pb.go @@ -1,4 +1,4 @@ -// Code support by protoc-gen-gogo. DO NOT EDIT. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: artela/types/v1/indexer.proto package types @@ -17,31 +17,32 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -// This is a compile-time assertion to ensure that this support file +// This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// TxResult is the value stored in eth txs indexer +// TxResult is the value stored in eth tx indexer type TxResult struct { // height of the blockchain Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - // tx_index of the cosmos txs + // tx_index of the cosmos transaction TxIndex uint32 `protobuf:"varint,2,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` - // msg_index in a batch txs + // msg_index in a batch transaction MsgIndex uint32 `protobuf:"varint,3,opt,name=msg_index,json=msgIndex,proto3" json:"msg_index,omitempty"` - // eth_tx_index is the index in the list of valid eth txs in the block, - // aka. the txs list returned by eth_getBlock api. + // eth_tx_index is the index in the list of valid eth tx in the block, + // aka. the transaction list returned by eth_getBlock api. EthTxIndex int32 `protobuf:"varint,4,opt,name=eth_tx_index,json=ethTxIndex,proto3" json:"eth_tx_index,omitempty"` - // failed is true if the eth txs did not go succeed + // failed is true if the eth transaction did not go succeed Failed bool `protobuf:"varint,5,opt,name=failed,proto3" json:"failed,omitempty"` - // gas_used by the txs. If it exceeds the block gas limit, + // gas_used by the transaction. If it exceeds the block gas limit, // it's set to gas limit, which is what's actually deducted by ante handler. GasUsed uint64 `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` // cumulative_gas_used specifies the cumulated amount of gas used for all - // processed messages within the current batch txs. + // processed messages within the current batch transaction. CumulativeGasUsed uint64 `protobuf:"varint,7,opt,name=cumulative_gas_used,json=cumulativeGasUsed,proto3" json:"cumulative_gas_used,omitempty"` + Sender string `protobuf:"bytes,8,opt,name=sender,proto3" json:"sender,omitempty"` } func (m *TxResult) Reset() { *m = TxResult{} } @@ -84,26 +85,27 @@ func init() { func init() { proto.RegisterFile("artela/types/v1/indexer.proto", fileDescriptor_ee5a8796d27044a7) } var fileDescriptor_ee5a8796d27044a7 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xb1, 0x4e, 0xf3, 0x30, - 0x14, 0x85, 0xe3, 0xbf, 0x6d, 0x9a, 0xdf, 0x02, 0x21, 0x02, 0xaa, 0x02, 0x88, 0x60, 0x31, 0x85, - 0x81, 0x44, 0x15, 0x1b, 0x23, 0x0c, 0x88, 0xd5, 0x2a, 0x0b, 0x4b, 0xe4, 0x36, 0x17, 0x27, 0x22, - 0xa9, 0xab, 0xf8, 0xa6, 0x84, 0x37, 0x60, 0xe4, 0x11, 0x78, 0x1c, 0xc6, 0x8e, 0x8c, 0xa8, 0x15, - 0xef, 0x81, 0xe2, 0x44, 0x65, 0xf3, 0xd1, 0x77, 0x8e, 0xaf, 0xf4, 0xd1, 0x53, 0x51, 0x22, 0xe4, - 0x22, 0xc2, 0xd7, 0x05, 0xe8, 0x68, 0x39, 0x8e, 0xb2, 0x79, 0x02, 0x35, 0x94, 0xe1, 0xa2, 0x54, - 0xa8, 0xdc, 0xbd, 0x16, 0x87, 0x06, 0x87, 0xcb, 0xf1, 0xf1, 0xa1, 0x54, 0x52, 0x19, 0x16, 0x35, - 0xaf, 0xb6, 0x76, 0xfe, 0x43, 0xa8, 0x33, 0xa9, 0x39, 0xe8, 0x2a, 0x47, 0x77, 0x44, 0xed, 0x14, - 0x32, 0x99, 0xa2, 0x47, 0x18, 0x09, 0x7a, 0xbc, 0x4b, 0xee, 0x11, 0x75, 0xb0, 0x8e, 0xcd, 0xff, - 0xde, 0x3f, 0x46, 0x82, 0x5d, 0x3e, 0xc4, 0xfa, 0xbe, 0x89, 0xee, 0x09, 0xfd, 0x5f, 0x68, 0xd9, - 0xb1, 0x9e, 0x61, 0x4e, 0xa1, 0x65, 0x0b, 0x19, 0xdd, 0x01, 0x4c, 0xe3, 0xed, 0xb6, 0xcf, 0x48, - 0x30, 0xe0, 0x14, 0x30, 0x9d, 0x74, 0xf3, 0x11, 0xb5, 0x9f, 0x44, 0x96, 0x43, 0xe2, 0x0d, 0x18, - 0x09, 0x1c, 0xde, 0xa5, 0xe6, 0xa2, 0x14, 0x3a, 0xae, 0x34, 0x24, 0x9e, 0xcd, 0x48, 0xd0, 0xe7, - 0x43, 0x29, 0xf4, 0x83, 0x86, 0xc4, 0x0d, 0xe9, 0xc1, 0xac, 0x2a, 0xaa, 0x5c, 0x60, 0xb6, 0x84, - 0x78, 0xdb, 0x1a, 0x9a, 0xd6, 0xfe, 0x1f, 0xba, 0x6b, 0xfb, 0xd7, 0xfd, 0xb7, 0x8f, 0x33, 0xeb, - 0xe6, 0xf6, 0x73, 0xed, 0x93, 0xd5, 0xda, 0x27, 0xdf, 0x6b, 0x9f, 0xbc, 0x6f, 0x7c, 0x6b, 0xb5, - 0xf1, 0xad, 0xaf, 0x8d, 0x6f, 0x3d, 0x5e, 0xc8, 0x0c, 0xd3, 0x6a, 0x1a, 0xce, 0x54, 0x11, 0xb5, - 0xce, 0x2e, 0xe7, 0x80, 0x2f, 0xaa, 0x7c, 0xee, 0x62, 0xe3, 0xd6, 0x58, 0x9c, 0xda, 0xc6, 0xd9, - 0xd5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0xb8, 0x29, 0x39, 0x7b, 0x01, 0x00, 0x00, + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0x31, 0x4f, 0x83, 0x40, + 0x18, 0x86, 0x39, 0xdb, 0x52, 0x7a, 0xd1, 0x18, 0xd1, 0x34, 0xa8, 0x11, 0x2f, 0x4e, 0x38, 0x08, + 0x69, 0xdc, 0x1c, 0x75, 0x30, 0xae, 0x97, 0xba, 0xb8, 0x10, 0x5a, 0x3e, 0x0f, 0x22, 0x94, 0x86, + 0xfb, 0xa8, 0xf8, 0x0f, 0x1c, 0xfd, 0x09, 0xfe, 0x1c, 0xc7, 0x8e, 0x8e, 0xa6, 0xfc, 0x0e, 0x13, + 0xc3, 0x71, 0xa9, 0xdb, 0x3d, 0x79, 0xde, 0xf7, 0xbe, 0xe4, 0xa5, 0x67, 0x51, 0x89, 0x90, 0x45, + 0x01, 0xbe, 0x2d, 0x41, 0x06, 0xab, 0x49, 0x90, 0x2e, 0x62, 0xa8, 0xa1, 0xf4, 0x97, 0x65, 0x81, + 0x85, 0xbd, 0xdf, 0x69, 0x5f, 0x69, 0x7f, 0x35, 0x39, 0x39, 0x12, 0x85, 0x28, 0x94, 0x0b, 0xda, + 0x57, 0x17, 0xbb, 0xf8, 0x25, 0xd4, 0x9a, 0xd6, 0x1c, 0x64, 0x95, 0xa1, 0x3d, 0xa6, 0x66, 0x02, + 0xa9, 0x48, 0xd0, 0x21, 0x8c, 0x78, 0x3d, 0xae, 0xc9, 0x3e, 0xa6, 0x16, 0xd6, 0xa1, 0xfa, 0xdf, + 0xd9, 0x61, 0xc4, 0xdb, 0xe3, 0x43, 0xac, 0x1f, 0x5a, 0xb4, 0x4f, 0xe9, 0x28, 0x97, 0x42, 0xbb, + 0x9e, 0x72, 0x56, 0x2e, 0x45, 0x27, 0x19, 0xdd, 0x05, 0x4c, 0xc2, 0x6d, 0xb7, 0xcf, 0x88, 0x37, + 0xe0, 0x14, 0x30, 0x99, 0xea, 0xfa, 0x98, 0x9a, 0xcf, 0x51, 0x9a, 0x41, 0xec, 0x0c, 0x18, 0xf1, + 0x2c, 0xae, 0xa9, 0xbd, 0x28, 0x22, 0x19, 0x56, 0x12, 0x62, 0xc7, 0x64, 0xc4, 0xeb, 0xf3, 0xa1, + 0x88, 0xe4, 0xa3, 0x84, 0xd8, 0xf6, 0xe9, 0xe1, 0xbc, 0xca, 0xab, 0x2c, 0xc2, 0x74, 0x05, 0xe1, + 0x36, 0x35, 0x54, 0xa9, 0x83, 0x7f, 0x75, 0xaf, 0xf3, 0x63, 0x6a, 0x4a, 0x58, 0xc4, 0x50, 0x3a, + 0x16, 0x23, 0xde, 0x88, 0x6b, 0xba, 0xe9, 0xbf, 0x7f, 0x9e, 0x1b, 0xb7, 0x77, 0x5f, 0x1b, 0x97, + 0xac, 0x37, 0x2e, 0xf9, 0xd9, 0xb8, 0xe4, 0xa3, 0x71, 0x8d, 0x75, 0xe3, 0x1a, 0xdf, 0x8d, 0x6b, + 0x3c, 0x5d, 0x8a, 0x14, 0x93, 0x6a, 0xe6, 0xcf, 0x8b, 0x3c, 0xe8, 0xb6, 0xbc, 0x5a, 0x00, 0xbe, + 0x16, 0xe5, 0x8b, 0xc6, 0x76, 0x73, 0xb5, 0xee, 0xcc, 0x54, 0x5b, 0x5e, 0xff, 0x05, 0x00, 0x00, + 0xff, 0xff, 0x59, 0x23, 0x88, 0x06, 0x93, 0x01, 0x00, 0x00, } func (m *TxResult) Marshal() (dAtA []byte, err error) { @@ -126,6 +128,13 @@ func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintIndexer(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x42 + } if m.CumulativeGasUsed != 0 { i = encodeVarintIndexer(dAtA, i, uint64(m.CumulativeGasUsed)) i-- @@ -207,6 +216,10 @@ func (m *TxResult) Size() (n int) { if m.CumulativeGasUsed != 0 { n += 1 + sovIndexer(uint64(m.CumulativeGasUsed)) } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovIndexer(uint64(l)) + } return n } @@ -379,6 +392,38 @@ func (m *TxResult) Unmarshal(dAtA []byte) error { break } } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIndexer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthIndexer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIndexer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipIndexer(dAtA[iNdEx:]) diff --git a/ethereum/utils/utils.go b/ethereum/utils/utils.go index dd6cdbed..20a1da5e 100644 --- a/ethereum/utils/utils.go +++ b/ethereum/utils/utils.go @@ -5,19 +5,18 @@ import ( "math/big" "strings" - "github.com/artela-network/aspect-core/djpm" - "github.com/ethereum/go-ethereum/common" - ethereum "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" + ethereum "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/aspect-core/djpm" ) const ( @@ -123,15 +122,11 @@ func IsCustomizedVerification(tx *ethereum.Transaction) bool { } // check prefix - if bytes.Compare(data[:4], djpm.CustomVerificationPrefix) != 0 { + if !bytes.Equal(data[:4], djpm.CustomVerificationPrefix) { return false } // compute checksum and check dataHash := crypto.Keccak256(data[8:]) - if bytes.Compare(data[4:8], dataHash[:4]) != 0 { - return false - } - - return true + return bytes.Equal(data[4:8], dataHash[:4]) } diff --git a/go.mod b/go.mod index 0f1285df..7978c4cc 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,10 @@ require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/math v1.0.1 github.com/BurntSushi/toml v1.2.1 - github.com/artela-network/artela-evm v0.4.7-rc7 - github.com/artela-network/aspect-core v0.4.7-rc7-1 + github.com/andybalholm/brotli v1.1.0 + github.com/artela-network/artela-evm v0.4.8-rc8 + github.com/artela-network/aspect-core v0.4.8-rc8 + github.com/artela-network/aspect-runtime v0.4.8-rc8 github.com/btcsuite/btcd/btcutil v1.1.2 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 @@ -23,7 +25,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/json-iterator/go v1.1.12 github.com/pkg/errors v0.9.1 - github.com/spf13/cast v1.5.0 + github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -36,13 +38,12 @@ require ( require ( github.com/DataDog/zstd v1.5.5 // indirect - github.com/artela-network/aspect-runtime v0.4.7-rc7 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/bytecodealliance/wasmtime-go/v20 v20.0.0 // indirect - github.com/cockroachdb/errors v1.9.1 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect @@ -55,6 +56,7 @@ require ( github.com/hashicorp/go-bexpr v0.1.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/linxGnu/grocksdb v1.8.12 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -91,7 +93,6 @@ require ( github.com/btcsuite/btcd v0.23.0 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/cenkalti/backoff/v4 v4.1.3 // indirect - github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect @@ -109,10 +110,6 @@ require ( github.com/davecgh/go-spew v1.1.1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect @@ -124,7 +121,6 @@ require ( github.com/go-stack/stack v1.8.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect - github.com/golang/glog v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect @@ -156,7 +152,6 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect @@ -192,7 +187,6 @@ require ( github.com/status-im/keycard-go v0.2.0 github.com/subosito/gotenv v1.4.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/tidwall/match v1.1.1 // indirect @@ -203,14 +197,13 @@ require ( github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect - go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df golang.org/x/net v0.12.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.10.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect @@ -226,9 +219,11 @@ require ( ) replace ( - github.com/artela-network/aspect-runtime => github.com/artela-network/aspect-runtime v0.4.7-rc7-fix-execution github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.22.3 // TODO artela: btcd/btcec become not valid for 0.23.x, need to dig into it - github.com/bytecodealliance/wasmtime-go/v20 => github.com/artela-network/wasmtime-go/v20 v20.0.2 - github.com/cosmos/cosmos-sdk => github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc-7-1 + github.com/bytecodealliance/wasmtime-go/v20 => github.com/artela-network/wasmtime-go/v20 v20.0.3 + github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b + github.com/cometbft/cometbft-db => github.com/artela-network/cosmos-db v1.0.2-048-rc8 + github.com/cosmos/cosmos-sdk => github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc8 + github.com/cosmos/iavl => github.com/artela-network/iavl v0.20.0-048-rc8 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 4e597a3d..3e7b2bef 100644 --- a/go.sum +++ b/go.sum @@ -208,7 +208,6 @@ github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMb github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -216,18 +215,13 @@ github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= @@ -239,7 +233,6 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/ github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -248,25 +241,30 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc-7-1 h1:PpGpkm6xxG/n5D9234d+HZxQRm0XdZCrB5lIPZk1sM0= -github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc-7-1/go.mod h1:vCwxnQmF5xn8DieUZdGT2qb0hEbsLNbX4Zscl03MEOc= -github.com/artela-network/artela-evm v0.4.7-rc7 h1:6BbpLmZZQQDIqtU9KIK0yKCovZKag4TzN4gvjGxlgb4= -github.com/artela-network/artela-evm v0.4.7-rc7/go.mod h1:kRZPmabNVQ+qwtC75qG/JxUTO/bekgAvfvURI8ObcOY= -github.com/artela-network/aspect-core v0.4.7-rc7-1 h1:jH3NcHfjcWJ3BZqVwHag3CWZwF3EeuR0zTHNOry8kJI= -github.com/artela-network/aspect-core v0.4.7-rc7-1/go.mod h1:C/aJERYZ2O3yxAuP6I4gg0I/R3efZSIDt64PMw50Uwo= -github.com/artela-network/aspect-runtime v0.4.7-rc7-fix-execution h1:CUnw7f36L2aDG15acx77Bys+INaOSwe1Q+QcB+nFQV0= -github.com/artela-network/aspect-runtime v0.4.7-rc7-fix-execution/go.mod h1:eiBT6JkElkgJNRgRXTOJu/bVS3br+GoqMDv6Gn4a0cU= -github.com/artela-network/wasmtime-go/v20 v20.0.2 h1:miyLlk3+w+5b2LdI0sMpzHiUOFv4O+MzaZjQIg0vqW8= -github.com/artela-network/wasmtime-go/v20 v20.0.2/go.mod h1:Va362hmt7aqwyb2Vu73yHbmx6NkSvGmvHOzJa2xMECQ= +github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc8 h1:O5/yuEheEYS36afw6gP1Fp6JfAz1M+XKUdChKynd7uA= +github.com/artela-network/artela-cosmos-sdk v0.47.4-artela-rc8/go.mod h1:fyykf4Hf4k3QoVBCSnnsULuDRwwfXpLDi90s0PriD4M= +github.com/artela-network/artela-evm v0.4.8-rc8 h1:4saDqBKnVmaEvSBEveVwRi/vnXVERz5YvRXr3gAzB3E= +github.com/artela-network/artela-evm v0.4.8-rc8/go.mod h1:eYeoqd8pOAX/HcKVKnqxqwJki0qyIoQwSGgYTyFZQ/M= +github.com/artela-network/aspect-core v0.4.8-rc8 h1:7KSb/NcD3HhOTirVg7mVPmknxSO1xQooNjPHe4bryZc= +github.com/artela-network/aspect-core v0.4.8-rc8/go.mod h1:hve/4ibuIgt0HaAQrBYez1O8BQGceK8O8rGeyHoMAwg= +github.com/artela-network/aspect-runtime v0.4.8-rc8 h1:48dbWs+4wUAL52U6JUN+hPQ7u7lDTkajoI0EcZYtwL4= +github.com/artela-network/aspect-runtime v0.4.8-rc8/go.mod h1:GiDB2+LUbl2b2Z8+v/83LFbUKs5DqQ3ACxLUWY8zMdU= +github.com/artela-network/cosmos-db v1.0.2-048-rc8 h1:pAC/94oLbFVE8sTP3szkliTJcR9EKtHibRI7BQliEKA= +github.com/artela-network/cosmos-db v1.0.2-048-rc8/go.mod h1:CIRaQk50vLgSKYhzkucNtxfFokZqOxOJL10BNL4YUqc= +github.com/artela-network/iavl v0.20.0-048-rc8 h1:x6j9F0cu3kD95JaG2ZNRuzgOiRe2nebt55C+eIQjOQ0= +github.com/artela-network/iavl v0.20.0-048-rc8/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= +github.com/artela-network/wasmtime-go/v20 v20.0.3 h1:A4/KrrCQiXhDibc3bUlvD7vzohV4saWiAA3MIFz11Yo= +github.com/artela-network/wasmtime-go/v20 v20.0.3/go.mod h1:Va362hmt7aqwyb2Vu73yHbmx6NkSvGmvHOzJa2xMECQ= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -274,7 +272,6 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U= github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -311,7 +308,6 @@ github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8 github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -343,31 +339,23 @@ github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b80 github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b h1:LCs8gDhg6vt8A3dN7AEJxmCoETZ4qkySoVJVm3rcSJk= github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b/go.mod h1:TkdVsGYRqtULUppt2RbC+YaKtTHnHoWa2apfFrSKABw= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= 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/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= 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.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= -github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= -github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -384,8 +372,6 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= -github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ibc-go/v7 v7.1.0 h1:SCLgs7tqVnzdIDO5MRLgovAnc696vTTKl+8qsTu8IMM= github.com/cosmos/ibc-go/v7 v7.1.0/go.mod h1:7MptlWeIyqmDiuJeRAFqBvXKY8Hybd+rF8vMSmGd2zg= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= @@ -394,7 +380,6 @@ github.com/cosmos/ledger-cosmos-go v0.12.1 h1:sMBxza5p/rNK/06nBSNmsI/WDqI0pVJFVN github.com/cosmos/ledger-cosmos-go v0.12.1/go.mod h1:dhO6kj+Y+AHIOgAe4L9HL/6NDdyyth4q238I9yFpD2g= 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.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -419,29 +404,16 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2U github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= -github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -455,15 +427,9 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= @@ -472,26 +438,20 @@ github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4= github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -508,7 +468,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -535,7 +494,6 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -546,13 +504,9 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -594,7 +548,6 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= @@ -615,7 +568,6 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8 github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -748,10 +700,8 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= -github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -759,11 +709,6 @@ github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= -github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -773,8 +718,6 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= -github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= @@ -790,32 +733,21 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= -github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= -github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= -github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= -github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -823,8 +755,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= @@ -833,24 +763,19 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/linxGnu/grocksdb v1.8.12 h1:1/pCztQUOa3BX/1gR3jSZDoaKFpeHFvQ1XrqZpSvZVo= +github.com/linxGnu/grocksdb v1.8.12/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -860,12 +785,9 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= @@ -895,7 +817,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -919,7 +840,6 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= @@ -946,7 +866,6 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -956,7 +875,6 @@ github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7c github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1008,8 +926,6 @@ github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGn github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= @@ -1019,18 +935,14 @@ github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= -github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -1044,26 +956,18 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= @@ -1091,8 +995,6 @@ github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= @@ -1113,10 +1015,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1126,23 +1026,9 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1154,8 +1040,6 @@ github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= -go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1179,19 +1063,16 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1209,8 +1090,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= -golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1237,7 +1118,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1250,7 +1131,6 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -1260,7 +1140,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1289,7 +1168,6 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1356,10 +1234,8 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1367,9 +1243,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1413,7 +1287,6 @@ golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1428,7 +1301,6 @@ golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1449,11 +1321,10 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1476,19 +1347,16 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1612,7 +1480,6 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1727,7 +1594,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 h1: google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1800,12 +1666,8 @@ gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= @@ -1824,7 +1686,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/init.sh b/init.sh index 837d4e4b..6f6f069b 100755 --- a/init.sh +++ b/init.sh @@ -23,7 +23,19 @@ command -v jq >/dev/null 2>&1 || { } # remove existing daemon and client -rm -rf ~/.artelad* +folder_path="$HOME/.artelad" +echo folder_path +if [ -d "$folder_path" ]; then + read -p "Are you sure you want to delete the folder '$folder_path' ? (y/n): " confirm + + if [ "$confirm" == "y" ]; then + rm -rf "$folder_path" + echo "The folder has been deleted." + else + echo "Operation canceled." + exit 1 + fi +fi echo artelad config keyring-backend $KEYRING artelad config keyring-backend $KEYRING @@ -44,6 +56,7 @@ artelad init $MONIKER --chain-id $CHAINID cat $HOME/.artelad/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="uart"' >$HOME/.artelad/config/tmp_genesis.json && mv $HOME/.artelad/config/tmp_genesis.json $HOME/.artelad/config/genesis.json cat $HOME/.artelad/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="uart"' >$HOME/.artelad/config/tmp_genesis.json && mv $HOME/.artelad/config/tmp_genesis.json $HOME/.artelad/config/genesis.json cat $HOME/.artelad/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="uart"' >$HOME/.artelad/config/tmp_genesis.json && mv $HOME/.artelad/config/tmp_genesis.json $HOME/.artelad/config/genesis.json +cat $HOME/.artelad/config/genesis.json | jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="uart"' >$HOME/.artelad/config/tmp_genesis.json && mv $HOME/.artelad/config/tmp_genesis.json $HOME/.artelad/config/genesis.json cat $HOME/.artelad/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="uart"' >$HOME/.artelad/config/tmp_genesis.json && mv $HOME/.artelad/config/tmp_genesis.json $HOME/.artelad/config/genesis.json # Set gas limit in genesis @@ -103,6 +116,9 @@ else # set snapshot options sed -i 's/snapshot-interval = 0/snapshot-interval = 2000/g' $HOME/.artelad/config/app.toml + sed -i 's/enable = false/enable = true/g' $HOME/.artelad/config/app.toml + sed -i 's/prometheus = false/prometheus = true/' $HOME/.artelad/config/config.toml + sed -i 's/timeout_commit = "5s"/timeout_commit = "500ms"/' $HOME/.artelad/config/config.toml fi if [[ $1 == "pending" ]]; then diff --git a/proto/artela/types/v1/indexer.proto b/proto/artela/types/v1/indexer.proto index 7e74556c..b5399064 100644 --- a/proto/artela/types/v1/indexer.proto +++ b/proto/artela/types/v1/indexer.proto @@ -28,4 +28,6 @@ message TxResult { // cumulative_gas_used specifies the cumulated amount of gas used for all // processed messages within the current batch transaction. uint64 cumulative_gas_used = 7; + + string sender = 8; } diff --git a/testutil/network/network.go b/testutil/network/network.go index fd2ae6c3..ddac271a 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -15,10 +15,8 @@ import ( "testing" "time" - "github.com/artela-network/artela/ethereum/rpc" - "github.com/artela-network/artela/ethereum/server/config" - "github.com/artela-network/artela/ethereum/types" - evmtypes "github.com/artela-network/artela/x/evm/txs" + "github.com/spf13/cobra" + "google.golang.org/grpc" "cosmossdk.io/math" dbm "github.com/cometbft/cometbft-db" @@ -28,11 +26,6 @@ import ( tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cometbft/cometbft/node" tmclient "github.com/cometbft/cometbft/rpc/client" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" @@ -45,10 +38,6 @@ import ( srvconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" - - "github.com/artela-network/artela/app" - "github.com/artela-network/artela/app/params" - "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -56,9 +45,17 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/artela-network/artela/app" + "github.com/artela-network/artela/app/params" "github.com/artela-network/artela/ethereum/crypto/hd" artelakeyring "github.com/artela-network/artela/ethereum/crypto/keyring" + "github.com/artela-network/artela/ethereum/rpc" + "github.com/artela-network/artela/ethereum/server/config" + "github.com/artela-network/artela/ethereum/types" + evmtypes "github.com/artela-network/artela/x/evm/txs" ) // package-wide network lock to only allow one test network at a time @@ -186,8 +183,6 @@ type ( jsonrpcDone chan struct{} artelaService *rpc.ArtelaService - // nolint:unused - artelaServiceDone chan struct{} } ) diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go index 85ae07b3..9845d31d 100644 --- a/testutil/network/network_test.go +++ b/testutil/network/network_test.go @@ -8,14 +8,12 @@ import ( "testing" "time" - "github.com/artela-network/artela/ethereum/server/config" - "github.com/stretchr/testify/suite" "github.com/ethereum/go-ethereum/ethclient" + "github.com/artela-network/artela/ethereum/server/config" "github.com/artela-network/artela/testutil/network" - artelanetwork "github.com/artela-network/artela/testutil/network" ) diff --git a/testutil/network/util.go b/testutil/network/util.go index b030e585..c3951069 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -6,9 +6,6 @@ import ( "strings" "time" - rpc2 "github.com/artela-network/artela/ethereum/rpc" - "github.com/artela-network/artela/x/evm/txs/support" - tmos "github.com/cometbft/cometbft/libs/os" "github.com/cometbft/cometbft/node" "github.com/cometbft/cometbft/p2p" @@ -17,9 +14,6 @@ import ( "github.com/cometbft/cometbft/rpc/client/local" "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" - "github.com/ethereum/go-ethereum/accounts" - "github.com/ethereum/go-ethereum/log" - "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" srvtypes "github.com/cosmos/cosmos-sdk/server/types" @@ -31,7 +25,10 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/log" + rpc2 "github.com/artela-network/artela/ethereum/rpc" + "github.com/artela-network/artela/x/evm/txs/support" evmtypes "github.com/artela-network/artela/x/evm/types" ) @@ -162,7 +159,7 @@ func startInProcess(cfg Config, val *Validator) error { panic(err) } - val.artelaService = rpc2.NewArtelaService(val.Ctx, val.ClientCtx, nil, cfg, node, accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: false}), log.Root()) + val.artelaService = rpc2.NewArtelaService(val.Ctx, val.ClientCtx, nil, cfg, node, log.Root()) startErr := val.artelaService.Start() if startErr != nil { return startErr @@ -234,18 +231,9 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance var govGenState govv1.GenesisState cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[govtypes.ModuleName], &govGenState) - // nolint:staticcheck - govGenState.DepositParams.MinDeposit[0].Denom = cfg.BondDenom + govGenState.Params.MinDeposit[0].Denom = cfg.BondDenom cfg.GenesisState[govtypes.ModuleName] = cfg.Codec.MustMarshalJSON(&govGenState) - /* TODO artela - var inflationGenState inflationtypes.GenesisState - cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[inflationtypes.ModuleName], &inflationGenState) - - inflationGenState.Params.MintDenom = cfg.BondDenom - cfg.GenesisState[inflationtypes.ModuleName] = cfg.Codec.MustMarshalJSON(&inflationGenState) - */ - var crisisGenState crisistypes.GenesisState cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[crisistypes.ModuleName], &crisisGenState) diff --git a/testutil/tx/cosmos.go b/testutil/tx/cosmos.go index 885aed2d..0358e121 100644 --- a/testutil/tx/cosmos.go +++ b/testutil/tx/cosmos.go @@ -3,8 +3,6 @@ package tx import ( "math" - "github.com/artela-network/artela/ethereum/utils" - sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" @@ -14,6 +12,7 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/artela-network/artela/app" + "github.com/artela-network/artela/ethereum/utils" ) var ( diff --git a/testutil/tx/eip712.go b/testutil/tx/eip712.go index ae0cf0de..12cbef19 100644 --- a/testutil/tx/eip712.go +++ b/testutil/tx/eip712.go @@ -3,9 +3,6 @@ package tx import ( "errors" - cryptocodec "github.com/artela-network/artela/ethereum/crypto/codec" - types2 "github.com/artela-network/artela/ethereum/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -19,7 +16,9 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/artela-network/artela/app" + cryptocodec "github.com/artela-network/artela/ethereum/crypto/codec" "github.com/artela-network/artela/ethereum/eip712" + types2 "github.com/artela-network/artela/ethereum/types" ) type EIP712TxArgs struct { @@ -87,7 +86,8 @@ func PrepareEIP712CosmosTx( return nil, err } - fee := legacytx.NewStdFee(txArgs.Gas, txArgs.Fees) // nolint: staticcheck + //nolint: staticcheck + fee := legacytx.NewStdFee(txArgs.Gas, txArgs.Fees) msgs := txArgs.Msgs data := legacytx.StdSignBytes(ctx.ChainID(), accNumber, nonce, 0, fee, msgs, "", nil) diff --git a/testutil/tx/eth.go b/testutil/tx/eth.go index ea9e5c36..2ea3b4c6 100644 --- a/testutil/tx/eth.go +++ b/testutil/tx/eth.go @@ -4,10 +4,6 @@ import ( "encoding/json" "math/big" - "github.com/artela-network/artela/ethereum/server/config" - "github.com/artela-network/artela/ethereum/utils" - "github.com/artela-network/artela/x/evm/txs" - errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" @@ -21,6 +17,9 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/artela-network/artela/app" + "github.com/artela-network/artela/ethereum/server/config" + "github.com/artela-network/artela/ethereum/utils" + "github.com/artela-network/artela/x/evm/txs" ) // PrepareEthTx creates an ethereum txs and signs it with the provided messages and private key. diff --git a/testutil/tx/signer.go b/testutil/tx/signer.go index 77fda6b0..a90548c6 100644 --- a/testutil/tx/signer.go +++ b/testutil/tx/signer.go @@ -3,14 +3,13 @@ package tx import ( "fmt" - ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + + ethsecp256k12 "github.com/artela-network/artela/ethereum/crypto/ethsecp256k1" ) // NewAddrKey generates an Ethereum address and its corresponding private key. diff --git a/x/evm/artela/api/aspect_property_api.go b/x/evm/artela/api/aspect_property_api.go index e5e68000..ab1fc45d 100644 --- a/x/evm/artela/api/aspect_property_api.go +++ b/x/evm/artela/api/aspect_property_api.go @@ -3,24 +3,24 @@ package api import ( "context" "errors" + "github.com/artela-network/artela/x/evm/artela/contract" "github.com/artela-network/artela/x/evm/artela/types" asptypes "github.com/artela-network/aspect-core/types" ) -var ( - _ asptypes.AspectPropertyHostAPI = (*aspectPropertyHostAPI)(nil) -) +var _ asptypes.AspectPropertyHostAPI = (*aspectPropertyHostAPI)(nil) type aspectPropertyHostAPI struct { aspectRuntimeContext *types.AspectRuntimeContext } -func (a *aspectPropertyHostAPI) Get(ctx *asptypes.RunnerContext, key string) []byte { +func (a *aspectPropertyHostAPI) Get(ctx *asptypes.RunnerContext, key string) (ret []byte, err error) { // TODO: this part looks weird, // but due to the time issue, we just migrate the old logics for now nativeContractStore := contract.NewAspectStore(a.aspectRuntimeContext.StoreKey(), a.aspectRuntimeContext.Logger()) - return nativeContractStore.GetAspectPropertyValue(a.aspectRuntimeContext.CosmosContext(), ctx.AspectId, key) + ret, ctx.Gas, err = nativeContractStore.GetAspectPropertyValue(a.aspectRuntimeContext.CosmosContext(), ctx.AspectId, key, ctx.Gas) + return } func GetAspectPropertyHostInstance(ctx context.Context) (asptypes.AspectPropertyHostAPI, error) { diff --git a/x/evm/artela/api/aspect_runtime_ctx_api.go b/x/evm/artela/api/aspect_runtime_ctx_api.go index d4300514..4c8b790d 100644 --- a/x/evm/artela/api/aspect_runtime_ctx_api.go +++ b/x/evm/artela/api/aspect_runtime_ctx_api.go @@ -5,22 +5,20 @@ import ( "errors" "fmt" - aspctx "github.com/artela-network/aspect-core/context" - "github.com/cosmos/gogoproto/proto" "github.com/emirpasic/gods/sets/hashset" - asptypes "github.com/artela-network/aspect-core/types" + "github.com/cosmos/gogoproto/proto" "github.com/artela-network/artela/x/evm/artela/api/datactx" "github.com/artela-network/artela/x/evm/artela/types" + aspctx "github.com/artela-network/aspect-core/context" + asptypes "github.com/artela-network/aspect-core/types" ) var ( - _ asptypes.RuntimeContextHostAPI = (*aspectRuntimeContextHostAPI)(nil) -) - -var ( - ctxKeyConstraints = map[asptypes.PointCut]*hashset.Set{ + _ asptypes.RuntimeContextHostAPI = (*aspectRuntimeContextHostAPI)(nil) + ctxKeyConstraints = map[asptypes.PointCut]*hashset.Set{ + asptypes.INIT_METHOD: hashset.New(aspctx.InitKeys...), asptypes.OPERATION_METHOD: hashset.New(aspctx.OperationKeys...), asptypes.VERIFY_TX: hashset.New(aspctx.VerifyTxCtxKeys...), asptypes.PRE_TX_EXECUTE_METHOD: hashset.New(aspctx.PreTxCtxKeys...), diff --git a/x/evm/artela/api/aspect_state_api.go b/x/evm/artela/api/aspect_state_api.go index 2c08a4d4..4527c9a6 100644 --- a/x/evm/artela/api/aspect_state_api.go +++ b/x/evm/artela/api/aspect_state_api.go @@ -4,10 +4,10 @@ import ( "context" "errors" - asptypes "github.com/artela-network/aspect-core/types" "github.com/emirpasic/gods/sets/hashset" "github.com/artela-network/artela/x/evm/artela/types" + asptypes "github.com/artela-network/aspect-core/types" ) var ( @@ -18,6 +18,7 @@ var ( asptypes.PRE_TX_EXECUTE_METHOD, asptypes.POST_TX_EXECUTE_METHOD, asptypes.OPERATION_METHOD, + asptypes.INIT_METHOD, ) ) diff --git a/x/evm/artela/api/aspect_transient_storage_api.go b/x/evm/artela/api/aspect_transient_storage_api.go index 912dbd45..329d935a 100644 --- a/x/evm/artela/api/aspect_transient_storage_api.go +++ b/x/evm/artela/api/aspect_transient_storage_api.go @@ -3,10 +3,13 @@ package api import ( "context" "errors" - "github.com/artela-network/artela/x/evm/artela/types" - asptypes "github.com/artela-network/aspect-core/types" + "github.com/emirpasic/gods/sets/hashset" + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela/x/evm/artela/types" + asptypes "github.com/artela-network/aspect-core/types" ) var ( diff --git a/x/evm/artela/api/datactx/aspect.go b/x/evm/artela/api/datactx/aspect.go index 3847c3a9..08a91af0 100644 --- a/x/evm/artela/api/datactx/aspect.go +++ b/x/evm/artela/api/datactx/aspect.go @@ -3,9 +3,10 @@ package datactx import ( "errors" + "google.golang.org/protobuf/proto" + aspctx "github.com/artela-network/aspect-core/context" artelatypes "github.com/artela-network/aspect-core/types" - "google.golang.org/protobuf/proto" ) type AspectContextFieldLoader func(ctx *artelatypes.RunnerContext) proto.Message diff --git a/x/evm/artela/api/datactx/block.go b/x/evm/artela/api/datactx/block.go index a7930d67..e28db499 100644 --- a/x/evm/artela/api/datactx/block.go +++ b/x/evm/artela/api/datactx/block.go @@ -3,11 +3,11 @@ package datactx import ( "errors" - "github.com/artela-network/aspect-core/context" - artelatypes "github.com/artela-network/aspect-core/types" "google.golang.org/protobuf/proto" "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/aspect-core/context" + artelatypes "github.com/artela-network/aspect-core/types" ) type BlockContextFieldLoader func(blockCtx *types.EthBlockContext) proto.Message diff --git a/x/evm/artela/api/datactx/env.go b/x/evm/artela/api/datactx/env.go index 610ce3d6..fcdfbd6e 100644 --- a/x/evm/artela/api/datactx/env.go +++ b/x/evm/artela/api/datactx/env.go @@ -3,12 +3,12 @@ package datactx import ( "strings" - "github.com/artela-network/aspect-core/context" - artelatypes "github.com/artela-network/aspect-core/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/protobuf/proto" "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/aspect-core/context" + artelatypes "github.com/artela-network/aspect-core/types" ) type EnvContextFieldLoader func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message @@ -32,135 +32,129 @@ func NewEnvContext(ctx *types.AspectRuntimeContext, keeper EVMKeeper) *EnvContex func (c *EnvContext) registerLoaders() { loaders := c.envContentLoaders defUint64 := uint64(0) - loaders[context.EnvExtraEIPs] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvExtraEIPs] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { return &artelatypes.IntArrayData{Data: ethTxCtx.EvmCfg().Params.ExtraEIPs} } - loaders[context.EnvEnableCreate] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvEnableCreate] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { return &artelatypes.BoolData{Data: ðTxCtx.EvmCfg().Params.EnableCreate} } - loaders[context.EnvEnableCall] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvEnableCall] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { return &artelatypes.BoolData{Data: ðTxCtx.EvmCfg().Params.EnableCall} } - loaders[context.EnvAllowUnprotectedTxs] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvAllowUnprotectedTxs] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { return &artelatypes.BoolData{Data: ðTxCtx.EvmCfg().Params.AllowUnprotectedTxs} } - loaders[context.EnvChainChainId] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainChainId] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { chainId := c.keeper.ChainID().Uint64() return &artelatypes.UintData{Data: &chainId} } - loaders[context.EnvChainHomesteadBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainHomesteadBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { homesteadBlock := ethTxCtx.EvmCfg().ChainConfig.HomesteadBlock.Uint64() return &artelatypes.UintData{Data: &homesteadBlock} } - loaders[context.EnvChainDaoForkBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainDaoForkBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { forkBlock := ethTxCtx.EvmCfg().ChainConfig.DAOForkBlock.Uint64() return &artelatypes.UintData{Data: &forkBlock} } - loaders[context.EnvChainDaoForkSupport] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainDaoForkSupport] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { forkBlock := ethTxCtx.EvmCfg().ChainConfig.DAOForkSupport return &artelatypes.BoolData{Data: &forkBlock} } - loaders[context.EnvChainEip150Block] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainEip150Block] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { eip150Block := ethTxCtx.EvmCfg().ChainConfig.EIP150Block.Uint64() return &artelatypes.UintData{Data: &eip150Block} } - loaders[context.EnvChainEip155Block] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainEip155Block] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { eip155block := ethTxCtx.EvmCfg().ChainConfig.EIP155Block.Uint64() return &artelatypes.UintData{Data: &eip155block} } - loaders[context.EnvChainEip158Block] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainEip158Block] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { eip158block := ethTxCtx.EvmCfg().ChainConfig.EIP158Block.Uint64() return &artelatypes.UintData{Data: &eip158block} } - loaders[context.EnvChainByzantiumBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainByzantiumBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { byzantium := ethTxCtx.EvmCfg().ChainConfig.ByzantiumBlock.Uint64() return &artelatypes.UintData{Data: &byzantium} } - loaders[context.EnvChainConstantinopleBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainConstantinopleBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { constantinople := ethTxCtx.EvmCfg().ChainConfig.ConstantinopleBlock.Uint64() return &artelatypes.UintData{Data: &constantinople} } - loaders[context.EnvChainPetersburgBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainPetersburgBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { petersburgBlock := ethTxCtx.EvmCfg().ChainConfig.PetersburgBlock.Uint64() return &artelatypes.UintData{Data: &petersburgBlock} } - loaders[context.EnvChainIstanbulBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainIstanbulBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { istanbul := ethTxCtx.EvmCfg().ChainConfig.IstanbulBlock.Uint64() return &artelatypes.UintData{Data: &istanbul} } - loaders[context.EnvChainMuirGlacierBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainMuirGlacierBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { muirGlacier := ethTxCtx.EvmCfg().ChainConfig.MuirGlacierBlock.Uint64() return &artelatypes.UintData{Data: &muirGlacier} } - loaders[context.EnvChainBerlinBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainBerlinBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { berlinBlock := ethTxCtx.EvmCfg().ChainConfig.BerlinBlock.Uint64() return &artelatypes.UintData{Data: &berlinBlock} } - loaders[context.EnvChainLondonBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainLondonBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { londonBlock := ethTxCtx.EvmCfg().ChainConfig.LondonBlock.Uint64() return &artelatypes.UintData{Data: &londonBlock} } - loaders[context.EnvChainArrowGlacierBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainArrowGlacierBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { arrowGlacierBlock := ethTxCtx.EvmCfg().ChainConfig.ArrowGlacierBlock.Uint64() return &artelatypes.UintData{Data: &arrowGlacierBlock} } - loaders[context.EnvChainGrayGlacierBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainGrayGlacierBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { grayGlacierBlock := ethTxCtx.EvmCfg().ChainConfig.GrayGlacierBlock.Uint64() return &artelatypes.UintData{Data: &grayGlacierBlock} } - loaders[context.EnvChainMergeNetSplitBlock] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainMergeNetSplitBlock] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { mergeNetsplitBlock := ethTxCtx.EvmCfg().ChainConfig.MergeNetsplitBlock.Uint64() return &artelatypes.UintData{Data: &mergeNetsplitBlock} } - loaders[context.EnvChainShanghaiTime] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainShanghaiTime] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { shanghaiTime := ethTxCtx.EvmCfg().ChainConfig.ShanghaiTime if shanghaiTime != nil { return &artelatypes.UintData{Data: shanghaiTime} - } else { - return &artelatypes.UintData{Data: &defUint64} } - + return &artelatypes.UintData{Data: &defUint64} } - loaders[context.EnvChainCancunTime] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainCancunTime] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { cancunTime := ethTxCtx.EvmCfg().ChainConfig.CancunTime if cancunTime != nil { return &artelatypes.UintData{Data: cancunTime} } else { return &artelatypes.UintData{Data: &defUint64} } - } - loaders[context.EnvChainPragueTime] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvChainPragueTime] = func(_ sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { pragueTime := ethTxCtx.EvmCfg().ChainConfig.PragueTime if pragueTime != nil { return &artelatypes.UintData{Data: pragueTime} - } else { - return &artelatypes.UintData{Data: &defUint64} - } - + return &artelatypes.UintData{Data: &defUint64} } - loaders[context.EnvConsensusParamsBlockMaxGas] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsBlockMaxGas] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.IntData{Data: &sdkCtx.ConsensusParams().Block.MaxGas} } - loaders[context.EnvConsensusParamsBlockMaxBytes] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsBlockMaxBytes] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.IntData{Data: &sdkCtx.ConsensusParams().Block.MaxBytes} } - loaders[context.EnvConsensusParamsValidatorPubKeyTypes] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsValidatorPubKeyTypes] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.StringArrayData{Data: sdkCtx.ConsensusParams().Validator.PubKeyTypes} } - loaders[context.EnvConsensusParamsEvidenceMaxBytes] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsEvidenceMaxBytes] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.IntData{Data: &sdkCtx.ConsensusParams().Evidence.MaxBytes} } - loaders[context.EnvConsensusParamsEvidenceMaxAgeNumBlocks] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsEvidenceMaxAgeNumBlocks] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.IntData{Data: &sdkCtx.ConsensusParams().Evidence.MaxAgeNumBlocks} } - loaders[context.EnvConsensusParamsEvidenceMaxAgeDuration] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsEvidenceMaxAgeDuration] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { data := sdkCtx.ConsensusParams().Evidence.MaxAgeDuration.Milliseconds() / 1000 return &artelatypes.IntData{Data: &data} } - loaders[context.EnvConsensusParamsAppVersion] = func(sdkCtx sdk.Context, ethTxCtx *types.EthTxContext) proto.Message { + loaders[context.EnvConsensusParamsAppVersion] = func(sdkCtx sdk.Context, _ *types.EthTxContext) proto.Message { return &artelatypes.UintData{Data: &sdkCtx.ConsensusParams().Version.App} } } @@ -174,9 +168,7 @@ func (c *EnvContext) ValueLoader(key string) ContextLoader { if strings.HasPrefix(key, "env.consensusParams.") && c.ctx.CosmosContext().ConsensusParams() == nil { // when it is in an eth call, we are not able to return env.consensusParams.* values return nil, nil - } - return proto.Marshal(c.envContentLoaders[key](c.ctx.CosmosContext(), c.ctx.EthTxContext())) } } diff --git a/x/evm/artela/api/datactx/msg.go b/x/evm/artela/api/datactx/msg.go index f7abc7c9..52dbddcc 100644 --- a/x/evm/artela/api/datactx/msg.go +++ b/x/evm/artela/api/datactx/msg.go @@ -3,13 +3,13 @@ package datactx import ( "errors" - aspctx "github.com/artela-network/aspect-core/context" - artelatypes "github.com/artela-network/aspect-core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/core" "google.golang.org/protobuf/proto" "github.com/artela-network/artela/x/evm/artela/types" + aspctx "github.com/artela-network/aspect-core/context" + artelatypes "github.com/artela-network/aspect-core/types" ) type MessageContextFieldLoader func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message @@ -37,23 +37,23 @@ func (c *MessageContext) registerLoaders() { index := ethTxCtx.VmTracer().CurrentCallIndex() return &artelatypes.UintData{Data: &index} } - loaders[aspctx.MsgFrom] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgFrom] = func(_ *types.EthTxContext, message *core.Message) proto.Message { return &artelatypes.BytesData{Data: message.From.Bytes()} } - loaders[aspctx.MsgTo] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgTo] = func(_ *types.EthTxContext, message *core.Message) proto.Message { return &artelatypes.BytesData{Data: message.To.Bytes()} } - loaders[aspctx.MsgValue] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgValue] = func(_ *types.EthTxContext, message *core.Message) proto.Message { return &artelatypes.BytesData{Data: message.Value.Bytes()} } - loaders[aspctx.MsgInput] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgInput] = func(_ *types.EthTxContext, message *core.Message) proto.Message { return &artelatypes.BytesData{Data: message.Data} } - loaders[aspctx.MsgGas] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgGas] = func(_ *types.EthTxContext, message *core.Message) proto.Message { gasLimit := message.GasLimit return &artelatypes.UintData{Data: &gasLimit} } - loaders[aspctx.MsgResultRet] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgResultRet] = func(ethTxCtx *types.EthTxContext, _ *core.Message) proto.Message { tracer := ethTxCtx.VmTracer() callIdx := tracer.CurrentCallIndex() currentCall := tracer.CallTree().FindCall(callIdx) @@ -70,7 +70,7 @@ func (c *MessageContext) registerLoaders() { result := message.GasLimit - currentCall.RemainingGas return &artelatypes.UintData{Data: &result} } - loaders[aspctx.MsgResultError] = func(ethTxCtx *types.EthTxContext, message *core.Message) proto.Message { + loaders[aspctx.MsgResultError] = func(ethTxCtx *types.EthTxContext, _ *core.Message) proto.Message { tracer := ethTxCtx.VmTracer() callIdx := tracer.CurrentCallIndex() currentCall := tracer.CallTree().FindCall(callIdx) diff --git a/x/evm/artela/api/datactx/receipt.go b/x/evm/artela/api/datactx/receipt.go index 2cdfddfe..4e90181e 100644 --- a/x/evm/artela/api/datactx/receipt.go +++ b/x/evm/artela/api/datactx/receipt.go @@ -3,13 +3,13 @@ package datactx import ( "errors" - aspctx "github.com/artela-network/aspect-core/context" - artelatypes "github.com/artela-network/aspect-core/types" sdk "github.com/cosmos/cosmos-sdk/types" ethereum "github.com/ethereum/go-ethereum/core/types" "google.golang.org/protobuf/proto" "github.com/artela-network/artela/x/evm/artela/types" + aspctx "github.com/artela-network/aspect-core/context" + artelatypes "github.com/artela-network/aspect-core/types" ) type ReceiptContextFieldLoader func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message @@ -33,10 +33,10 @@ func NewReceiptContext(getEthTxContext func() *types.EthTxContext, func (c *ReceiptContext) registerLoaders() { loaders := c.receiptContentLoaders - loaders[aspctx.ReceiptStatus] = func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { + loaders[aspctx.ReceiptStatus] = func(_ *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { return &artelatypes.UintData{Data: &receipt.Status} } - loaders[aspctx.ReceiptLogs] = func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { + loaders[aspctx.ReceiptLogs] = func(_ *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { logs := make([]*artelatypes.EthLog, 0, len(receipt.Logs)) for _, log := range receipt.Logs { topics := make([][]byte, 0, len(log.Topics)) @@ -53,13 +53,13 @@ func (c *ReceiptContext) registerLoaders() { } return &artelatypes.EthLogs{Logs: logs} } - loaders[aspctx.ReceiptGasUsed] = func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { + loaders[aspctx.ReceiptGasUsed] = func(_ *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { return &artelatypes.UintData{Data: &receipt.GasUsed} } - loaders[aspctx.ReceiptCumulativeGasUsed] = func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { + loaders[aspctx.ReceiptCumulativeGasUsed] = func(_ *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { return &artelatypes.UintData{Data: &receipt.CumulativeGasUsed} } - loaders[aspctx.ReceiptBloom] = func(ethTxCtx *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { + loaders[aspctx.ReceiptBloom] = func(_ *types.EthTxContext, receipt *ethereum.Receipt) proto.Message { return &artelatypes.BytesData{Data: receipt.Bloom.Bytes()} } } diff --git a/x/evm/artela/api/datactx/tx.go b/x/evm/artela/api/datactx/tx.go index b4c1b34a..5212f7f3 100644 --- a/x/evm/artela/api/datactx/tx.go +++ b/x/evm/artela/api/datactx/tx.go @@ -5,14 +5,14 @@ import ( "errors" "math/big" - aspctx "github.com/artela-network/aspect-core/context" - artelatypes "github.com/artela-network/aspect-core/types" sdk "github.com/cosmos/cosmos-sdk/types" ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" "google.golang.org/protobuf/proto" "github.com/artela-network/artela/x/evm/artela/types" + aspctx "github.com/artela-network/aspect-core/context" + artelatypes "github.com/artela-network/aspect-core/types" ) type TxContextFieldLoader func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message @@ -37,18 +37,17 @@ func NewTxContext(getEthTxContext func() *types.EthTxContext, func (c *TxContext) registerLoaders() { loaders := c.receiptContentLoaders - loaders[aspctx.TxType] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxType] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { txType := uint64(tx.Type()) return &artelatypes.UintData{Data: &txType} } - loaders[aspctx.TxChainId] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxChainId] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { if tx.ChainId() != nil { return &artelatypes.BytesData{Data: tx.ChainId().Bytes()} - } else { - return &artelatypes.BytesData{Data: []byte{}} } + return &artelatypes.BytesData{Data: []byte{}} } - loaders[aspctx.TxAccessList] = func(ehTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxAccessList] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { res := &artelatypes.EthAccessList{AccessList: make([]*artelatypes.EthAccessTuple, 0, len(tx.AccessList()))} if len(tx.AccessList()) == 0 { return res @@ -68,40 +67,40 @@ func (c *TxContext) registerLoaders() { } return res } - loaders[aspctx.TxNonce] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxNonce] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { nonce := tx.Nonce() return &artelatypes.UintData{Data: &nonce} } - loaders[aspctx.TxGas] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxGas] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { gas := tx.Gas() return &artelatypes.UintData{Data: &gas} } - loaders[aspctx.TxGasPrice] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxGasPrice] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.GasPrice().Bytes()} } - loaders[aspctx.TxGasTipCap] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxGasTipCap] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.GasTipCap().Bytes()} } - loaders[aspctx.TxGasFeeCap] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxGasFeeCap] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.GasFeeCap().Bytes()} } - loaders[aspctx.TxTo] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxTo] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.To().Bytes()} } - loaders[aspctx.TxValue] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxValue] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.Value().Bytes()} } - loaders[aspctx.TxData] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxData] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.Data()} } - loaders[aspctx.TxBytes] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxBytes] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { raw, err := tx.MarshalBinary() if err != nil { panic(err) } return &artelatypes.BytesData{Data: raw} } - loaders[aspctx.TxHash] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxHash] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: tx.Hash().Bytes()} } loaders[aspctx.TxUnsignedBytes] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { @@ -201,22 +200,22 @@ func (c *TxContext) registerLoaders() { signer := ethereum.MakeSigner(config, blockNumber, blockTime) return &artelatypes.BytesData{Data: signer.Hash(tx).Bytes()} } - loaders[aspctx.TxSigV] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxSigV] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { v, _, _ := tx.RawSignatureValues() return &artelatypes.BytesData{Data: v.Bytes()} } - loaders[aspctx.TxSigS] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxSigS] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { _, r, _ := tx.RawSignatureValues() return &artelatypes.BytesData{Data: r.Bytes()} } - loaders[aspctx.TxSigR] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxSigR] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { _, _, s := tx.RawSignatureValues() return &artelatypes.BytesData{Data: s.Bytes()} } - loaders[aspctx.TxFrom] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxFrom] = func(ethTxCtx *types.EthTxContext, _ *ethereum.Transaction) proto.Message { return &artelatypes.BytesData{Data: ethTxCtx.TxFrom().Bytes()} } - loaders[aspctx.TxIndex] = func(ethTxCtx *types.EthTxContext, tx *ethereum.Transaction) proto.Message { + loaders[aspctx.TxIndex] = func(ethTxCtx *types.EthTxContext, _ *ethereum.Transaction) proto.Message { index := ethTxCtx.TxIndex() return &artelatypes.UintData{Data: &index} } diff --git a/x/evm/artela/api/datactx/types.go b/x/evm/artela/api/datactx/types.go index 9f889713..ea312415 100644 --- a/x/evm/artela/api/datactx/types.go +++ b/x/evm/artela/api/datactx/types.go @@ -1,8 +1,9 @@ package datactx import ( - artelatypes "github.com/artela-network/aspect-core/types" "math/big" + + artelatypes "github.com/artela-network/aspect-core/types" ) type ContextLoader func(ctx *artelatypes.RunnerContext) ([]byte, error) diff --git a/x/evm/artela/api/evm_api.go b/x/evm/artela/api/evm_api.go index a56d2fea..d29ac2fa 100644 --- a/x/evm/artela/api/evm_api.go +++ b/x/evm/artela/api/evm_api.go @@ -3,17 +3,18 @@ package api import ( "context" "errors" + "github.com/emirpasic/gods/sets/hashset" - "github.com/artela-network/artela-evm/vm" - asptypes "github.com/artela-network/aspect-core/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/log" + "github.com/artela-network/artela-evm/vm" artelatypes "github.com/artela-network/artela/x/evm/artela/types" "github.com/artela-network/artela/x/evm/states" types "github.com/artela-network/artela/x/evm/txs" + asptypes "github.com/artela-network/aspect-core/types" ) var ( @@ -25,11 +26,7 @@ var ( asptypes.PRE_TX_EXECUTE_METHOD, asptypes.POST_TX_EXECUTE_METHOD, asptypes.OPERATION_METHOD, - ) - - evmJITCallConstrainedJoinPoints = hashset.New( - asptypes.PRE_CONTRACT_CALL_METHOD, - asptypes.POST_CONTRACT_CALL_METHOD, + asptypes.INIT_METHOD, ) ) @@ -100,8 +97,7 @@ func (e *evmHostApi) JITCall(ctx *asptypes.RunnerContext, request *asptypes.JitI // determine jit call stage defBool := false switch asptypes.PointCut(ctx.Point) { - case asptypes.PRE_TX_EXECUTE_METHOD, asptypes.POST_TX_EXECUTE_METHOD, - asptypes.PRE_CONTRACT_CALL_METHOD, asptypes.POST_CONTRACT_CALL_METHOD: + case asptypes.PRE_CONTRACT_CALL_METHOD, asptypes.POST_CONTRACT_CALL_METHOD: // FIXME: get leftover gas from last evm resp, gas, err := e.aspectCtx.JITManager().Submit(ctx.Ctx, ctx.AspectId, ctx.Gas, request) if err != nil { diff --git a/x/evm/artela/api/globals.go b/x/evm/artela/api/globals.go index 579f00a8..ed8d359c 100644 --- a/x/evm/artela/api/globals.go +++ b/x/evm/artela/api/globals.go @@ -1,12 +1,14 @@ package api import ( - "github.com/artela-network/artela-evm/vm" - "github.com/artela-network/artela/x/evm/states" + "math/big" + cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" - "math/big" + + "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/artela/x/evm/states" ) // globals, we need to manage the lifecycle carefully for the following hooks / variables diff --git a/x/evm/artela/api/statedb_api.go b/x/evm/artela/api/statedb_api.go index fc41e8a6..e8e02822 100644 --- a/x/evm/artela/api/statedb_api.go +++ b/x/evm/artela/api/statedb_api.go @@ -2,9 +2,11 @@ package api import ( "context" + + "github.com/pkg/errors" + "github.com/artela-network/artela/x/evm/artela/types" artelatypes "github.com/artela-network/aspect-core/types" - "github.com/pkg/errors" ) func GetStateDBHostInstance(ctx context.Context) (artelatypes.StateDBHostAPI, error) { diff --git a/x/evm/artela/api/trace_api.go b/x/evm/artela/api/trace_api.go index 25df68c3..bff1fb64 100644 --- a/x/evm/artela/api/trace_api.go +++ b/x/evm/artela/api/trace_api.go @@ -3,15 +3,16 @@ package api import ( "context" "errors" - "github.com/emirpasic/gods/sets/hashset" "sort" - "github.com/artela-network/artela-evm/vm" - artelatypes "github.com/artela-network/aspect-core/types" + "github.com/emirpasic/gods/sets/hashset" + "google.golang.org/protobuf/proto" + "github.com/ethereum/go-ethereum/common" - "github.com/golang/protobuf/proto" + "github.com/artela-network/artela-evm/vm" "github.com/artela-network/artela/x/evm/artela/types" + artelatypes "github.com/artela-network/aspect-core/types" ) var ( @@ -64,11 +65,9 @@ func (a *aspectTraceHostAPI) QueryStateChange(ctx *artelatypes.RunnerContext, qu } var result proto.Message - // nolint:gosimple - switch storageChanges.(type) { - // nolint:gosimple + switch sc := storageChanges.(type) { case *vm.StorageChanges: - changes := storageChanges.(*vm.StorageChanges).Changes() + changes := sc.Changes() ethStateChanges := &artelatypes.EthStateChanges{ All: make([]*artelatypes.EthStateChange, 0, len(changes)), } @@ -95,11 +94,9 @@ func (a *aspectTraceHostAPI) QueryStateChange(ctx *artelatypes.RunnerContext, qu } } result = ethStateChanges - // nolint:gosimple case [][]byte: - indices := storageChanges.([][]byte) ethStateChangeIndices := &artelatypes.EthStateChangeIndices{ - Indices: indices, + Indices: sc, } result = ethStateChangeIndices @@ -120,9 +117,6 @@ func (a *aspectTraceHostAPI) QueryCallTree(ctx *artelatypes.RunnerContext, query return []byte{}, errors.New("cannot query call tree in current join point") } - if ctx == nil { - return []byte{}, nil - } txContext := a.aspectRuntimeContext.EthTxContext() if txContext == nil || txContext.VmTracer() == nil || txContext.VmTracer().CallTree() == nil { @@ -135,8 +129,11 @@ func (a *aspectTraceHostAPI) QueryCallTree(ctx *artelatypes.RunnerContext, query callTree := tracer.CallTree() if query.CallIdx == nil || *query.CallIdx < 0 { // for negative numbers we return the entire call tree - ethCallTree := &artelatypes.EthCallTree{Calls: make(map[uint64]*artelatypes.EthCallMessage)} + ethCallTree := &artelatypes.EthCallTree{Calls: make([]*artelatypes.EthCallMessage, 0, tracer.CurrentCallIndex())} traverseEVMCallTree(callTree.Root(), ethCallTree) + sort.Slice(ethCallTree.Calls, func(i, j int) bool { + return *ethCallTree.Calls[i].Index < *ethCallTree.Calls[j].Index + }) result = ethCallTree } else { call := tracer.CallTree().FindCall(uint64(*query.CallIdx)) @@ -153,14 +150,11 @@ func (a *aspectTraceHostAPI) QueryCallTree(ctx *artelatypes.RunnerContext, query } func traverseEVMCallTree(ethCall *vm.Call, evmCallTree *artelatypes.EthCallTree) { - if evmCallTree == nil { - evmCallTree = &artelatypes.EthCallTree{Calls: make(map[uint64]*artelatypes.EthCallMessage)} - } if ethCall == nil { return } - evmCallTree.GetCalls()[ethCall.Index] = callToTrace(ethCall) + evmCallTree.Calls = append(evmCallTree.Calls, callToTrace(ethCall)) children := ethCall.Children if children == nil { diff --git a/x/evm/artela/contract/contract.go b/x/evm/artela/contract/contract.go index 24a9d452..bda52e0c 100644 --- a/x/evm/artela/contract/contract.go +++ b/x/evm/artela/contract/contract.go @@ -1,25 +1,19 @@ package contract import ( - "bytes" - "math/big" "strings" - "github.com/artela-network/artela/x/evm/states" - errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela-evm/vm" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/crypto" - "github.com/holiman/uint256" - "github.com/pkg/errors" - "github.com/artela-network/artela/x/evm/artela/types" - evmtxs "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/artela/common" + "github.com/artela-network/artela/common/aspect" + "github.com/artela-network/artela/x/evm/states" evmtypes "github.com/artela-network/artela/x/evm/types" ) @@ -27,6 +21,9 @@ type AspectNativeContract struct { aspectService *AspectService evmState *states.StateDB evm *vm.EVM + + logger log.Logger + handlers map[string]Handler } func NewAspectNativeContract(storeKey storetypes.StoreKey, @@ -39,202 +36,66 @@ func NewAspectNativeContract(storeKey storetypes.StoreKey, aspectService: NewAspectService(storeKey, getBlockHeight, logger), evm: evm, evmState: evmState, + logger: logger, + handlers: make(map[string]Handler), } } -func (k *AspectNativeContract) ApplyMessage(ctx sdk.Context, msg *core.Message, commit bool) (*evmtxs.MsgEthereumTxResponse, error) { +func (c *AspectNativeContract) Init() { + c.register(DeployHandler{}) + c.register(UpgradeHandler{}) + c.register(BindHandler{}) + c.register(UnbindHandler{}) + c.register(ChangeVersionHandler{}) + c.register(GetVersionHandler{}) + c.register(GetBindingHandler{}) + c.register(GetBoundAddressHandler{}) + c.register(OperationHandler{}) +} + +func (c *AspectNativeContract) register(handler Handler) { + c.handlers[handler.Method()] = handler +} + +func (c *AspectNativeContract) ApplyMessage(ctx sdk.Context, msg *core.Message, gas uint64, commit bool) (ret []byte, remainingGas uint64, err error) { var writeCacheFunc func() ctx, writeCacheFunc = ctx.CacheContext() - applyMsg, err := k.applyMsg(ctx, msg, commit) + ret, remainingGas, err = c.applyMsg(ctx, msg, gas, commit) if err == nil && commit { writeCacheFunc() } - if err != nil { - return &evmtxs.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: err.Error(), - Ret: nil, - Logs: nil, - }, nil - } - return applyMsg, err + + return ret, remainingGas, err } -func (k *AspectNativeContract) applyMsg(ctx sdk.Context, msg *core.Message, commit bool) (*evmtxs.MsgEthereumTxResponse, error) { - method, parameters, err := types.ParseMethod(msg.Data) +func (c *AspectNativeContract) applyMsg(ctx sdk.Context, msg *core.Message, gas uint64, commit bool) (ret []byte, remainingGas uint64, err error) { + method, parameters, err := aspect.ParseMethod(msg.Data) if err != nil { - return nil, err + return nil, 0, err } - switch strings.ToLower(method.Name) { - case "deploy": - { - code := parameters["code"].([]byte) - properties := parameters["properties"].([]struct { - Key string `json:"key"` - Value []byte `json:"value"` - }) - var propertyAry []types.Property - for i := range properties { - s := properties[i] - if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { - // Block query of account and Proof - return nil, errors.New("Cannot use Aspect-defined keys") - } - propertyAry = append(propertyAry, types.Property{ - Key: s.Key, - Value: s.Value, - }) - } - sender := vm.AccountRef(msg.From) - account := parameters["account"].(common.Address) - if bytes.Equal(account.Bytes(), msg.From.Bytes()) { - accountProperty := types.Property{ - Key: types.AspectAccountKey, - Value: account.Bytes(), - } - propertyAry = append(propertyAry, accountProperty) - } else { - return nil, errors.New("Account verification failed during aspect deploy") - } - joinPoints := parameters["joinPoints"].(*big.Int) - - if len(code) == 0 { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "Code verification failed during aspect deploy") - } - if joinPoints == nil { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "JoinPoints verification failed during aspect deploy") - } - - aspectId := crypto.CreateAddress(sender.Address(), msg.Nonce) - checkErr := k.checkAspectCode(ctx, aspectId, code, false) - if checkErr != nil { - return nil, checkErr - } - return k.deploy(ctx, aspectId, code, propertyAry, joinPoints) - } - case "upgrade": - { - aspectId := parameters["aspectId"].(common.Address) - code := parameters["code"].([]byte) - properties := parameters["properties"].([]struct { - Key string `json:"key"` - Value []byte `json:"value"` - }) - var propertyAry []types.Property - for i := range properties { - s := properties[i] - if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { - // Block query of account and Proof - return nil, errors.New("Cannot use Aspect-defined keys") - } - propertyAry = append(propertyAry, types.Property{ - Key: s.Key, - Value: s.Value, - }) - } - sender := vm.AccountRef(msg.From) - aspectOwner, checkErr := k.checkAspectOwner(ctx, aspectId, sender.Address(), msg.GasLimit, commit) - if checkErr != nil { - return nil, checkErr - } - if !aspectOwner { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "failed to check if the sender is the owner, unable to upgrade, sender: %s , aspectId: %s", sender.Address().String(), aspectId.String()) - } - joinPoints := parameters["joinPoints"].(*big.Int) - if len(code) > 0 { - codeErr := k.checkAspectCode(ctx, aspectId, code, false) - if codeErr != nil { - return nil, codeErr - } - } - return k.deploy(ctx, aspectId, code, propertyAry, joinPoints) - } - case "bind": - { - aspectId := parameters["aspectId"].(common.Address) - aspectVersion := parameters["aspectVersion"].(*big.Int) - account := parameters["contract"].(common.Address) - priority := parameters["priority"].(int8) - versionU256, _ := uint256.FromBig(aspectVersion) - sender := vm.AccountRef(msg.From) - isContract := len(k.evmState.GetCode(account)) > 0 - if isContract { - cOwner := k.checkContractOwner(ctx, &account, msg.Nonce+1, msg.GasLimit, sender.Address()) - if !cOwner { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "check sender isOwner fail, sender: %s , contract: %s", sender.Address().String(), account.String()) - } - } else if account != sender.Address() { - // For EoA account binding, only the account itself can issue the bind request - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "unauthorized EoA account aspect binding") - } - code, _ := k.aspectService.GetAspectCode(ctx, aspectId, versionU256) - if len(code) == 0 { - return nil, errorsmod.Wrapf(evmtypes.ErrAspectNotFound, "aspect %s ,version %s not found", aspectId.String(), versionU256.String()) - } - - return k.bind(ctx, aspectId, account, versionU256, priority, isContract) - } - - case "unbind": - { - aspectId := parameters["aspectId"].(common.Address) - account := parameters["contract"].(common.Address) - sender := vm.AccountRef(msg.From) - isContract := len(k.evmState.GetCode(account)) > 0 - if isContract { - cOwner := k.checkContractOwner(ctx, &account, msg.Nonce+1, msg.GasLimit, sender.Address()) - // Bind with contract account, need to verify contract ownerships first - if !cOwner { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "check sender isOwner fail, sender: %s , contract: %s", sender.Address().String(), account.String()) - } - } else if account != sender.Address() { - // For EoA account binding, only the account itself can issue the bind request - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "unauthorized EoA account aspect unbinding") - } - return k.unbind(ctx, aspectId, account, isContract) - - } - case "changeversion": - { - aspectId := parameters["aspectId"].(common.Address) - contract := parameters["contract"].(common.Address) - version := parameters["version"].(uint64) - sender := vm.AccountRef(msg.From) - aspectOwner, err := k.checkAspectOwner(ctx, aspectId, sender.Address(), msg.GasLimit, commit) - if err != nil { - return nil, err - } - if !aspectOwner { - return nil, errorsmod.Wrapf(evmtypes.ErrCallContract, "failed to check if the sender is the owner, unable to changeversion, sender: %s , contract: %s", sender.Address().String(), contract.String()) - } - return k.changeVersion(ctx, aspectId, contract, version) - } - case "versionof": - { - aspectId := parameters["aspectId"].(common.Address) - return k.version(ctx, method, aspectId) - } - - case "aspectsof": - { - account := parameters["contract"].(common.Address) - isContract := len(k.evmState.GetCode(account)) > 0 - - return k.aspectsOf(ctx, method, account, isContract) - } + handler, ok := c.handlers[strings.ToLower(method.Name)] + if !ok { + return nil, 0, errorsmod.Wrapf(evmtypes.ErrCallContract, "method %s not found", method.Name) + } - case "boundaddressesof": - { - aspectId := parameters["aspectId"].(common.Address) - return k.boundAddressesOf(ctx, method, aspectId) - } - case "entrypoint": - { - aspectId := parameters["aspectId"].(common.Address) - data := parameters["optArgs"].([]byte) - return k.entrypoint(ctx, msg, method, aspectId, data, commit) - } + handlerCtx := &HandlerContext{ + ctx, + msg.From, + parameters, + commit, + c.aspectService, + common.WrapLogger(c.logger.With("module", "aspect-system-contract")), + c.evmState, + c.evm, + method, + msg.Data, + msg.Nonce, + msg.GasLimit, + msg.GasPrice, + msg.GasTipCap, + msg.GasFeeCap, } - return nil, nil + + return handler.Handle(handlerCtx, gas) } diff --git a/x/evm/artela/contract/contract_func.go b/x/evm/artela/contract/contract_func.go deleted file mode 100644 index 8bf195d6..00000000 --- a/x/evm/artela/contract/contract_func.go +++ /dev/null @@ -1,367 +0,0 @@ -package contract - -import ( - "math/big" - - "github.com/artela-network/artela-evm/vm" - "github.com/artela-network/aspect-core/djpm/contract" - "github.com/artela-network/aspect-core/djpm/run" - artelasdkType "github.com/artela-network/aspect-core/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/holiman/uint256" - "github.com/pkg/errors" - - "github.com/artela-network/artela/x/evm/artela/types" - evmtypes "github.com/artela-network/artela/x/evm/txs" -) - -func (anc *AspectNativeContract) entrypoint(ctx sdk.Context, msg *core.Message, method *abi.Method, aspectId common.Address, data []byte, commit bool) (*evmtypes.MsgEthereumTxResponse, error) { - lastHeight := ctx.BlockHeight() - code, version := anc.aspectService.GetAspectCode(ctx, aspectId, nil) - - aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) - if !ok { - return nil, errors.New("AspectNativeContract.entrypoint: unwrap AspectRuntimeContext failed") - } - runner, newErr := run.NewRunner(aspectCtx, ctx.Logger(), aspectId.String(), version.Uint64(), code, commit) - if newErr != nil { - return nil, newErr - } - defer runner.Return() - - var txHash []byte - ethTxCtx := aspectCtx.EthTxContext() - if ethTxCtx != nil { - ethTxContent := ethTxCtx.TxContent() - if ethTxContent != nil { - txHash = ethTxContent.Hash().Bytes() - } - } - height := uint64(lastHeight) - // ignore gas output for now, since we haven't implemented gas metering for aspect for now - ret, _, err := runner.JoinPoint(artelasdkType.OPERATION_METHOD, msg.GasLimit, lastHeight, msg.To, &artelasdkType.OperationInput{ - Tx: &artelasdkType.WithFromTxInput{ - Hash: txHash, - To: msg.To.Bytes(), - From: msg.From.Bytes(), - }, - Block: &artelasdkType.BlockInput{Number: &height}, - CallData: data, - }) - var vmError string - var retByte []byte - if err != nil { - vmError = err.Error() - } else { - retByte, err = method.Outputs.Pack(ret) - if err != nil { - vmError = err.Error() - } - } - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: vmError, - Ret: retByte, - Logs: nil, - }, nil -} - -func (anc *AspectNativeContract) boundAddressesOf(ctx sdk.Context, method *abi.Method, aspectId common.Address) (*evmtypes.MsgEthereumTxResponse, error) { - value, err := anc.aspectService.GetAspectOf(ctx, aspectId) - if err != nil { - return nil, err - } - addressAry := make([]common.Address, 0) - for _, data := range value.Values() { - contractAddr := common.HexToAddress(data.(string)) - addressAry = append(addressAry, contractAddr) - } - - ret, err := method.Outputs.Pack(addressAry) - if err != nil { - return nil, err - } - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: ret, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) bind(ctx sdk.Context, aspectId common.Address, account common.Address, aspectVersion *uint256.Int, priority int8, isContract bool) (*evmtypes.MsgEthereumTxResponse, error) { - // check aspect types - aspectJP := k.aspectService.aspectStore.GetAspectJP(ctx, aspectId, aspectVersion) - txAspect := artelasdkType.CheckIsTransactionLevel(aspectJP.Int64()) - txVerifier := artelasdkType.CheckIsTxVerifier(aspectJP.Int64()) - - if !(txAspect || txVerifier) { - return nil, errors.New("check aspect join point fail, An aspect which can be bound, must be a transactional or Verifier") - } - // EoA can only bind with tx verifier - if !txVerifier && !isContract { - return nil, errors.New("unable to bind non-tx-verifier Aspect to an EoA account") - } - - // bind tx processing aspect if account is a contract - if txAspect && isContract { - if err := k.aspectService.aspectStore.BindTxAspect(ctx, account, aspectId, aspectVersion, priority); err != nil { - return nil, err - } - } - - // bind tx verifier aspect - if txVerifier { - if err := k.aspectService.aspectStore.BindVerificationAspect(ctx, account, aspectId, aspectVersion, priority, isContract); err != nil { - return nil, err - } - } - - // save reverse index - if err := k.aspectService.aspectStore.StoreAspectRefValue(ctx, account, aspectId); err != nil { - return nil, err - } - - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: nil, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) unbind(ctx sdk.Context, aspectId common.Address, contract common.Address, isContract bool) (*evmtypes.MsgEthereumTxResponse, error) { - // contract=>aspect object - // aspectId= [contract,contract] - if !isContract { - if err := k.aspectService.aspectStore.UnBindVerificationAspect(ctx, contract, aspectId); err != nil { - return nil, err - } - } - if err := k.aspectService.aspectStore.UnBindContractAspects(ctx, contract, aspectId); err != nil { - return nil, err - } - if err := k.aspectService.aspectStore.UnbindAspectRefValue(ctx, contract, aspectId); err != nil { - return nil, err - } - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: nil, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) changeVersion(ctx sdk.Context, aspectId common.Address, contract common.Address, version uint64) (*evmtypes.MsgEthereumTxResponse, error) { - err := k.aspectService.aspectStore.ChangeBoundAspectVersion(ctx, contract, aspectId, version) - if err != nil { - return nil, err - } - - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: 100, - VmError: "", - Ret: nil, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) version(ctx sdk.Context, method *abi.Method, aspectId common.Address) (*evmtypes.MsgEthereumTxResponse, error) { - version := k.aspectService.aspectStore.GetAspectLastVersion(ctx, aspectId) - - ret, err := method.Outputs.Pack(version.Uint64()) - if err != nil { - return nil, err - } - - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: 100, - VmError: "", - Ret: ret, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) aspectsOf(ctx sdk.Context, method *abi.Method, contract common.Address, isContract bool) (*evmtypes.MsgEthereumTxResponse, error) { - - aspectInfo := make([]types.AspectInfo, 0) - deduplicationMap := make(map[string]uint64, 0) - if isContract { - aspects, err := k.aspectService.GetBoundAspectForAddr(ctx, contract) - if err != nil { - return nil, err - } - aspectAccounts, verErr := k.aspectService.GetAccountVerifiers(ctx, contract) - if verErr != nil { - return nil, verErr - } - - for _, aspect := range aspects { - if _, exist := deduplicationMap[aspect.AspectId]; exist { - continue - } - deduplicationMap[aspect.AspectId] = aspect.Version - info := types.AspectInfo{ - AspectId: common.HexToAddress(aspect.AspectId), - Version: aspect.Version, - Priority: int8(aspect.Priority), - } - aspectInfo = append(aspectInfo, info) - } - - for _, aspect := range aspectAccounts { - if _, exist := deduplicationMap[aspect.AspectId]; exist { - continue - } - deduplicationMap[aspect.AspectId] = aspect.Version - info := types.AspectInfo{ - AspectId: common.HexToAddress(aspect.AspectId), - Version: aspect.Version, - Priority: int8(aspect.Priority), - } - aspectInfo = append(aspectInfo, info) - } - - } else { - aspectAccounts, verErr := k.aspectService.GetAccountVerifiers(ctx, contract) - if verErr != nil { - return nil, verErr - } - for _, aspect := range aspectAccounts { - if _, exist := deduplicationMap[aspect.AspectId]; exist { - continue - } - deduplicationMap[aspect.AspectId] = aspect.Version - info := types.AspectInfo{ - AspectId: common.HexToAddress(aspect.AspectId), - Version: aspect.Version, - Priority: int8(aspect.Priority), - } - aspectInfo = append(aspectInfo, info) - } - } - - ret, pkErr := method.Outputs.Pack(aspectInfo) - if pkErr != nil { - return nil, pkErr - } - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: ret, - Logs: nil, - }, nil -} - -func (k *AspectNativeContract) checkContractOwner(ctx sdk.Context, to *common.Address, nonce uint64, gas uint64, sender common.Address) bool { - msg, err := contract.ArtelaOwnerMsg(to, nonce, sender, gas) - if err != nil { - return false - } - fromAccount := vm.AccountRef(msg.From) - k.evm.CloseAspectCall() - defer k.evm.AspectCall() - - aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) - if !ok { - return false - } - ret, _, err := k.evm.Call(aspectCtx, fromAccount, *msg.To, msg.Data, msg.GasLimit, msg.Value) - if err != nil { - return false - } - result, err := contract.UnpackIsOwnerResult(ret) - if err != nil { - return false - } - return result -} -func (k *AspectNativeContract) checkAspectCode(ctx sdk.Context, aspectId common.Address, aspectCode []byte, commit bool) error { - - aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) - if !ok { - return errors.New("checkAspectOwner: unwrap AspectRuntimeContext failed") - } - runner, newErr := run.NewRunner(aspectCtx, ctx.Logger(), aspectId.String(), 1, aspectCode, commit) - if newErr != nil { - return newErr - } - defer runner.Return() - - return nil -} - -func (k *AspectNativeContract) checkAspectOwner(ctx sdk.Context, aspectId common.Address, sender common.Address, gas uint64, commit bool) (bool, error) { - bHeight := ctx.BlockHeight() - code, ver := k.aspectService.GetAspectCode(ctx, aspectId, nil) - if code == nil { - return false, nil - } - - aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) - if !ok { - return false, errors.New("checkAspectOwner: unwrap AspectRuntimeContext failed") - } - runner, newErr := run.NewRunner(aspectCtx, ctx.Logger(), aspectId.String(), ver.Uint64(), code, commit) - if newErr != nil { - return false, newErr - } - defer runner.Return() - - binding, runErr := runner.IsOwner(bHeight, gas, &sender, sender.Bytes()) - return binding, runErr -} - -func (k *AspectNativeContract) deploy(ctx sdk.Context, aspectId common.Address, code []byte, properties []types.Property, joinPoint *big.Int) (*evmtypes.MsgEthereumTxResponse, error) { - if len(code) == 0 && len(properties) == 0 && joinPoint == nil { - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: nil, - Logs: nil, - }, nil - } - _, aspectVersion := k.aspectService.aspectStore.GetAspectCode(ctx, aspectId, nil) - if len(code) > 0 { - // upgrade here may be 0 - aspectVersion = k.aspectService.aspectStore.StoreAspectCode(ctx, aspectId, code) - } - - if joinPoint != nil { - err := k.aspectService.aspectStore.StoreAspectJP(ctx, aspectId, aspectVersion, joinPoint) - if err != nil { - return nil, err - } - } - - if len(properties) > 0 { - err := k.aspectService.aspectStore.StoreAspectProperty(ctx, aspectId, properties) - if err != nil { - return nil, err - } - } - - level := artelasdkType.CheckIsBlockLevel(joinPoint.Int64()) - if level { - storeErr := k.aspectService.aspectStore.StoreBlockLevelAspect(ctx, aspectId) - if storeErr != nil { - return nil, storeErr - } - } else { - // for k.update,one aspect trans to tx level - removeErr := k.aspectService.aspectStore.RemoveBlockLevelAspect(ctx, aspectId) - if removeErr != nil { - return nil, removeErr - } - } - - return &evmtypes.MsgEthereumTxResponse{ - GasUsed: ctx.GasMeter().GasConsumed(), - VmError: "", - Ret: nil, - Logs: nil, - }, nil -} diff --git a/x/evm/artela/contract/handlers.go b/x/evm/artela/contract/handlers.go new file mode 100644 index 00000000..76fefa12 --- /dev/null +++ b/x/evm/artela/contract/handlers.go @@ -0,0 +1,835 @@ +package contract + +import ( + "bytes" + "errors" + "fmt" + "math/big" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/holiman/uint256" + + "github.com/artela-network/artela-evm/vm" + common2 "github.com/artela-network/artela/common" + "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/aspect-core/djpm/contract" + "github.com/artela-network/aspect-core/djpm/run" + artelasdkType "github.com/artela-network/aspect-core/types" + runtime "github.com/artela-network/aspect-runtime" + runtimeTypes "github.com/artela-network/aspect-runtime/types" +) + +var ( + zero = uint256.NewInt(0) + one = uint256.NewInt(1) + emptyAddr = common.Address{} +) + +type HandlerContext struct { + cosmosCtx sdk.Context + from common.Address + parameters map[string]interface{} + commit bool + service *AspectService + logger runtimeTypes.Logger + evmState *states.StateDB + evm *vm.EVM + abi *abi.Method + + rawInput []byte + nonce uint64 + gasLimit uint64 + gasPrice *big.Int + gasTipCap *big.Int + gasFeeCap *big.Int +} + +type Handler interface { + Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) + Method() string +} + +type DeployHandler struct{} + +func (h DeployHandler) Handle(ctx *HandlerContext, gas uint64) ([]byte, uint64, error) { + aspectId, code, initData, properties, joinPoint, err := h.decodeAndValidate(ctx) + if err != nil { + ctx.logger.Error("deploy aspect failed", "error", err, "from", ctx.from, "gasLimit", ctx.gasLimit) + return nil, 0, err + } + + store := ctx.service.aspectStore + newVersion, gas, err := store.BumpAspectVersion(ctx.cosmosCtx, aspectId, gas) + if err != nil { + ctx.logger.Error("bump aspect version failed", "error", err) + return nil, gas, err + } + + gas, err = store.StoreAspectCode(ctx.cosmosCtx, aspectId, code, newVersion, gas) + if err != nil { + ctx.logger.Error("store aspect code failed", "error", err) + return nil, gas, err + } + + // join point might be nil, since there are some operation only Aspects + if joinPoint != nil { + store.StoreAspectJP(ctx.cosmosCtx, aspectId, *newVersion, joinPoint) + } + + if len(properties) > 0 { + gas, err = store.StoreAspectProperty(ctx.cosmosCtx, aspectId, properties, gas) + if err != nil { + ctx.logger.Error("store aspect property failed", "error", err) + } + } + + // initialize aspect + aspectCtx := mustGetAspectContext(ctx.cosmosCtx) + runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectId.String(), newVersion.Uint64(), code, ctx.commit) + if err != nil { + ctx.logger.Error("failed to create aspect runner", "error", err) + return nil, 0, err + } + defer runner.Return() + + var txHash []byte + ethTxCtx := aspectCtx.EthTxContext() + if ethTxCtx != nil && ethTxCtx.TxContent() != nil { + txHash = ethTxCtx.TxContent().Hash().Bytes() + } + + height := ctx.cosmosCtx.BlockHeight() + heightU64 := uint64(height) + + return runner.JoinPoint(artelasdkType.INIT_METHOD, gas, height, aspectId, &artelasdkType.InitInput{ + Tx: &artelasdkType.WithFromTxInput{ + Hash: txHash, + To: aspectId.Bytes(), + From: ctx.from.Bytes(), + }, + Block: &artelasdkType.BlockInput{Number: &heightU64}, + CallData: initData, + }) +} + +func (h DeployHandler) Method() string { + return "deploy" +} + +func (h DeployHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.Address, code, initData []byte, properties []types.Property, joinPoint *big.Int, err error) { + // input validations + code = ctx.parameters["code"].([]byte) + if len(code) == 0 { + err = errors.New("code is empty") + return + } + + initData = ctx.parameters["initdata"].([]byte) + + propertiesArr := ctx.parameters["properties"].([]struct { + Key string `json:"key"` + Value []byte `json:"value"` + }) + + for i := range propertiesArr { + s := propertiesArr[i] + if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { + // Block query of account and Proof + err = errors.New("using reserved aspect property key") + return + } + + properties = append(properties, types.Property{ + Key: s.Key, + Value: s.Value, + }) + } + + account := ctx.parameters["account"].(common.Address) + if bytes.Equal(account.Bytes(), ctx.from.Bytes()) { + accountProperty := types.Property{ + Key: types.AspectAccountKey, + Value: account.Bytes(), + } + properties = append(properties, accountProperty) + } else { + err = errors.New("account verification fail") + return + } + + proof := ctx.parameters["proof"].([]byte) + proofProperty := types.Property{ + Key: types.AspectProofKey, + Value: proof, + } + properties = append(properties, proofProperty) + + joinPoint = ctx.parameters["joinPoints"].(*big.Int) + if joinPoint == nil { + err = errors.New("unable to decode join point") + return + } + + aspectId = crypto.CreateAddress(ctx.from, ctx.nonce) + + // check duplicate deployment + if isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { + err = errors.New("aspect already deployed") + return + } + + // validate aspect code + code, err = validateCode(ctx.cosmosCtx, code) + return +} + +type UpgradeHandler struct{} + +func (h UpgradeHandler) Handle(ctx *HandlerContext, gas uint64) ([]byte, uint64, error) { + aspectId, code, properties, joinPoint, gas, err := h.decodeAndValidate(ctx, gas) + if err != nil { + return nil, gas, err + } + + store := ctx.service.aspectStore + newVersion, gas, err := store.BumpAspectVersion(ctx.cosmosCtx, aspectId, gas) + if err != nil { + ctx.logger.Error("bump aspect version failed", "error", err) + return nil, gas, err + } + + if gas, err = store.StoreAspectCode(ctx.cosmosCtx, aspectId, code, newVersion, gas); err != nil { + ctx.logger.Error("store aspect code failed", "error", err) + return nil, gas, err + } + + // join point might be nil, since there are some operation only Aspects + if joinPoint != nil { + store.StoreAspectJP(ctx.cosmosCtx, aspectId, *newVersion, joinPoint) + } + + if len(properties) > 0 { + gas, err = store.StoreAspectProperty(ctx.cosmosCtx, aspectId, properties, gas) + } + + return nil, gas, err +} + +func (h UpgradeHandler) Method() string { + return "upgrade" +} + +func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) (aspectId common.Address, + code []byte, + properties []types.Property, + joinPoint *big.Int, leftover uint64, err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspectId not specified") + return + } + + // input validations + code = ctx.parameters["code"].([]byte) + if len(code) == 0 { + err = errors.New("code is empty") + return + } + + propertiesArr := ctx.parameters["properties"].([]struct { + Key string `json:"key"` + Value []byte `json:"value"` + }) + + for i := range propertiesArr { + s := propertiesArr[i] + if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { + // Block query of account and Proof + err = errors.New("using reserved aspect property key") + return + } + + properties = append(properties, types.Property{ + Key: s.Key, + Value: s.Value, + }) + } + + joinPoint = ctx.parameters["joinPoints"].(*big.Int) + if joinPoint == nil { + joinPoint = big.NewInt(0) + } + + // check deployment + store := ctx.service.aspectStore + if !isAspectDeployed(ctx.cosmosCtx, store, aspectId) { + err = errors.New("aspect not deployed") + return + } + + // check aspect owner + currentCode, version := store.GetAspectCode(ctx.cosmosCtx, aspectId, nil) + + var ok bool + ok, leftover, err = checkAspectOwner(ctx.cosmosCtx, aspectId, ctx.from, gas, currentCode, version, ctx.commit) + if err != nil || !ok { + err = errors.New("aspect ownership validation failed") + return + } + + // validate aspect code + code, err = validateCode(ctx.cosmosCtx, code) + return +} + +type BindHandler struct{} + +func (b BindHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, account, aspectVersion, priority, isContract, leftover, err := b.decodeAndValidate(ctx, gas) + if err != nil { + return nil, leftover, err + } + + // check aspect types + store := ctx.service.aspectStore + aspectJP, err := store.GetAspectJP(ctx.cosmosCtx, aspectId, aspectVersion) + if err != nil { + return nil, leftover, err + } + + txAspect := artelasdkType.CheckIsTransactionLevel(aspectJP.Int64()) + txVerifier := artelasdkType.CheckIsTxVerifier(aspectJP.Int64()) + + if !txAspect && !txVerifier { + return nil, 0, errors.New("aspect is either for tx or verifier") + } + + // EoA can only bind with tx verifier + if !txVerifier && !isContract { + return nil, 0, errors.New("only verifier aspect can be bound with eoa") + } + + // bind tx processing aspect if account is a contract + if txAspect && isContract { + if err := store.BindTxAspect(ctx.cosmosCtx, account, aspectId, aspectVersion, priority); err != nil { + ctx.logger.Error("bind tx aspect failed", "aspect", aspectId.Hex(), "version", aspectVersion.Uint64(), "contract", account.Hex(), "error", err) + return nil, 0, err + } + } + + // bind tx verifier aspect + if txVerifier { + if err := store.BindVerificationAspect(ctx.cosmosCtx, account, aspectId, aspectVersion, priority, isContract); err != nil { + ctx.logger.Error("bind verifier aspect failed", "aspect", aspectId.Hex(), "version", aspectVersion.Uint64(), "account", account.Hex(), "error", err) + return nil, 0, err + } + } + + // save reverse index + if err := store.StoreAspectRefValue(ctx.cosmosCtx, account, aspectId); err != nil { + return nil, 0, err + } + + return nil, leftover, nil +} + +func (b BindHandler) Method() string { + return "bind" +} + +func (b BindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( + aspectId common.Address, + account common.Address, + aspectVersion *uint256.Int, + priority int8, + isContract bool, + leftover uint64, + err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspectId not specified") + return + } + + version := ctx.parameters["aspectVersion"].(*big.Int) + if version != nil && version.Sign() < 0 { + err = errors.New("aspectVersion is negative") + return + } + + account = ctx.parameters["contract"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), account.Bytes()) { + err = errors.New("binding account not specified") + return + } + + priority = ctx.parameters["priority"].(int8) + + store := ctx.service.aspectStore + if !isAspectDeployed(ctx.cosmosCtx, store, aspectId) { + err = errors.New("aspect not deployed") + return + } + + isContract = len(ctx.evmState.GetCode(account)) > 0 + if isContract { + var isOwner bool + isOwner, leftover = checkContractOwner(ctx, account, gas) + if !isOwner { + err = errors.New("contract ownership validation failed") + return + } + } else if !bytes.Equal(account.Bytes(), ctx.from.Bytes()) { + err = errors.New("unauthorized EoA account aspect binding") + return + } else { + leftover = gas + } + + aspectVersion, _ = uint256.FromBig(version) + + // overwrite aspect version, just in case if aspect version is 0 which means we will need to overwrite + // it to latest + if aspectVersion == nil || aspectVersion.Cmp(zero) <= 0 { + aspectVersion = ctx.service.aspectStore.GetAspectLastVersion(ctx.cosmosCtx, aspectId) + } + + return +} + +type UnbindHandler struct{} + +func (u UnbindHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, account, isContract, leftover, err := u.decodeAndValidate(ctx, gas) + if err != nil { + return nil, leftover, err + } + + store := ctx.service.aspectStore + + if err := store.UnBindVerificationAspect(ctx.cosmosCtx, account, aspectId); err != nil { + return nil, leftover, err + } + if isContract { + if err := store.UnBindContractAspects(ctx.cosmosCtx, account, aspectId); err != nil { + return nil, leftover, err + } + } + + if err := store.UnbindAspectRefValue(ctx.cosmosCtx, account, aspectId); err != nil { + return nil, leftover, err + } + + return nil, leftover, nil +} + +func (u UnbindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( + aspectId common.Address, + account common.Address, + isContract bool, + leftover uint64, + err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspectId not specified") + return + } + + account = ctx.parameters["contract"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), account.Bytes()) { + err = errors.New("binding account not specified") + return + } + + isContract = len(ctx.evmState.GetCode(account)) > 0 + if isContract { + var isOwner bool + isOwner, leftover = checkContractOwner(ctx, account, gas) + if !isOwner { + err = errors.New("contract ownership validation failed") + } + } else if !bytes.Equal(account.Bytes(), ctx.from.Bytes()) { + err = errors.New("unauthorized EoA account aspect binding") + } else { + leftover = gas + } + + return +} + +func (u UnbindHandler) Method() string { + return "unbind" +} + +type ChangeVersionHandler struct{} + +func (c ChangeVersionHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, account, version, isContract, leftover, err := c.decodeAndValidate(ctx, gas) + if err != nil { + return nil, leftover, err + } + + aspectJP, err := ctx.service.aspectStore.GetAspectJP(ctx.cosmosCtx, aspectId, uint256.NewInt(version)) + if err != nil { + return nil, leftover, err + } + + txAspect := artelasdkType.CheckIsTransactionLevel(aspectJP.Int64()) + verifierAspect := artelasdkType.CheckIsTxVerifier(aspectJP.Int64()) + + if !txAspect && !verifierAspect { + return nil, leftover, errors.New("aspect is either for tx or verifier") + } + + if !verifierAspect && !isContract { + return nil, 0, errors.New("only verifier aspect can be bound with eoa") + } + + err = ctx.service.aspectStore.ChangeBoundAspectVersion(ctx.cosmosCtx, account, aspectId, version, isContract, verifierAspect, txAspect) + remainingGas = leftover + return +} + +func (c ChangeVersionHandler) Method() string { + return "changeversion" +} + +func (c ChangeVersionHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( + aspectId common.Address, + account common.Address, + version uint64, + isContract bool, + leftover uint64, + err error, +) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspectId not specified") + return + } + + account = ctx.parameters["contract"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), account.Bytes()) { + err = errors.New("binding account not specified") + return + } + + // should check whether expected version is greater than + // the latest version we have, if so, the designated aspect + // does not exist yet + version = ctx.parameters["version"].(uint64) + store := ctx.service.aspectStore + latestVersion := store.GetAspectLastVersion(ctx.cosmosCtx, aspectId) + if latestVersion == nil || latestVersion.Cmp(zero) == 0 || latestVersion.Uint64() < version { + err = errors.New("given version of aspect does not exist") + return + } + if version == 0 { + version = latestVersion.Uint64() + } + + if isContract = len(ctx.evmState.GetCode(account)) > 0; isContract { + var isOwner bool + if isOwner, leftover = checkContractOwner(ctx, account, gas); !isOwner { + err = errors.New("unauthorized operation") + } + } else if !bytes.Equal(account.Bytes(), ctx.from.Bytes()) { + err = errors.New("unauthorized operation") + } else { + leftover = gas + } + + return +} + +type GetVersionHandler struct{} + +func (g GetVersionHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, err := g.decodeAndValidate(ctx) + if err != nil { + return nil, 0, err + } + + version := ctx.service.aspectStore.GetAspectLastVersion(ctx.cosmosCtx, aspectId) + + ret, err = ctx.abi.Outputs.Pack(version.Uint64()) + if err != nil { + return nil, gas, err + } + + return ret, gas, nil +} + +func (g GetVersionHandler) Method() string { + return "versionof" +} + +func (g GetVersionHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.Address, err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspectId not specified") + return + } + + return +} + +type GetBindingHandler struct{} + +func (g GetBindingHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + account, isContract, err := g.decodeAndValidate(ctx) + if err != nil { + return nil, 0, err + } + + aspectInfo := make([]types.AspectInfo, 0) + deduplicationMap := make(map[common.Address]struct{}) + + accountVerifiers, err := ctx.service.aspectStore.GetVerificationAspects(ctx.cosmosCtx, account) + if err != nil { + return nil, 0, err + } + + for _, aspect := range accountVerifiers { + if _, exist := deduplicationMap[aspect.Id]; exist { + continue + } + deduplicationMap[aspect.Id] = struct{}{} + info := types.AspectInfo{ + AspectId: aspect.Id, + Version: aspect.Version.Uint64(), + Priority: int8(aspect.Priority), + } + aspectInfo = append(aspectInfo, info) + } + + if isContract { + txLevelAspects, err := ctx.service.aspectStore.GetTxLevelAspects(ctx.cosmosCtx, account) + if err != nil { + return nil, 0, err + } + + for _, aspect := range txLevelAspects { + if _, exist := deduplicationMap[aspect.Id]; exist { + continue + } + deduplicationMap[aspect.Id] = struct{}{} + info := types.AspectInfo{ + AspectId: aspect.Id, + Version: aspect.Version.Uint64(), + Priority: int8(aspect.Priority), + } + aspectInfo = append(aspectInfo, info) + } + } + + ret, err = ctx.abi.Outputs.Pack(aspectInfo) + return ret, gas, err +} + +func (g GetBindingHandler) Method() string { + return "aspectsof" +} + +func (g GetBindingHandler) decodeAndValidate(ctx *HandlerContext) (account common.Address, isContract bool, err error) { + account = ctx.parameters["contract"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), account.Bytes()) { + err = errors.New("binding account not specified") + return + } + + isContract = len(ctx.evmState.GetCode(account)) > 0 + return +} + +type GetBoundAddressHandler struct{} + +func (g GetBoundAddressHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, err := g.decodeAndValidate(ctx) + if err != nil { + return nil, 0, err + } + + value, err := ctx.service.GetAspectOf(ctx.cosmosCtx, aspectId) + if err != nil { + return nil, 0, err + } + addressArr := make([]common.Address, 0) + if value != nil { + for _, data := range value.Values() { + contractAddr := common.HexToAddress(data.(string)) + addressArr = append(addressArr, contractAddr) + } + } + + ret, err = ctx.abi.Outputs.Pack(addressArr) + return ret, gas, err +} + +func (g GetBoundAddressHandler) Method() string { + return "boundaddressesof" +} + +func (g GetBoundAddressHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.Address, err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspect id not specified") + return + } + + if !isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { + err = errors.New("aspect not deployed") + } + + return +} + +type OperationHandler struct{} + +func (o OperationHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { + aspectId, args, err := o.decodeAndValidate(ctx) + if err != nil { + return nil, 0, err + } + + lastHeight := ctx.cosmosCtx.BlockHeight() + code, version := ctx.service.GetAspectCode(ctx.cosmosCtx, aspectId, nil) + + aspectCtx := mustGetAspectContext(ctx.cosmosCtx) + runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectId.String(), version.Uint64(), code, ctx.commit) + if err != nil { + ctx.logger.Error("failed to create aspect runner", "error", err) + return nil, 0, err + } + defer runner.Return() + + var txHash []byte + ethTxCtx := aspectCtx.EthTxContext() + if ethTxCtx != nil && ethTxCtx.TxContent() != nil { + txHash = ethTxCtx.TxContent().Hash().Bytes() + } + height := uint64(lastHeight) + ret, remainingGas, err = runner.JoinPoint(artelasdkType.OPERATION_METHOD, gas, lastHeight, aspectId, &artelasdkType.OperationInput{ + Tx: &artelasdkType.WithFromTxInput{ + Hash: txHash, + To: aspectId.Bytes(), + From: ctx.from.Bytes(), + }, + Block: &artelasdkType.BlockInput{Number: &height}, + CallData: args, + }) + if err == nil { + ret, err = ctx.abi.Outputs.Pack(ret) + if err != nil { + ctx.logger.Error("failed to pack operation output", "error", err) + } + } + + return +} + +func (o OperationHandler) Method() string { + return "entrypoint" +} + +func (o OperationHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.Address, args []byte, err error) { + aspectId = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + err = errors.New("aspect id not specified") + return + } + + if !isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { + err = errors.New("aspect not deployed") + return + } + + args = ctx.parameters["optArgs"].([]byte) + return +} + +func isAspectDeployed(ctx sdk.Context, store *AspectStore, aspectId common.Address) bool { + return store.GetAspectLastVersion(ctx, aspectId).Cmp(zero) > 0 +} + +func validateCode(ctx sdk.Context, aspectCode []byte) ([]byte, error) { + startTime := time.Now() + validator, err := runtime.NewValidator(ctx, common2.WrapLogger(ctx.Logger()), runtime.WASM) + if err != nil { + return nil, err + } + ctx.Logger().Info("validated aspect bytecode", "duration", time.Since(startTime).String()) + + startTime = time.Now() + parsed, err := ParseByteCode(aspectCode) + if err != nil { + return nil, err + } + ctx.Logger().Info("parsed aspect bytecode", "duration", time.Since(startTime).String()) + + return parsed, validator.Validate(parsed) +} + +func checkContractOwner(ctx *HandlerContext, contractAddr common.Address, gas uint64) (bool, uint64) { + msg, err := contract.ArtelaOwnerMsg(&contractAddr, ctx.nonce, ctx.from, gas, ctx.gasPrice, ctx.gasFeeCap, ctx.gasTipCap) + if err != nil { + return false, 0 + } + fromAccount := vm.AccountRef(msg.From) + ctx.evm.CloseAspectCall() + defer ctx.evm.AspectCall() + + aspectCtx := mustGetAspectContext(ctx.cosmosCtx) + ret, leftover, err := ctx.evm.Call(aspectCtx, fromAccount, *msg.To, msg.Data, gas, msg.Value) + if err != nil { + // if fail, fallback to openzeppelin ownable + msg, err = contract.OpenZeppelinOwnableMsg(&contractAddr, ctx.nonce, ctx.from, gas, ctx.gasPrice, ctx.gasFeeCap, ctx.gasTipCap) + if err != nil { + return false, 0 + } + + ret, leftover, err = ctx.evm.Call(aspectCtx, fromAccount, *msg.To, msg.Data, gas, msg.Value) + if err != nil { + return false, leftover + } + + result, err := contract.UnpackOwnableOwnerResult(ret) + if err != nil { + return false, leftover + } + + return bytes.Equal(result.Bytes(), ctx.from.Bytes()), leftover + } + + result, err := contract.UnpackIsOwnerResult(ret) + if err != nil { + return false, leftover + } + return result, leftover +} + +func checkAspectOwner(ctx sdk.Context, aspectId common.Address, sender common.Address, gas uint64, code []byte, version *uint256.Int, commit bool) (bool, uint64, error) { + aspectCtx := mustGetAspectContext(ctx) + runner, err := run.NewRunner(aspectCtx, common2.WrapLogger(ctx.Logger()), aspectId.String(), version.Uint64(), code, commit) + if err != nil { + panic(fmt.Sprintf("failed to create runner: %v", err)) + } + defer runner.Return() + + return runner.IsOwner(ctx.BlockHeight(), gas, sender, sender.Bytes()) +} + +// retrieving aspect context from sdk.Context must not fail, so we panic if it does +func mustGetAspectContext(ctx sdk.Context) *types.AspectRuntimeContext { + aspectCtx, ok := ctx.Value(types.AspectContextKey).(*types.AspectRuntimeContext) + if !ok { + panic("unable to get aspect context, this should not happen") + } + + return aspectCtx +} diff --git a/x/evm/artela/contract/service.go b/x/evm/artela/contract/service.go index 13197c60..f82ee4a8 100644 --- a/x/evm/artela/contract/service.go +++ b/x/evm/artela/contract/service.go @@ -2,9 +2,7 @@ package contract import ( "math/big" - "sort" - artela "github.com/artela-network/aspect-core/types" "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,10 +12,7 @@ import ( "github.com/pkg/errors" evmtypes "github.com/artela-network/artela/x/evm/artela/types" -) - -type ( - heightRetriever func() int64 + artela "github.com/artela-network/aspect-core/types" ) type AspectService struct { @@ -34,7 +29,6 @@ func NewAspectService(storeKey storetypes.StoreKey, } func (service *AspectService) GetAspectOf(ctx sdk.Context, aspectId common.Address) (*treeset.Set, error) { - aspects, err := service.aspectStore.GetAspectRefValue(ctx, aspectId) if err != nil { return nil, errors.Wrap(err, "load aspect ref failed") @@ -43,12 +37,12 @@ func (service *AspectService) GetAspectOf(ctx sdk.Context, aspectId common.Addre } func (service *AspectService) GetAspectCode(ctx sdk.Context, aspectId common.Address, version *uint256.Int) ([]byte, *uint256.Int) { - - if version == nil { + if version == nil || version.Cmp(zero) <= 0 { version = service.aspectStore.GetAspectLastVersion(ctx, aspectId) } return service.aspectStore.GetAspectCode(ctx, aspectId, version) } + func (service *AspectService) GetBoundAspectForAddr(sdkCtx sdk.Context, to common.Address) ([]*artela.AspectCode, error) { aspects, err := service.aspectStore.GetTxLevelAspects(sdkCtx, to) if err != nil { @@ -73,7 +67,6 @@ func (service *AspectService) GetBoundAspectForAddr(sdkCtx sdk.Context, to commo // GetAspectsForJoinPoint BoundAspects get bound Aspects on previous block func (service *AspectService) GetAspectsForJoinPoint(ctx sdk.Context, to common.Address, cut artela.PointCut) ([]*artela.AspectCode, error) { - aspects, err := service.aspectStore.GetTxLevelAspects(ctx, to) if err != nil { @@ -86,7 +79,11 @@ func (service *AspectService) GetAspectsForJoinPoint(ctx sdk.Context, to common. } for _, aspect := range aspects { // check if the Join point has run permissions - jp := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) + jp, err := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) + if err != nil { + return nil, err + } + if !artela.CanExecPoint(jp.Int64(), cut) { continue } @@ -105,7 +102,6 @@ func (service *AspectService) GetAspectsForJoinPoint(ctx sdk.Context, to common. // GetAccountVerifiers gets the bound Aspect verifier for the account func (service *AspectService) GetAccountVerifiers(ctx sdk.Context, to common.Address) ([]*artela.AspectCode, error) { - aspects, err := service.aspectStore.GetVerificationAspects(ctx, to) if err != nil { return nil, errors.Wrap(err, "load contract aspect binding failed") @@ -116,7 +112,11 @@ func (service *AspectService) GetAccountVerifiers(ctx sdk.Context, to common.Add } for _, aspect := range aspects { // check if the verify point has run permissions - jp := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) + jp, err := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) + if err != nil { + return nil, err + } + if !artela.CanExecPoint(jp.Int64(), artela.VERIFY_TX) { continue } @@ -132,71 +132,11 @@ func (service *AspectService) GetAccountVerifiers(ctx sdk.Context, to common.Add return aspectCodes, nil } -func (service *AspectService) GetAspectForBlock(ctx sdk.Context) ([]*artela.AspectCode, error) { - - aspectMap, err := service.aspectStore.GetBlockLevelAspects(ctx) - if err != nil { - return nil, errors.Wrap(err, "load contract aspect binding failed") - } - aspectCodes := make([]*artela.AspectCode, 0, len(aspectMap)) - if aspectMap == nil { - return aspectCodes, nil - } - for aspectId, number := range aspectMap { - aspectAddr := common.HexToAddress(aspectId) - - // check if the join point has run permissions - jp := service.aspectStore.GetAspectJP(ctx, aspectAddr, nil) - blockInitCheck := artela.CanExecPoint(jp.Int64(), artela.ON_BLOCK_INITIALIZE_METHOD) - blockFinalCheck := artela.CanExecPoint(jp.Int64(), artela.ON_BLOCK_FINALIZE_METHOD) - if !(blockInitCheck || blockFinalCheck) { - continue - } - - codeBytes, ver := service.aspectStore.GetAspectCode(ctx, aspectAddr, nil) - aspectCode := &artela.AspectCode{ - AspectId: aspectAddr.String(), - Priority: uint32(number), - Version: ver.Uint64(), - Code: codeBytes, - } - aspectCodes = append(aspectCodes, aspectCode) - } - sort.Slice(aspectCodes, evmtypes.NewBindingAspectPriorityComparator(aspectCodes)) - return aspectCodes, nil -} - -func (service *AspectService) GetAspectAccount(ctx sdk.Context, aspectId common.Address) (*common.Address, error) { - - if ctx.ChainID() == "" { - return nil, errors.New("chainID is empty.") - } - value := service.aspectStore.GetAspectPropertyValue(ctx, aspectId, evmtypes.AspectAccountKey) - if value == nil { - return nil, errors.New("cannot get aspect account.") - } - address := common.HexToAddress(string(value)) - return &address, nil -} - -func (service *AspectService) GetAspectProof(ctx sdk.Context, aspectId common.Address) ([]byte, error) { - - if ctx.ChainID() == "" { - return nil, errors.New("chainID is empty.") - } - value := service.aspectStore.GetAspectPropertyValue(ctx, aspectId, evmtypes.AspectProofKey) - if value == nil { - return nil, errors.New("cannot get aspect proof.") - } - address := common.Hex2Bytes(string(value)) - return address, nil -} - func (service *AspectService) GetBlockHeight() int64 { return service.getHeight() } -func (service *AspectService) GetAspectJoinPoint(ctx sdk.Context, aspectId common.Address, version *uint256.Int) *big.Int { +func (service *AspectService) GetAspectJoinPoint(ctx sdk.Context, aspectId common.Address, version *uint256.Int) (*big.Int, error) { if version == nil { version = service.aspectStore.GetAspectLastVersion(ctx, aspectId) diff --git a/x/evm/artela/contract/store.go b/x/evm/artela/contract/store.go index a873be78..65db32a5 100644 --- a/x/evm/artela/contract/store.go +++ b/x/evm/artela/contract/store.go @@ -3,33 +3,78 @@ package contract import ( "bytes" "encoding/json" - "fmt" + "errors" "math" "math/big" "sort" "strings" - "cosmossdk.io/errors" - artelasdkType "github.com/artela-network/aspect-core/types" + "github.com/emirpasic/gods/sets/treeset" + "github.com/holiman/uint256" + "golang.org/x/exp/slices" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/emirpasic/gods/sets/treeset" "github.com/ethereum/go-ethereum/common" - "github.com/holiman/uint256" - "github.com/status-im/keycard-go/hexutils" - "golang.org/x/exp/slices" "github.com/artela-network/artela/x/evm/artela/types" evmtypes "github.com/artela-network/artela/x/evm/types" + artelasdkType "github.com/artela-network/aspect-core/types" + types2 "github.com/artela-network/aspect-runtime/types" ) +const ( + storageLoadCost = 50 + storageStoreCost = 20000 + storageSaveCodeCost = 1000 + storageUpdateCost = 5000 +) + +type gasMeter struct { + gas uint64 +} + +func newGasMeter(gas uint64) *gasMeter { + return &gasMeter{ + gas: gas, + } +} + +func (m *gasMeter) measureStorageUpdate(dataLen int) error { + return m.consume(dataLen, storageUpdateCost) +} + +func (m *gasMeter) measureStorageCodeSave(dataLen int) error { + return m.consume(dataLen, storageSaveCodeCost) +} + +func (m *gasMeter) measureStorageStore(dataLen int) error { + return m.consume(dataLen, storageStoreCost) +} + +func (m *gasMeter) measureStorageLoad(dataLen int) error { + return m.consume(dataLen, storageLoadCost) +} + +func (m *gasMeter) remainingGas() uint64 { + return m.gas +} + +func (m *gasMeter) consume(dataLen int, gasCostPer32Bytes uint64) error { + gas := ((uint64(dataLen) + 32) >> 5) * gasCostPer32Bytes + if m.gas < gas { + m.gas = 0 + return types2.OutOfGasError + } + m.gas -= gas + return nil +} + type AspectStore struct { storeKey storetypes.StoreKey - - logger log.Logger + logger log.Logger } type bindingQueryFunc func(sdk.Context, common.Address) ([]*types.AspectMeta, error) @@ -45,146 +90,91 @@ func (k *AspectStore) newPrefixStore(ctx sdk.Context, fixKey string) prefix.Stor return prefix.NewStore(ctx.KVStore(k.storeKey), evmtypes.KeyPrefix(fixKey)) } -func (k *AspectStore) RemoveBlockLevelAspect(ctx sdk.Context, aspectId common.Address) error { - dataSet, err := k.GetBlockLevelAspects(ctx) - if err != nil { - return err - } - if dataSet == nil { - return nil - } - delete(dataSet, aspectId.String()) - jsonBytes, err := json.Marshal(dataSet) - if err != nil { - return err - } - // store - store := k.newPrefixStore(ctx, types.AspectBlockKeyPrefix) - aspectBlockKey := types.AspectBlockKey() - store.Set(aspectBlockKey, jsonBytes) - - k.logger.Debug( - fmt.Sprintf("setState: RemoveBlockLevelAspect"), - "key", string(aspectBlockKey), - "aspect-id", aspectId.Hex(), - "data-set", string(jsonBytes), - ) - return nil -} +func (k *AspectStore) BumpAspectVersion(ctx sdk.Context, aspectID common.Address, gas uint64) (*uint256.Int, uint64, error) { + meter := newGasMeter(gas) + version := k.getAspectLastVersion(ctx, aspectID) -// StoreBlockLevelAspect key="AspectBlock" value=map[string]int64 -func (k *AspectStore) StoreBlockLevelAspect(ctx sdk.Context, aspectId common.Address) error { - dataSet, err := k.GetBlockLevelAspects(ctx) - if err != nil { - return err - } - if dataSet == nil { - // order by - dataSet = make(map[string]int64) - } - // oder by block height - dataSet[aspectId.String()] = ctx.BlockHeight() - jsonBytes, err := json.Marshal(dataSet) - if err != nil { - return err + newVersion := version.Add(version, uint256.NewInt(1)) + if err := k.storeAspectVersion(ctx, aspectID, newVersion, meter); err != nil { + return nil, meter.remainingGas(), err } - // - // prefix - // kv - store := k.newPrefixStore(ctx, types.AspectBlockKeyPrefix) - aspectBlockKey := types.AspectBlockKey() - store.Set(aspectBlockKey, jsonBytes) - - k.logger.Debug( - fmt.Sprintf("setState: StoreBlockLevelAspect"), - "key", string(aspectBlockKey), - "aspect-id", aspectId.Hex(), - "data-set", string(jsonBytes), - ) - return nil -} -func (k *AspectStore) GetBlockLevelAspects(ctx sdk.Context) (map[string]int64, error) { - store := k.newPrefixStore(ctx, types.AspectBlockKeyPrefix) - blockKey := types.AspectBlockKey() - get := store.Get(blockKey) - if get == nil { - return nil, nil - } - blockMap := make(map[string]int64) - if err := json.Unmarshal(get, &blockMap); err != nil { - return nil, err - } - return blockMap, nil + return newVersion, meter.remainingGas(), nil } // StoreAspectCode aspect code -func (k *AspectStore) StoreAspectCode(ctx sdk.Context, aspectId common.Address, code []byte) *uint256.Int { - // get last value - version := k.GetAspectLastVersion(ctx, aspectId) - if len(code) == 0 { - return version +func (k *AspectStore) StoreAspectCode(ctx sdk.Context, aspectID common.Address, code []byte, version *uint256.Int, gas uint64) (uint64, error) { + meter := newGasMeter(gas) + if err := meter.measureStorageCodeSave(len(code)); err != nil { + return meter.remainingGas(), err } // store code codeStore := k.newPrefixStore(ctx, types.AspectCodeKeyPrefix) - newVersion := version.Add(version, uint256.NewInt(1)) versionKey := types.AspectVersionKey( - aspectId.Bytes(), - newVersion.Bytes(), + aspectID.Bytes(), + version.Bytes(), ) codeStore.Set(versionKey, code) - k.logger.Debug( - fmt.Sprintf("setState: StoreAspectCode"), - "aspect-id", aspectId.Hex(), - "aspect-version", fmt.Sprintf("%d", newVersion), - "aspect-code-hex", hexutils.BytesToHex(code), - ) - - // update last version - k.StoreAspectVersion(ctx, aspectId, newVersion) - return newVersion + k.logger.Info("saved aspect code", "id", aspectID.Hex(), "version", version.String()) + return meter.remainingGas(), nil } func (k *AspectStore) GetAspectCode(ctx sdk.Context, aspectId common.Address, version *uint256.Int) ([]byte, *uint256.Int) { codeStore := k.newPrefixStore(ctx, types.AspectCodeKeyPrefix) if version == nil { - version = k.GetAspectLastVersion(ctx, aspectId) + version = k.getAspectLastVersion(ctx, aspectId) + } + + if version.Cmp(zero) == 0 { + return nil, zero } + versionKey := types.AspectVersionKey( aspectId.Bytes(), version.Bytes(), ) code := codeStore.Get(versionKey) - return code, version + + // stored code is already validated, so we can ignore the error here + parsed, _ := ParseByteCode(code) + + return parsed, version } -// StoreAspectVersion version -func (k *AspectStore) StoreAspectVersion(ctx sdk.Context, aspectId common.Address, version *uint256.Int) { +// storeAspectVersion version +func (k *AspectStore) storeAspectVersion(ctx sdk.Context, aspectId common.Address, version *uint256.Int, meter *gasMeter) error { + var err error + if version.Cmp(one) == 0 { + err = meter.measureStorageStore(32) + } else { + err = meter.measureStorageUpdate(32) + } + if err != nil { + return err + } + versionStore := k.newPrefixStore(ctx, types.AspectCodeVersionKeyPrefix) - versionKey := types.AspectIdKey( - aspectId.Bytes(), - ) + versionKey := types.AspectIDKey(aspectId.Bytes()) versionStore.Set(versionKey, version.Bytes()) - k.logger.Debug( - fmt.Sprintf("setState: StoreAspectVersion"), - "aspect-id", aspectId.Hex(), - "aspect-version", fmt.Sprintf("%d", version), - ) + k.logger.Info("saved aspect version info", "id", aspectId.Hex(), "version", version.String()) + return nil } func (k *AspectStore) GetAspectLastVersion(ctx sdk.Context, aspectId common.Address) *uint256.Int { + return k.getAspectLastVersion(ctx, aspectId) +} + +func (k *AspectStore) getAspectLastVersion(ctx sdk.Context, aspectId common.Address) *uint256.Int { aspectVersionStore := k.newPrefixStore(ctx, types.AspectCodeVersionKeyPrefix) - versionKey := types.AspectIdKey( - aspectId.Bytes(), - ) + versionKey := types.AspectIDKey(aspectId.Bytes()) version := uint256.NewInt(0) - data := aspectVersionStore.Get(versionKey) - if data != nil || len(data) > 0 { + if data := aspectVersionStore.Get(versionKey); data != nil || len(data) > 0 { version.SetBytes(data) } + return version } @@ -198,16 +188,19 @@ func (k *AspectStore) GetAspectLastVersion(ctx sdk.Context, aspectId common.Addr // @param aspectId // @param prop // @return error -func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Address, prop []types.Property) error { - +func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Address, prop []types.Property, gas uint64) (uint64, error) { + meter := newGasMeter(gas) if len(prop) == 0 { - return nil + return gas, nil } // get treemap value aspectConfigStore := k.newPrefixStore(ctx, types.AspectPropertyKeyPrefix) // get all property key - propertyAllKey := k.GetAspectPropertyValue(ctx, aspectId, types.AspectPropertyAllKeyPrefix) + propertyAllKey, err := k.getAspectPropertyValue(ctx, aspectId, types.AspectPropertyAllKeyPrefix, meter) + if err != nil { + return meter.remainingGas(), err + } keySet := treeset.NewWithStringComparator() // add propertyAllKey to keySet @@ -224,7 +217,7 @@ func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Addre } // check key limit if keySet.Size() > types.AspectPropertyLimit { - return errors.Wrapf(nil, "The maximum key limit is exceeded, and the maximum allowed is %d now available %d", types.AspectPropertyLimit, keySet.Size()) + return meter.remainingGas(), errors.New("aspect property limit exceeds") } // store property key @@ -232,6 +225,11 @@ func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Addre key := prop[i].Key value := prop[i].Value + if err := meter.measureStorageCodeSave(len(key) + len(value)); err != nil { + k.logger.Error("unable to save property", "err", err, "key", key, "value", value) + return meter.remainingGas(), err + } + // store aspectPropertyKey := types.AspectPropertyKey( aspectId.Bytes(), @@ -240,11 +238,7 @@ func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Addre aspectConfigStore.Set(aspectPropertyKey, value) - k.logger.Debug( - fmt.Sprintf("setState: StoreAspectProperty"), - "aspect-id", aspectId.Hex(), - "aspect-property", fmt.Sprintf("%+v", prop), - ) + k.logger.Info("aspect property updated", "aspect", aspectId.Hex(), "key", key, "value", value) } // store AspectPropertyAllKey @@ -259,20 +253,24 @@ func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Addre ) aspectConfigStore.Set(allPropertyKeys, []byte(join)) - return nil + return meter.remainingGas(), nil } -func (k *AspectStore) GetAspectPropertyValue(ctx sdk.Context, aspectId common.Address, propertyKey string) []byte { - if types.AspectProofKey == propertyKey || types.AspectAccountKey == propertyKey { - // Block query of account and Proof - return nil - } +func (k *AspectStore) GetAspectPropertyValue(ctx sdk.Context, aspectId common.Address, propertyKey string, gas uint64) ([]byte, uint64, error) { + meter := newGasMeter(gas) + value, err := k.getAspectPropertyValue(ctx, aspectId, propertyKey, meter) + return value, meter.remainingGas(), err +} + +func (k *AspectStore) getAspectPropertyValue(ctx sdk.Context, aspectId common.Address, propertyKey string, meter *gasMeter) ([]byte, error) { codeStore := k.newPrefixStore(ctx, types.AspectPropertyKeyPrefix) aspectPropertyKey := types.AspectPropertyKey( aspectId.Bytes(), []byte(propertyKey), ) - return codeStore.Get(aspectPropertyKey) + + value := codeStore.Get(aspectPropertyKey) + return value, meter.measureStorageLoad(len(propertyKey) + len(value)) } func (k *AspectStore) BindTxAspect(ctx sdk.Context, account common.Address, aspectId common.Address, aspectVersion *uint256.Int, priority int8) error { @@ -281,15 +279,15 @@ func (k *AspectStore) BindTxAspect(ctx sdk.Context, account common.Address, aspe } func (k *AspectStore) BindVerificationAspect(ctx sdk.Context, account common.Address, aspectId common.Address, aspectVersion *uint256.Int, priority int8, isContractAccount bool) error { + // EoA can have multiple verifiers + limit := math.MaxUint8 if isContractAccount { // contract can have only 1 verifier - return k.saveBindingInfo(ctx, account, aspectId, aspectVersion, priority, - k.GetVerificationAspects, types.VerifierBindingKeyPrefix, 1) - } else { - // EoA can have multiple verifiers - return k.saveBindingInfo(ctx, account, aspectId, aspectVersion, priority, - k.GetVerificationAspects, types.VerifierBindingKeyPrefix, math.MaxUint8) + limit = 1 } + + return k.saveBindingInfo(ctx, account, aspectId, aspectVersion, priority, + k.GetVerificationAspects, types.VerifierBindingKeyPrefix, limit) } func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, aspectId common.Address, @@ -298,7 +296,7 @@ func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, a // check aspect existence code, version := k.GetAspectCode(ctx, aspectId, aspectVersion) if code == nil || version == nil { - return errors.Wrap(nil, "aspect not exist") + return errors.New("aspect not found") } // get transaction level aspect binding relationships @@ -308,22 +306,13 @@ func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, a } if len(bindings) >= limit { - return errors.Wrap(nil, "aspect binding limit exceeds") + return errors.New("binding limit exceeded") } // check duplicates - existing := -1 - for index, binding := range bindings { + for _, binding := range bindings { if bytes.Equal(binding.Id.Bytes(), aspectId.Bytes()) { - // ignore if binding already exists - if binding.Priority == int64(priority) && - binding.Version.Cmp(aspectVersion) == 0 { - return nil - } - - // record existing, replace later - existing = index - break + return errors.New("aspect already bound") } } @@ -333,12 +322,7 @@ func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, a Priority: int64(priority), } - // replace existing binding - if existing > 0 { - bindings[existing] = newAspect - } else { - bindings = append(bindings, newAspect) - } + bindings = append(bindings, newAspect) // re-sort aspects by priority if limit != 1 { @@ -357,10 +341,9 @@ func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, a ) aspectBindingStore.Set(aspectPropertyKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: saveBindingInfo"), - "aspect-id", aspectId.Hex(), - "countract", account.String(), + k.logger.Info("binding info saved", + "aspect", aspectId.Hex(), + "contract", account.Hex(), "bindings", string(jsonBytes), ) @@ -376,7 +359,8 @@ func (k *AspectStore) UnBindContractAspects(ctx sdk.Context, contract common.Add return bytes.Equal(meta.Id.Bytes(), aspectId.Bytes()) }) if toDelete < 0 { - return errors.Wrapf(nil, "aspect %s not bound with contract %s", aspectId.Hex(), contract.Hex()) + // not found + return nil } txAspectBindings = slices.Delete(txAspectBindings, toDelete, toDelete+1) jsonBytes, err := json.Marshal(txAspectBindings) @@ -391,12 +375,7 @@ func (k *AspectStore) UnBindContractAspects(ctx sdk.Context, contract common.Add ) contractBindingStore.Set(aspectPropertyKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: UnBindContractAspects"), - "aspect-id", aspectId.Hex(), - "contract", contract.String(), - "txAspectBindings", string(jsonBytes), - ) + k.logger.Info("tx aspect unbound", "aspect", aspectId.Hex(), "contract", contract.String()) return nil } @@ -421,49 +400,111 @@ func (k *AspectStore) getAccountBondAspects(ctx sdk.Context, account common.Addr return bindings, nil } if err := json.Unmarshal(rawJSON, &bindings); err != nil { - return nil, errors.Wrap(err, "unable to deserialize value bytes") + return nil, errors.New("failed to unmarshal aspect bindings") } return bindings, nil } -func (k *AspectStore) ChangeBoundAspectVersion(ctx sdk.Context, contract common.Address, aspectId common.Address, version uint64) error { - meta, err := k.GetTxLevelAspects(ctx, contract) - if err != nil { - return err +func (k *AspectStore) ChangeBoundAspectVersion(ctx sdk.Context, account common.Address, aspectId common.Address, version uint64, isContract, verifierAspect, txAspect bool) error { + bindingStoreKeys := make([]string, 0, 2) + bindingStoreKeys = append(bindingStoreKeys, types.VerifierBindingKeyPrefix) + if isContract { + bindingStoreKeys = append(bindingStoreKeys, types.ContractBindKeyPrefix) } - hasAspect := false - for _, aspect := range meta { - if bytes.Equal(aspect.Id.Bytes(), aspectId.Bytes()) { - aspect.Version = uint256.NewInt(version) - hasAspect = true + + bindings := make(map[string][]*types.AspectMeta, len(bindingStoreKeys)) + bindingIndex := make(map[string]int, len(bindingStoreKeys)) + + bound := false + var priority int8 + for _, bindingStoreKey := range bindingStoreKeys { + binding, err := k.getAccountBondAspects(ctx, account, bindingStoreKey) + if err != nil { + return err + } + bindings[bindingStoreKey] = binding + + for i, aspect := range binding { + if bytes.Equal(aspect.Id.Bytes(), aspectId.Bytes()) { + bindingIndex[bindingStoreKey] = i + bound = true + priority = int8(aspect.Priority) + break + } } } - if !hasAspect { - return nil - } - jsonBytes, err := json.Marshal(meta) - if err != nil { - return err + + if !bound { + return errors.New("aspect not bound") + } + + newBindingTypes := make(map[string]bool, 2) + newBindingTypes[types.VerifierBindingKeyPrefix] = verifierAspect + newBindingTypes[types.ContractBindKeyPrefix] = txAspect + u256Version := uint256.NewInt(version) + + for bindingStoreKey, binding := range bindings { + updateIdx, ok := bindingIndex[bindingStoreKey] + if !ok { + // join-point in the new version aspect has been changed, we need to add the new binding type + if newBindingTypes[bindingStoreKey] { + var err error + if bindingStoreKey == types.ContractBindKeyPrefix { + err = k.BindTxAspect(ctx, account, aspectId, u256Version, priority) + } else { + err = k.BindVerificationAspect(ctx, account, aspectId, u256Version, priority, isContract) + } + if err != nil { + k.logger.Error("failed to add new aspect binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) + return err + } + k.logger.Info("added new binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) + } + continue + } + + // join-point in the new version aspect has been changed, we need to remove the non-exist binding type + if !newBindingTypes[bindingStoreKey] { + var unbind func(ctx sdk.Context, contract common.Address, aspectId common.Address) error + if bindingStoreKey == types.ContractBindKeyPrefix { + unbind = k.UnBindContractAspects + } else { + unbind = k.UnBindVerificationAspect + } + + if err := unbind(ctx, account, aspectId); err != nil { + k.logger.Error("failed to remove aspect binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) + return err + } + + k.logger.Info("removed binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) + continue + } + + // join-point in the new version aspect not changed, we can just update the old one + oldVer := binding[updateIdx].Version.Uint64() + binding[updateIdx].Version = u256Version + + jsonBytes, err := json.Marshal(binding) + if err != nil { + return err + } + + bindingStore := k.newPrefixStore(ctx, bindingStoreKey) + bindingKey := types.AccountKey( + account.Bytes(), + ) + bindingStore.Set(bindingKey, jsonBytes) + + k.logger.Info("aspect bound version changed", "aspect", aspectId.Hex(), "account", account.String(), "old", oldVer, "new", version) } - // store - contractBindingStore := k.newPrefixStore(ctx, types.ContractBindKeyPrefix) - aspectPropertyKey := types.AccountKey( - contract.Bytes(), - ) - contractBindingStore.Set(aspectPropertyKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: ChangeBoundAspectVersion"), - "aspect-id", aspectId.Hex(), - "contract", contract.String(), - "aspects", string(jsonBytes), - ) return nil } func (k *AspectStore) GetAspectRefValue(ctx sdk.Context, aspectId common.Address) (*treeset.Set, error) { aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - aspectPropertyKey := types.AspectIdKey( + aspectPropertyKey := types.AspectIDKey( aspectId.Bytes(), ) @@ -495,21 +536,16 @@ func (k *AspectStore) StoreAspectRefValue(ctx sdk.Context, account common.Addres // store aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - aspectIdKey := types.AspectIdKey( + aspectIdKey := types.AspectIDKey( aspectId.Bytes(), ) aspectRefStore.Set(aspectIdKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: StoreAspectRefValue"), - "aspect-id", aspectId.Hex(), - "context", account.Hex(), - "aspects", string(jsonBytes), - ) + k.logger.Info("aspect bound", "aspect", aspectId.Hex(), "account", account.Hex()) return nil } -func (k *AspectStore) UnbindAspectRefValue(ctx sdk.Context, contract common.Address, aspectId common.Address) error { +func (k *AspectStore) UnbindAspectRefValue(ctx sdk.Context, account common.Address, aspectId common.Address) error { dataSet, err := k.GetAspectRefValue(ctx, aspectId) if err != nil { return err @@ -517,8 +553,8 @@ func (k *AspectStore) UnbindAspectRefValue(ctx sdk.Context, contract common.Addr if dataSet == nil { return nil } - // remove contract - dataSet.Remove(contract.String()) + // remove account + dataSet.Remove(account.String()) // marshal set and put treemap with new blockHeight jsonBytes, err := dataSet.MarshalJSON() if err != nil { @@ -526,43 +562,34 @@ func (k *AspectStore) UnbindAspectRefValue(ctx sdk.Context, contract common.Addr } // store aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - aspectPropertyKey := types.AspectIdKey( + aspectPropertyKey := types.AspectIDKey( aspectId.Bytes(), ) aspectRefStore.Set(aspectPropertyKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: UnbindAspectRefValue"), - "aspect-id", aspectId.Hex(), - "context", contract.Hex(), - "aspect-refvalue", string(jsonBytes), - ) + k.logger.Info("aspect unbound", "aspect", aspectId.Hex(), "account", account.Hex()) return nil } func (k *AspectStore) UnBindVerificationAspect(ctx sdk.Context, account common.Address, aspectId common.Address) error { - bindings, err := k.GetVerificationAspects(ctx, account) if err != nil { return err } - existing := -1 - // check duplicates - for index, binding := range bindings { - if bytes.Equal(binding.Id.Bytes(), aspectId.Bytes()) { - // delete Aspect id - existing = index - break - } - } - if existing == -1 { + + toDelete := slices.IndexFunc(bindings, func(meta *types.AspectMeta) bool { + return bytes.Equal(meta.Id.Bytes(), aspectId.Bytes()) + }) + + if toDelete < 0 { + // not found return nil } // delete existing - newBinding := append(bindings[:existing], bindings[existing+1:]...) + bindings = slices.Delete(bindings, toDelete, toDelete+1) - sort.Slice(newBinding, types.NewBindingPriorityComparator(newBinding)) - jsonBytes, _ := json.Marshal(newBinding) + sort.Slice(bindings, types.NewBindingPriorityComparator(bindings)) + jsonBytes, err := json.Marshal(bindings) if err != nil { return err } @@ -574,12 +601,7 @@ func (k *AspectStore) UnBindVerificationAspect(ctx sdk.Context, account common.A ) aspectBindingStore.Set(aspectPropertyKey, jsonBytes) - k.logger.Debug( - fmt.Sprintf("setState: UnBindVerificationAspect"), - "aspect-id", aspectId.Hex(), - "contract", account.Hex(), - "newBinding", string(jsonBytes), - ) + k.logger.Info("aspect unbound", "aspect", aspectId.Hex(), "account", account.String()) return nil } @@ -592,31 +614,20 @@ func (k *AspectStore) UnBindVerificationAspect(ctx sdk.Context, account common.A // @param version: aspect version ,optional,Default Aspect last version // @param point JoinPointRunType value, @see join_point_type.go // @return bool Execute Result -func (k *AspectStore) StoreAspectJP(ctx sdk.Context, aspectId common.Address, version *uint256.Int, point *big.Int) error { - if version.Uint64() == 0 || point.Int64() == 0 { - return nil - } +func (k *AspectStore) StoreAspectJP(ctx sdk.Context, aspectId common.Address, version uint256.Int, point *big.Int) { // check point - _, ok := artelasdkType.CheckIsJoinPoint(point) - if !ok { + if _, ok := artelasdkType.CheckIsJoinPoint(point); !ok { // Default store 0 point = big.NewInt(0) } - // Default last Aspect version - if version == nil { - version = k.GetAspectLastVersion(ctx, aspectId) - } - aspectPropertyStore := k.newPrefixStore(ctx, types.AspectJoinPointRunKeyPrefix) - // store aspectPropertyKey := types.AspectArrayKey( aspectId.Bytes(), version.Bytes(), []byte(types.AspectRunJoinPointKey), ) aspectPropertyStore.Set(aspectPropertyKey, point.Bytes()) - return nil } // GetAspectJP @@ -627,22 +638,24 @@ func (k *AspectStore) StoreAspectJP(ctx sdk.Context, aspectId common.Address, ve // @param aspectId // @param version // @return *big.Int -func (k *AspectStore) GetAspectJP(ctx sdk.Context, aspectId common.Address, version *uint256.Int) *big.Int { +func (k *AspectStore) GetAspectJP(ctx sdk.Context, aspectId common.Address, version *uint256.Int) (*big.Int, error) { // Default last Aspect version + latestVersion := k.GetAspectLastVersion(ctx, aspectId) if version == nil { - version = k.GetAspectLastVersion(ctx, aspectId) + version = latestVersion + } else if version.Cmp(zero) < 0 || version.Cmp(latestVersion) > 0 { + return nil, errors.New("invalid aspect version") } - codeStore := k.newPrefixStore(ctx, types.AspectJoinPointRunKeyPrefix) + + store := k.newPrefixStore(ctx, types.AspectJoinPointRunKeyPrefix) aspectPropertyKey := types.AspectArrayKey( aspectId.Bytes(), version.Bytes(), []byte(types.AspectRunJoinPointKey), ) - get := codeStore.Get(aspectPropertyKey) - - if nil != get && len(get) > 0 { - return new(big.Int).SetBytes(get) - } else { - return new(big.Int) + jp := store.Get(aspectPropertyKey) + if len(jp) == 0 { + return new(big.Int), nil } + return new(big.Int).SetBytes(jp), nil } diff --git a/x/evm/artela/contract/utils.go b/x/evm/artela/contract/utils.go new file mode 100644 index 00000000..7afa03bf --- /dev/null +++ b/x/evm/artela/contract/utils.go @@ -0,0 +1,83 @@ +package contract + +import ( + "bytes" + "errors" + "fmt" + "io" + + "github.com/andybalholm/brotli" + "github.com/ethereum/go-ethereum/crypto" +) + +// ParseByteCode byte code format rules: +// 1. The bytecode format is: [4 Bytes Header][4 Bytes CheckSum][Data...] +// 2. Header format is [3 Byte Reserved][1 Byte Compression Algorithm] +// 3. The first 3 bytes of the header are reserved for future extensions. +// 4. The last byte of the header indicates the compression algorithm used (0x01 for Brotli). +// 5. The 4 Bytes CheckSum is calculated using the `keccak256(data)[:4]` rule, where `data` is the compressed bytecode. +// 6. If the bytecode does not conform to the above rules, it is considered unprocessed WASM bytecode and will be directly validated and executed. +func ParseByteCode(bytecode []byte) ([]byte, error) { + if len(bytecode) < 8 { + // no header + return bytecode, nil + } + + // Decode Header and CheckSum + header := bytecode[:4] + + // parsed reserved parts + for _, reserved := range header[:3] { + if reserved != 0 { + // not a valid header, ignore the processing + return bytecode, nil + } + } + + // check compression algo + compressionAlgo := header[3] + if compressionAlgo == 0 { + // not a valid compression algo, ignore the processing + return bytecode, nil + } + + // check checksum + checkSum := bytecode[4:8] + data := bytecode[8:] + if err := verifyChecksum(data, checkSum); err != nil { + return nil, err + } + + var ( + decompressed []byte + err error + ) + + switch compressionAlgo { + case 0x01: + decompressed, err = brotliDecompress(data) + default: + err = fmt.Errorf("unsupported compression algorithm: %d", compressionAlgo) + } + + return decompressed, err +} + +// verifyChecksum validate whether the checksum is correct +func verifyChecksum(data, expectedCheckSum []byte) error { + actualCheckSum := crypto.Keccak256(data)[:4] + if !bytes.Equal(actualCheckSum, expectedCheckSum) { + return errors.New("invalid checksum") + } + return nil +} + +// brotliDecompress brotli decompress +func brotliDecompress(data []byte) ([]byte, error) { + reader := brotli.NewReader(bytes.NewReader(data)) + decompressedData, err := io.ReadAll(reader) + if err != nil { + return nil, fmt.Errorf("failed to decompress data: %w", err) + } + return decompressedData, nil +} diff --git a/x/evm/artela/handle/prepare.go b/x/evm/artela/handle/prepare.go index ef99683f..82c681dc 100644 --- a/x/evm/artela/handle/prepare.go +++ b/x/evm/artela/handle/prepare.go @@ -118,7 +118,7 @@ func (h ArtelaProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandl return NoOpProcessProposal() } - return func(ctx sdk.Context, req abci.RequestProcessProposal) abci.ResponseProcessProposal { + return func(_ sdk.Context, req abci.RequestProcessProposal) abci.ResponseProcessProposal { for _, txBytes := range req.Txs { _, err := h.txVerifier.ProcessProposalVerifyTx(txBytes) if err != nil { diff --git a/x/evm/artela/provider/artela.go b/x/evm/artela/provider/artela.go index 04e68cd4..d4fb2ba2 100644 --- a/x/evm/artela/provider/artela.go +++ b/x/evm/artela/provider/artela.go @@ -3,12 +3,14 @@ package provider import ( "context" "errors" - "github.com/artela-network/artela/x/evm/artela/contract" - "github.com/artela-network/artela/x/evm/artela/types" - asptypes "github.com/artela-network/aspect-core/types" + "github.com/cometbft/cometbft/libs/log" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela/x/evm/artela/contract" + "github.com/artela-network/artela/x/evm/artela/types" + asptypes "github.com/artela-network/aspect-core/types" ) var _ asptypes.AspectProvider = (*ArtelaProvider)(nil) @@ -49,31 +51,6 @@ func (j *ArtelaProvider) GetAccountVerifiers(ctx context.Context, address common return j.service.GetAccountVerifiers(aspectCtx.CosmosContext(), address) } -func (j *ArtelaProvider) GetBlockBondAspects(ctx context.Context) ([]*asptypes.AspectCode, error) { - if ctx == nil { - return nil, errors.New("invalid Context") - } - aspectCtx, ok := ctx.(*types.AspectRuntimeContext) - if !ok { - return nil, errors.New("failed to unwrap AspectRuntimeContext from context.Context") - } - - return j.service.GetAspectForBlock(aspectCtx.CosmosContext()) -} - -func (j *ArtelaProvider) GetAspectAccount(ctx context.Context, aspectId common.Address) (*common.Address, error) { - - if ctx == nil { - return nil, errors.New("invalid Context") - } - aspectCtx, ok := ctx.(*types.AspectRuntimeContext) - if !ok { - return nil, errors.New("failed to unwrap AspectRuntimeContext from context.Context") - } - - return j.service.GetAspectAccount(aspectCtx.CosmosContext(), aspectId) -} - func (j *ArtelaProvider) GetLatestBlock() int64 { return j.service.GetBlockHeight() } diff --git a/x/evm/artela/provider/jit_call.go b/x/evm/artela/provider/jit_call.go index caa65cdc..961ffae2 100644 --- a/x/evm/artela/provider/jit_call.go +++ b/x/evm/artela/provider/jit_call.go @@ -3,10 +3,10 @@ package provider import ( "math/big" - "github.com/artela-network/aspect-core/integration" "github.com/ethereum/go-ethereum/common" "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/aspect-core/integration" ) var _ integration.AspectProtocol = (*AspectProtocolProvider)(nil) diff --git a/x/evm/artela/types/aspect_abi.go b/x/evm/artela/types/aspect_abi.go deleted file mode 100644 index b8d04f96..00000000 --- a/x/evm/artela/types/aspect_abi.go +++ /dev/null @@ -1,112 +0,0 @@ -package types - -import ( - "encoding/hex" - - errorsmod "cosmossdk.io/errors" - "github.com/ethereum/go-ethereum/accounts/abi" -) - -var ( - Uint256, _ = abi.NewType("uint256", "", nil) - Uint64, _ = abi.NewType("uint64", "", nil) - Uint32, _ = abi.NewType("uint32", "", nil) - Uint16, _ = abi.NewType("uint16", "", nil) - Uint8, _ = abi.NewType("uint8", "", nil) - - String, _ = abi.NewType("string", "", nil) - Bool, _ = abi.NewType("bool", "", nil) - Bytes, _ = abi.NewType("bytes", "", nil) - Bytes32, _ = abi.NewType("bytes32", "", nil) - Address, _ = abi.NewType("address", "", nil) - Uint64Arr, _ = abi.NewType("uint64[]", "", nil) - AddressArr, _ = abi.NewType("address[]", "", nil) - Int8, _ = abi.NewType("int8", "", nil) - // Special types for testing - Uint32Arr2, _ = abi.NewType("uint32[2]", "", nil) - Uint64Arr2, _ = abi.NewType("uint64[2]", "", nil) - Uint256Arr, _ = abi.NewType("uint256[]", "", nil) - Uint256Arr2, _ = abi.NewType("uint256[2]", "", nil) - Uint256Arr3, _ = abi.NewType("uint256[3]", "", nil) - Uint256ArrNested, _ = abi.NewType("uint256[2][2]", "", nil) - Uint8ArrNested, _ = abi.NewType("uint8[][2]", "", nil) - Uint8SliceNested, _ = abi.NewType("uint8[][]", "", nil) - KvPair, _ = abi.NewType("tuple", "struct Overloader.F", []abi.ArgumentMarshaling{ - {Name: "key", Type: "bytes"}, - {Name: "value", Type: "bytes"}, - }) - KvPairArr, _ = abi.NewType("tuple[]", "struct Overloader.F", []abi.ArgumentMarshaling{ - {Name: "key", Type: "string"}, - {Name: "value", Type: "bytes"}, - }) - AspectBoundInfoArr, _ = abi.NewType("tuple[]", "struct Overloader.F", []abi.ArgumentMarshaling{ - {Name: "aspectId", Type: "address"}, - {Name: "version", Type: "uint64"}, - {Name: "priority", Type: "int8"}, - }) -) - -// nolint -var methods = map[string]abi.Method{ - "deploy": abi.NewMethod("deploy", "deploy", abi.Function, "", false, false, []abi.Argument{{"code", Bytes, false}, {"properties", KvPairArr, false}, {"account", Address, false}, {"proof", Bytes, false}, {"joinPoints", Uint256, false}}, nil), - "upgrade": abi.NewMethod("upgrade", "upgrade", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}, {"code", Bytes, false}, {"properties", KvPairArr, false}, {"joinPoints", Uint256, false}}, nil), - "bind": abi.NewMethod("bind", "bind", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}, {"aspectVersion", Uint256, false}, {"contract", Address, false}, {"priority", Int8, false}}, nil), - "unbind": abi.NewMethod("unbind", "unbind", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}, {"contract", Address, false}}, nil), - "changeVersion": abi.NewMethod("changeVersion", "changeVersion", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}, {"contract", Address, false}, {"version", Uint64, false}}, nil), - "versionOf": abi.NewMethod("versionOf", "versionOf", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}}, []abi.Argument{{"version", Uint64, false}}), - "aspectsOf": abi.NewMethod("aspectsOf", "aspectsOf", abi.Function, "", false, false, []abi.Argument{{"contract", Address, false}}, []abi.Argument{{"aspectBoundInfo", AspectBoundInfoArr, false}}), - "boundAddressesOf": abi.NewMethod("boundAddressesOf", "boundAddressesOf", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}}, []abi.Argument{{"account", AddressArr, false}}), - "entrypoint": abi.NewMethod("entrypoint", "entrypoint", abi.Function, "", false, false, []abi.Argument{{"aspectId", Address, false}, {"optArgs", Bytes, false}}, []abi.Argument{{"resultMap", Bytes, false}}), -} - -// nolint -var AspectOwnableMethod = map[string]abi.Method{ - "isOwner": abi.NewMethod("isOwner", "isOwner", abi.Function, "", false, false, []abi.Argument{{"sender", Address, false}}, []abi.Argument{{"result", Bool, false}}), -} - -var methodsLookup = AbiMap() - -var AbiMap = func() map[string]string { - abiIndex := make(map[string]string) - for name, expM := range methods { - abiIndex[hex.EncodeToString(expM.ID)] = name - } - return abiIndex -} - -func ParseMethod(callData []byte) (*abi.Method, map[string]interface{}, error) { - methodId := hex.EncodeToString(callData[:4]) - methodName, ok := methodsLookup[methodId] - if !ok { - return nil, nil, errorsmod.Wrapf(nil, "missing expected method %s", methodId) - } - - method, ok := methods[methodName] - if !ok { - return nil, nil, errorsmod.Wrapf(nil, "method %s does not exist", methodName) - } - - argsMap := make(map[string]interface{}) - if err := method.Inputs.UnpackIntoMap(argsMap, callData[4:]); err != nil { - return nil, nil, err - } - - return &method, argsMap, nil -} - -func ParseInput(tx []byte) (*abi.Method, map[string]interface{}, error) { - methodId := hex.EncodeToString(tx[:4]) - methodName, exist := AbiMap()[methodId] - if !exist { - return nil, nil, errorsmod.Wrapf(nil, "Missing expected method %v", methodId) - } - method := methods[methodName] - argsMap := make(map[string]interface{}) - inputs := method.Inputs - err := inputs.UnpackIntoMap(argsMap, tx[4:]) - if err != nil { - return nil, nil, err - } - - return &method, argsMap, nil -} diff --git a/x/evm/artela/types/aspect_store_key.go b/x/evm/artela/types/aspect_store_key.go index ebaa51e1..76024620 100644 --- a/x/evm/artela/types/aspect_store_key.go +++ b/x/evm/artela/types/aspect_store_key.go @@ -6,10 +6,12 @@ import ( "math" "strings" - artela "github.com/artela-network/aspect-core/types" "github.com/emirpasic/gods/utils" - "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" + + "github.com/ethereum/go-ethereum/common" + + artela "github.com/artela-network/aspect-core/types" ) var _ binary.ByteOrder @@ -22,18 +24,14 @@ const ( ContractBindKeyPrefix = "AspectStore/ContractBind/" VerifierBindingKeyPrefix = "AspectStore/VerifierBind/" AspectRefKeyPrefix = "AspectStore/AspectRef/" - AspectBlockKeyPrefix = "AspectStore/Block/" AspectStateKeyPrefix = "AspectStore/State/" AspectJoinPointRunKeyPrefix = "AspectStore/JoinPointRun/" - AspectIdMapKey = "aspectId" + AspectIDMapKey = "aspectId" VersionMapKey = "version" PriorityMapKey = "priority" - AspectStateBeginBlock = "State/BeginBlock" - AspectStateDeliverTxState = "State/DeliverTx" - AspectStateEndBlock = "State/EndBlock" AspectAccountKey = "Aspect_@Acount@_" AspectProofKey = "Aspect_@Proof@_" AspectRunJoinPointKey = "Aspect_@Run@JoinPoint@_" @@ -47,22 +45,6 @@ var ( PathSeparatorLen = len(PathSeparator) ) -func GetAspectStatePoint(point string) string { - if strings.EqualFold(point, string(artela.ON_BLOCK_INITIALIZE_METHOD)) { - return AspectStateBeginBlock - } else if strings.EqualFold(point, string(artela.ON_BLOCK_FINALIZE_METHOD)) { - return AspectStateEndBlock - } else if strings.EqualFold(point, string(artela.POST_TX_COMMIT)) || - strings.EqualFold(point, string(artela.PRE_TX_EXECUTE_METHOD)) || - strings.EqualFold(point, string(artela.POST_TX_EXECUTE_METHOD)) || - strings.EqualFold(point, string(artela.PRE_CONTRACT_CALL_METHOD)) || - strings.EqualFold(point, string(artela.POST_CONTRACT_CALL_METHOD)) || - strings.EqualFold(point, string(artela.OPERATION_METHOD)) { - return AspectStateDeliverTxState - } - return "" -} - func AspectArrayKey(keys ...[]byte) []byte { var key []byte for _, b := range keys { @@ -74,12 +56,12 @@ func AspectArrayKey(keys ...[]byte) []byte { // AspectCodeStoreKey returns the store key to retrieve a AspectCodeStore from the index fields func AspectPropertyKey( - aspectId []byte, + aspectID []byte, propertyKey []byte, ) []byte { - key := make([]byte, 0, len(aspectId)+PathSeparatorLen*2+len(propertyKey)) + key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(propertyKey)) - key = append(key, aspectId...) + key = append(key, aspectID...) key = append(key, PathSeparator...) key = append(key, propertyKey...) key = append(key, PathSeparator...) @@ -88,12 +70,12 @@ func AspectPropertyKey( } func AspectVersionKey( - aspectId []byte, + aspectID []byte, version []byte, ) []byte { - key := make([]byte, 0, len(aspectId)+PathSeparatorLen*2+len(version)) + key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(version)) - key = append(key, aspectId...) + key = append(key, aspectID...) key = append(key, PathSeparator...) key = append(key, version...) key = append(key, PathSeparator...) @@ -101,11 +83,11 @@ func AspectVersionKey( return key } -func AspectIdKey( - aspectId []byte, +func AspectIDKey( + aspectID []byte, ) []byte { - key := make([]byte, 0, len(aspectId)+PathSeparatorLen) - key = append(key, aspectId...) + key := make([]byte, 0, len(aspectID)+PathSeparatorLen) + key = append(key, aspectID...) key = append(key, PathSeparator...) return key diff --git a/x/evm/artela/types/context.go b/x/evm/artela/types/context.go index bdd99cb4..2037f2f1 100644 --- a/x/evm/artela/types/context.go +++ b/x/evm/artela/types/context.go @@ -3,26 +3,26 @@ package types import ( "context" "fmt" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" + "math/big" "sync" "time" - evmtypes "github.com/artela-network/artela/x/evm/types" - artelatypes "github.com/artela-network/aspect-core/types" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" - - "github.com/artela-network/artela-evm/vm" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/artela-network/artela-evm/vm" statedb "github.com/artela-network/artela/x/evm/states" + evmtypes "github.com/artela-network/artela/x/evm/types" inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" + artelatypes "github.com/artela-network/aspect-core/types" ) const ( @@ -44,28 +44,21 @@ type ( // containing information related to transactions (tx) and blocks. Aspects at different // join points can access this context, and consequently, the context dynamically // adjusts its content based on the actual execution of blocks and transactions. - // Here is the execution scenario of this context in the lifecycle of a tx process, // listed in the order of tx execution: - // 1. initialization: Before each transaction execution, create the AspectRuntimeContext // and establish a bidirectional connection with the sdk context. - // 2. withBlockConfig: Write information before the start of each block and destroy it // at the end of each block. Transfer it to the AspectRuntimeContext before the execution // of tx in the deliver state through WithExtBlock. - // 3. withEVM: Before Pre-tx-execute, incorporate the EVM context, including evm, stateDB, // evm tracer, message, message from, etc., and pass it to the AspectRuntimeContext through // WithTxContext. - // 4. withReceipt: After the execution of the EVM, store the result in TxContext, enabling // subsequent JoinPoints to access the execution details of the tx. - // 5. commit: Decide whether to commit at the end of each transaction. If committing is // necessary, write the result to the sdk context. - -// 6. destory: After each transaction execution, destroy the AspectRuntimeContext. +// 6. destroy: After each transaction execution, destroy the AspectRuntimeContext. type AspectRuntimeContext struct { baseCtx context.Context @@ -100,9 +93,9 @@ func (c *AspectRuntimeContext) WithCosmosContext(newTxCtx cosmos.Context) { func (c *AspectRuntimeContext) Debug(msg string, keyvals ...interface{}) { if c.ethTxContext != nil { - keyvals = append(keyvals, "tx-from", fmt.Sprintf("%s", c.ethTxContext.TxFrom().Hex())) + keyvals = append(keyvals, "tx-from", c.ethTxContext.TxFrom().Hex()) if c.ethTxContext.TxContent() != nil { - keyvals = append(keyvals, "tx-hash", fmt.Sprintf("%s", c.ethTxContext.TxContent().Hash().Hex())) + keyvals = append(keyvals, "tx-hash", c.ethTxContext.TxContent().Hash().Hex()) } } c.logger.Debug(msg, keyvals...) @@ -154,7 +147,7 @@ func (c *AspectRuntimeContext) StateDb() vm.StateDB { if c.EthTxContext() == nil { return nil } - return c.EthTxContext().stateDb + return c.EthTxContext().stateDB } func (c *AspectRuntimeContext) ClearBlockContext() { @@ -182,7 +175,6 @@ func (c *AspectRuntimeContext) SetAspectState(ctx *artelatypes.RunnerContext, ke ) c.aspectState.Set(stateKey, value) - return } func (c *AspectRuntimeContext) Destroy() { @@ -223,7 +215,7 @@ type EthTxContext struct { msg *core.Message vmTracer *vm.Tracer receipt *ethtypes.Receipt - stateDb vm.StateDB + stateDB vm.StateDB evmCfg *statedb.EVMConfig lastEvm *vm.EVM from common.Address @@ -236,7 +228,7 @@ func NewEthTxContext(ethTx *ethtypes.Transaction) *EthTxContext { txContent: ethTx, vmTracer: nil, receipt: nil, - stateDb: nil, + stateDB: nil, } } @@ -253,14 +245,12 @@ func (c *EthTxContext) TxTo() string { func (c *EthTxContext) TxFrom() common.Address { return c.from } -func (c *EthTxContext) TxIndex() uint64 { - return c.index -} +func (c *EthTxContext) TxIndex() uint64 { return c.index } func (c *EthTxContext) EvmCfg() *statedb.EVMConfig { return c.evmCfg } func (c *EthTxContext) TxContent() *ethtypes.Transaction { return c.txContent } func (c *EthTxContext) VmTracer() *vm.Tracer { return c.vmTracer } func (c *EthTxContext) Receipt() *ethtypes.Receipt { return c.receipt } -func (c *EthTxContext) VmStateDB() vm.StateDB { return c.stateDb } +func (c *EthTxContext) VmStateDB() vm.StateDB { return c.stateDB } func (c *EthTxContext) LastEvm() *vm.EVM { return c.lastEvm } func (c *EthTxContext) Message() *core.Message { return c.msg } func (c *EthTxContext) Commit() bool { return c.commit } @@ -276,7 +266,7 @@ func (c *EthTxContext) WithEVM( c.msg = msg c.lastEvm = lastEvm c.vmTracer = monitor - c.stateDb = db + c.stateDB = db return c } @@ -300,13 +290,13 @@ func (c *EthTxContext) WithCommit(commit bool) *EthTxContext { return c } -func (c *EthTxContext) WithStateDB(stateDb vm.StateDB) *EthTxContext { - c.stateDb = stateDb +func (c *EthTxContext) WithStateDB(stateDB vm.StateDB) *EthTxContext { + c.stateDB = stateDB return c } func (c *EthTxContext) ClearEvmObject() *EthTxContext { - c.stateDb = nil + c.stateDB = nil c.vmTracer = nil c.lastEvm = nil c.evmCfg = nil @@ -444,7 +434,6 @@ func (k *AspectState) Set(key, value []byte) { } else { k.logger.Debug("setState:", "action", action, "key", string(key), "value", string(value)) } - } func (k *AspectState) Get(key []byte) []byte { diff --git a/x/evm/artela/types/treemap_test.go b/x/evm/artela/types/treemap_test.go index da637f38..ce51eec9 100644 --- a/x/evm/artela/types/treemap_test.go +++ b/x/evm/artela/types/treemap_test.go @@ -2,7 +2,6 @@ package types import ( "encoding/json" - _ "encoding/json" "fmt" "strings" "testing" @@ -12,19 +11,19 @@ import ( pq "github.com/emirpasic/gods/queues/priorityqueue" ) -func TestPriorityqueue(t *testing.T) { +func TestPriorityQueue(t *testing.T) { /* a := BondAspect{AspectId: "1111", priority: 1} b := BondAspect{AspectId: "22222", priority: -10} c := BondAspect{AspectId: "3333", priority: 3} */ ma := make(map[string]interface{}, 2) - ma[AspectIdMapKey] = "1111" + ma[AspectIDMapKey] = "1111" ma[PriorityMapKey] = 1 mb := make(map[string]interface{}, 2) - mb[AspectIdMapKey] = "2222" + mb[AspectIDMapKey] = "2222" mb[PriorityMapKey] = -10 mc := make(map[string]interface{}, 2) - mc[AspectIdMapKey] = "3333" + mc[AspectIDMapKey] = "3333" mc[PriorityMapKey] = 3 queue := pq.NewWith(ByMapKeyPriority) // empty @@ -57,7 +56,7 @@ func TestPriorityqueue(t *testing.T) { fmt.Println(newQueue.Values()) } -func TestTreemap(t *testing.T) { +func TestTreemap(_ *testing.T) { m := hashmap.New() m.Put("a", "1") m.Put("b", "2") @@ -95,8 +94,8 @@ func TestTreemap(t *testing.T) { fmt.Println(string(bytes)) comparator := treemap.NewWithIntComparator() - errJson := json.Unmarshal(bytes, &comparator) - if errJson != nil { + err = json.Unmarshal(bytes, &comparator) + if err != nil { return } foundKey7, foundValue7 := comparator.Floor("90") diff --git a/x/evm/blocker.go b/x/evm/blocker.go index 30cb4916..5a958ec3 100644 --- a/x/evm/blocker.go +++ b/x/evm/blocker.go @@ -1,14 +1,14 @@ package evm import ( - "github.com/artela-network/artela/x/evm/artela/types" - abci "github.com/cometbft/cometbft/abci/types" - - "github.com/artela-network/artela/x/evm/keeper" + "sync" + abci "github.com/cometbft/cometbft/abci/types" cosmos "github.com/cosmos/cosmos-sdk/types" - ethereum "github.com/ethereum/go-ethereum/core/types" + + "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/keeper" ) // BeginBlock sets the cosmos Context and EIP155 chain id to the Keeper. @@ -19,13 +19,16 @@ func BeginBlock(_ cosmos.Context, k *keeper.Keeper, beginBlock abci.RequestBegin // using code like ctx = ctx.WithValue(artelatypes.ExtBlockContextKey, extBlockCtx). // Instead, it suggests saving it to the keeper. k.BlockContext = types.NewEthBlockContextFromABCIBeginBlockReq(beginBlock) + + // clear the verifyTxCache when BeginBlock + clearSyncMap(k.VerifySigCache) } // EndBlock also retrieves the bloom filter value from the transient store and commits it to the // KVStore. The EVM end block logic doesn't update the validator set, thus it returns // an empty slice. func EndBlock(ctx cosmos.Context, k *keeper.Keeper, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - // Aspect Runtime Context Lifecycle: destory ExtBlockContext + // Aspect Runtime Context Lifecycle: destroy ExtBlockContext k.BlockContext = nil // Gas costs are handled within msg handler so costs should be ignored @@ -34,5 +37,19 @@ func EndBlock(ctx cosmos.Context, k *keeper.Keeper, _ abci.RequestEndBlock) []ab bloom := ethereum.BytesToBloom(k.GetBlockBloomTransient(infCtx).Bytes()) k.EmitBlockBloomEvent(infCtx, bloom) + // clear the verifyTxCache when EndBlock + clearSyncMap(k.VerifySigCache) + return []abci.ValidatorUpdate{} } + +func clearSyncMap(m *sync.Map) { + keys := make([]any, 0) + m.Range(func(key, value any) bool { + keys = append(keys, key) + return true + }) + for _, key := range keys { + m.Delete(key) + } +} diff --git a/x/evm/client/cli/query.go b/x/evm/client/cli/query.go index b802d010..087b79b2 100644 --- a/x/evm/client/cli/query.go +++ b/x/evm/client/cli/query.go @@ -1,13 +1,13 @@ package cli import ( - rpc "github.com/artela-network/artela/ethereum/rpc/types" - "github.com/artela-network/artela/x/evm/txs" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + rpc "github.com/artela-network/artela/ethereum/rpc/types" + "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/types" ) diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 6962db1d..6d30f93a 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -5,16 +5,16 @@ import ( "fmt" "os" - rpc "github.com/artela-network/artela/ethereum/rpc/types" - "github.com/artela-network/artela/x/evm/txs" + "github.com/pkg/errors" + "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/pkg/errors" - "github.com/spf13/cobra" + rpc "github.com/artela-network/artela/ethereum/rpc/types" + "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/types" ) diff --git a/x/evm/client/cli/utils.go b/x/evm/client/cli/utils.go index 639c1aa6..31533ec3 100644 --- a/x/evm/client/cli/utils.go +++ b/x/evm/client/cli/utils.go @@ -6,9 +6,8 @@ import ( "github.com/pkg/errors" - "github.com/ethereum/go-ethereum/common" - cosmos "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" ) func accountToHex(addr string) (string, error) { diff --git a/x/evm/genesis.go b/x/evm/genesis.go index fecd6361..8e97c11c 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -4,16 +4,15 @@ import ( "bytes" "fmt" - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/txs/support" - - "github.com/artela-network/artela/x/evm/keeper" abci "github.com/cometbft/cometbft/abci/types" cosmos "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/keeper" + "github.com/artela-network/artela/x/evm/txs/support" "github.com/artela-network/artela/x/evm/types" ) diff --git a/x/evm/keeper/aspect.go b/x/evm/keeper/aspect.go index 1ab04d6c..da118edf 100644 --- a/x/evm/keeper/aspect.go +++ b/x/evm/keeper/aspect.go @@ -4,8 +4,9 @@ import ( "context" "errors" - artvmtype "github.com/artela-network/artela/x/evm/artela/types" "github.com/ethereum/go-ethereum/common" + + artvmtype "github.com/artela-network/artela/x/evm/artela/types" ) func (k Keeper) GetAspectRuntimeContext() *artvmtype.AspectRuntimeContext { diff --git a/x/evm/keeper/config.go b/x/evm/keeper/config.go index 32bdd676..6e890646 100644 --- a/x/evm/keeper/config.go +++ b/x/evm/keeper/config.go @@ -3,16 +3,14 @@ package keeper import ( "math/big" - "github.com/artela-network/artela-evm/vm" - - "github.com/artela-network/artela/x/evm/txs/support" - errorsmod "cosmossdk.io/errors" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/artela-network/artela-evm/vm" "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/artela/x/evm/txs/support" ) // ---------------------------------------------------------------------------- @@ -22,7 +20,7 @@ import ( // EVMConfig creates the EVMConfig based on current states func (k *Keeper) EVMConfig(ctx cosmos.Context, proposerAddress cosmos.ConsAddress, chainID *big.Int) (*states.EVMConfig, error) { params := k.GetParams(ctx) - ethCfg := params.ChainConfig.EthereumConfig(chainID) + ethCfg := params.ChainConfig.EthereumConfig(ctx.BlockHeight(), chainID) // get the coinbase address from the block proposer coinbase, err := k.GetProposerAddress(ctx, proposerAddress) diff --git a/x/evm/keeper/evm.go b/x/evm/keeper/evm.go index 5ebd06d0..09ec339b 100644 --- a/x/evm/keeper/evm.go +++ b/x/evm/keeper/evm.go @@ -4,17 +4,8 @@ import ( "errors" "math/big" - asptypes "github.com/artela-network/aspect-core/types" - - "github.com/artela-network/artela/x/evm/artela/contract" - artelatypes "github.com/artela-network/artela/x/evm/artela/types" - - "github.com/artela-network/aspect-core/djpm" - cometbft "github.com/cometbft/cometbft/types" - errorsmod "cosmossdk.io/errors" - artcore "github.com/artela-network/artela-evm/core" - "github.com/artela-network/artela-evm/vm" + cometbft "github.com/cometbft/cometbft/types" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -22,11 +13,18 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + artcore "github.com/artela-network/artela-evm/core" + "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/artela/common/aspect" artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/artela/contract" + artelatypes "github.com/artela-network/artela/x/evm/artela/types" "github.com/artela-network/artela/x/evm/states" "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/txs/support" "github.com/artela-network/artela/x/evm/types" + "github.com/artela-network/aspect-core/djpm" + asptypes "github.com/artela-network/aspect-core/types" ) // NewEVM generates a go-ethereum VM from the provided Message fields and the chain parameters @@ -176,7 +174,7 @@ func (k *Keeper) ApplyTransaction(ctx cosmos.Context, tx *ethereum.Transaction) } // pass true to commit the StateDB - res, err := k.ApplyMessageWithConfig(tmpCtx, aspectCtx, msg, nil, true, evmConfig, txConfig) + res, err := k.ApplyMessageWithConfig(tmpCtx, aspectCtx, msg, nil, true, evmConfig, txConfig, k.isCustomizedVerification(tx)) if err != nil { ctx.Logger().Error("ApplyMessageWithConfig with error", "txhash", tx.Hash().String(), "error", err, "response", res) return nil, errorsmod.Wrap(err, "failed to apply ethereum core message") @@ -203,7 +201,7 @@ func (k *Keeper) ApplyTransaction(ctx cosmos.Context, tx *ethereum.Transaction) res.CumulativeGasUsed = cumulativeGasUsed var contractAddr common.Address - if msg.To == nil { + if msg.To == nil || aspect.IsAspectDeploy(msg.To, msg.Data) { contractAddr = crypto.CreateAddress(msg.From, msg.Nonce) } @@ -259,8 +257,7 @@ func (k *Keeper) ApplyTransaction(ctx cosmos.Context, tx *ethereum.Transaction) // ApplyMessage calls ApplyMessageWithConfig with an empty TxConfig. func (k *Keeper) ApplyMessage(ctx cosmos.Context, msg *core.Message, tracer vm.EVMLogger, commit bool) (*txs.MsgEthereumTxResponse, error) { - - evmConfig, err := k.EVMConfig(ctx, cosmos.ConsAddress(ctx.BlockHeader().ProposerAddress), k.eip155ChainID) + evmConfig, err := k.EVMConfig(ctx, ctx.BlockHeader().ProposerAddress, k.eip155ChainID) if err != nil { return nil, errorsmod.Wrap(err, "failed to load evm config") } @@ -273,7 +270,7 @@ func (k *Keeper) ApplyMessage(ctx cosmos.Context, msg *core.Message, tracer vm.E return nil, errors.New("ApplyMessageWithConfig: unwrap AspectRuntimeContext failed") } - return k.ApplyMessageWithConfig(ctx, aspectCtx, msg, tracer, commit, evmConfig, txConfig) + return k.ApplyMessageWithConfig(ctx, aspectCtx, msg, tracer, commit, evmConfig, txConfig, false) } // ApplyMessageWithConfig computes the new states by applying the given message against the existing states. @@ -321,6 +318,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, commit bool, cfg *states.EVMConfig, txConfig states.TxConfig, + isCustomVerification bool, ) (*txs.MsgEthereumTxResponse, error) { var ( ret []byte // return bytes from evm execution @@ -351,19 +349,21 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, leftoverGas := msg.GasLimit // Allow the tracer captures the txs level events, mainly the gas consumption. - // evmCfg := evm.Config - // if evmCfg.Debug { - // evmCfg.Tracer.CaptureTxStart(leftoverGas) - // defer func() { - // evmCfg.Tracer.CaptureTxEnd(leftoverGas) - // }() - // } + var aspectLogger asptypes.AspectLogger + if tracer != nil { + tracer.CaptureTxStart(leftoverGas) + defer func() { + tracer.CaptureTxEnd(leftoverGas) + }() + + aspectLogger, _ = tracer.(asptypes.AspectLogger) + } sender := vm.AccountRef(msg.From) contractCreation := msg.To == nil isLondon := cfg.ChainConfig.IsLondon(evm.Context.BlockNumber) - intrinsicGas, err := k.GetEthIntrinsicGas(ctx, msg, cfg.ChainConfig, contractCreation) + intrinsicGas, err := k.GetEthIntrinsicGas(ctx, msg, cfg.ChainConfig, contractCreation, isCustomVerification) if err != nil { // should have already been checked on Ante Handler return nil, errorsmod.Wrap(err, "intrinsic gas failed") @@ -386,11 +386,8 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, if isAspectOpTx := asptypes.IsAspectContractAddr(msg.To); isAspectOpTx { nativeContract := contract.NewAspectNativeContract(k.storeKey, evm, ctx.BlockHeight, stateDB, k.logger) - resp, aspectErr := nativeContract.ApplyMessage(ctx, msg, commit) - if resp != nil { - resp.Hash = txConfig.TxHash.Hex() - } - return resp, aspectErr + nativeContract.Init() + ret, leftoverGas, vmErr = nativeContract.ApplyMessage(ctx, msg, leftoverGas, commit) } else if contractCreation { // take over the nonce management from evm: // - reset sender's nonce to msg.Nonce() before calling evm. @@ -400,15 +397,14 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, stateDB.SetNonce(sender.Address(), msg.Nonce+1) } else { // begin pre tx aspect execution - - preTxResult := djpm.AspectInstance().PreTxExecute(aspectCtx, msg.To, ctx.BlockHeight(), leftoverGas, &asptypes.PreTxExecuteInput{ + preTxResult := djpm.AspectInstance().PreTxExecute(aspectCtx, msg.From, *msg.To, msg.Data, ctx.BlockHeight(), leftoverGas, msg.Value, &asptypes.PreTxExecuteInput{ Tx: &asptypes.WithFromTxInput{ Hash: aspectCtx.EthTxContext().TxContent().Hash().Bytes(), To: msg.To.Bytes(), From: msg.From.Bytes(), }, Block: &asptypes.BlockInput{Number: &lastHeight}, - }) + }, aspectLogger) leftoverGas = preTxResult.Gas if preTxResult.Err != nil { @@ -447,36 +443,39 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, } } - // set receipt - aspectCtx.EthTxContext().WithReceipt(ðereum.Receipt{ - Status: status, - Bloom: bloomReceipt, - Logs: logs, - GasUsed: gasUsed, - CumulativeGasUsed: cumulativeGasUsed, - }) - - // begin post tx aspect execution - postTxResult := djpm.AspectInstance().PostTxExecute(aspectCtx, msg.To, ctx.BlockHeight(), leftoverGas, - &asptypes.PostTxExecuteInput{ - Tx: &asptypes.WithFromTxInput{ - Hash: aspectCtx.EthTxContext().TxContent().Hash().Bytes(), - To: msg.To.Bytes(), - From: msg.From.Bytes(), - }, - Block: &asptypes.BlockInput{Number: &lastHeight}, - Receipt: &asptypes.ReceiptInput{Status: &status}, + // only trigger post tx execute if tx not reverted + if vmErr == nil { + // set receipt + aspectCtx.EthTxContext().WithReceipt(ðereum.Receipt{ + Status: status, + Bloom: bloomReceipt, + Logs: logs, + GasUsed: gasUsed, + CumulativeGasUsed: cumulativeGasUsed, }) - if postTxResult.Err != nil { - // overwrite vmErr if post tx reverted - if postTxResult.Err.Error() == vm.ErrOutOfGas.Error() { - vmErr = vm.ErrOutOfGas - } else { - vmErr = postTxResult.Err + + // begin post tx aspect execution + postTxResult := djpm.AspectInstance().PostTxExecute(aspectCtx, msg.From, *msg.To, msg.Data, ctx.BlockHeight(), leftoverGas, msg.Value, + &asptypes.PostTxExecuteInput{ + Tx: &asptypes.WithFromTxInput{ + Hash: aspectCtx.EthTxContext().TxContent().Hash().Bytes(), + To: msg.To.Bytes(), + From: msg.From.Bytes(), + }, + Block: &asptypes.BlockInput{Number: &lastHeight}, + Receipt: &asptypes.ReceiptInput{Status: &status}, + }, aspectLogger) + if postTxResult.Err != nil { + // overwrite vmErr if post tx reverted + if postTxResult.Err.Error() == vm.ErrOutOfGas.Error() { + vmErr = vm.ErrOutOfGas + } else { + vmErr = postTxResult.Err + } + ret = postTxResult.Ret } - ret = postTxResult.Ret + leftoverGas = postTxResult.Gas } - leftoverGas = postTxResult.Gas } } @@ -525,7 +524,6 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, gasUsed := cosmos.MaxDec(minimumGasUsed, cosmos.NewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() // reset leftoverGas, to be used by the tracer - // nolint leftoverGas = msg.GasLimit - gasUsed return &txs.MsgEthereumTxResponse{ diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 9b4d709d..c594eb12 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -8,30 +8,26 @@ import ( "math/big" "time" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/txs/support" - "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "cosmossdk.io/math" cosmos "github.com/cosmos/cosmos-sdk/types" - - "github.com/artela-network/artela-evm/tracers" - "github.com/artela-network/artela-evm/tracers/logger" - "github.com/artela-network/artela-evm/vm" - - artela "github.com/artela-network/artela/ethereum/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" ethereum "github.com/ethereum/go-ethereum/core/types" ethparams "github.com/ethereum/go-ethereum/params" + "github.com/artela-network/artela-evm/tracers" + "github.com/artela-network/artela-evm/tracers/logger" + "github.com/artela-network/artela-evm/vm" + artela "github.com/artela-network/artela/ethereum/types" "github.com/artela-network/artela/x/evm/artela/provider" artelatypes "github.com/artela-network/artela/x/evm/artela/types" "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/txs/support" "github.com/artela-network/artela/x/evm/types" inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" ) @@ -262,7 +258,8 @@ func (k Keeper) EthCall(c context.Context, req *txs.EthCallRequest) (*txs.MsgEth defer aspectCtx.Destroy() // pass false to not commit StateDB - res, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, nil, false, cfg, txConfig) + isCustomVerification := len(args.GetValidationData()) > 0 + res, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, nil, false, cfg, txConfig, isCustomVerification) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -324,13 +321,6 @@ func (k Keeper) EstimateGas(c context.Context, req *txs.EthCallRequest) (*txs.Es return nil, status.Error(codes.Internal, "failed to load evm config") } - // Aspect Runtime Context Lifecycle: create aspect context. - // This marks the beginning of running an aspect of EstimateGas, creating the aspect context, - // and establishing the link with the SDK context. - ctx, aspectCtx := k.WithAspectContext(ctx, txMsg.AsTransaction(), cfg, - artelatypes.NewEthBlockContextFromQuery(ctx, k.clientContext)) - defer aspectCtx.Destroy() - // ApplyMessageWithConfig expect correct nonce set in msg nonce := k.GetNonce(ctx, args.GetFrom()) args.Nonce = (*hexutil.Uint64)(&nonce) @@ -346,12 +336,23 @@ func (k Keeper) EstimateGas(c context.Context, req *txs.EthCallRequest) (*txs.Es // NOTE: the errors from the executable below should be consistent with go-ethereum, // so we don't wrap them with the gRPC status code + isCustomVerification := len(args.GetValidationData()) > 0 + // Create a helper to check if a gas allowance results in an executable txs executable := func(gas uint64) (vmError bool, rsp *txs.MsgEthereumTxResponse, err error) { + // need to create a cache context here to avoid state change affecting each other + tmpCtx, _ := ctx.CacheContext() + // Aspect Runtime Context Lifecycle: create aspect context. + // This marks the beginning of running an aspect of EstimateGas, creating the aspect context, + // and establishing the link with the SDK context. + cosmosCtx, aspectCtx := k.WithAspectContext(tmpCtx, txMsg.AsTransaction(), cfg, + artelatypes.NewEthBlockContextFromQuery(tmpCtx, k.clientContext)) + defer aspectCtx.Destroy() + // update the message with the new gas value msg.GasLimit = gas // pass false to not commit StateDB - rsp, err = k.ApplyMessageWithConfig(ctx, aspectCtx, msg, nil, false, cfg, txConfig) + rsp, err = k.ApplyMessageWithConfig(cosmosCtx, aspectCtx, msg, nil, false, cfg, txConfig, isCustomVerification) if err != nil { if errors.Is(err, core.ErrIntrinsicGas) { return true, nil, nil // Special case, raise gas limit @@ -430,20 +431,23 @@ func (k Keeper) TraceTx(c context.Context, req *txs.QueryTraceTxRequest) (*txs.Q // and establishing the link with the SDK context. ctx, aspectCtx := k.WithAspectContext(ctx, ethTx, cfg, artelatypes.NewEthBlockContextFromQuery(ctx, k.clientContext)) - defer aspectCtx.Destroy() msg, err := txs.ToMessage(ethTx, signer, cfg.BaseFee) if err != nil { + aspectCtx.Destroy() continue } txConfig.TxHash = ethTx.Hash() txConfig.TxIndex = uint(i) - rsp, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, txs.NewNoOpTracer(), true, cfg, txConfig) + isCustomVerification := k.isCustomizedVerification(ethTx) + rsp, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, txs.NewNoOpTracer(), true, cfg, txConfig, isCustomVerification) if err != nil { + aspectCtx.Destroy() continue } + aspectCtx.Destroy() txConfig.LogIndex += uint(len(rsp.Logs)) } @@ -579,7 +583,7 @@ func (k *Keeper) traceTx( } if traceConfig.Overrides != nil { - overrides = traceConfig.Overrides.EthereumConfig(cfg.ChainConfig.ChainID) + overrides = traceConfig.Overrides.EthereumConfig(ctx.BlockHeight(), cfg.ChainConfig.ChainID) } logConfig := logger.Config{ @@ -624,7 +628,8 @@ func (k *Keeper) traceTx( } }() - res, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, tracer, commitMessage, cfg, txConfig) + isCustomVerification := k.isCustomizedVerification(tx) + res, err := k.ApplyMessageWithConfig(ctx, aspectCtx, msg, tracer, commitMessage, cfg, txConfig, isCustomVerification) if err != nil { return nil, 0, status.Error(codes.Internal, err.Error()) } @@ -642,7 +647,7 @@ func (k Keeper) BaseFee(c context.Context, _ *txs.QueryBaseFeeRequest) (*txs.Que ctx := cosmos.UnwrapSDKContext(c) params := k.GetParams(ctx) - ethCfg := params.ChainConfig.EthereumConfig(k.eip155ChainID) + ethCfg := params.ChainConfig.EthereumConfig(ctx.BlockHeight(), k.eip155ChainID) baseFee := k.GetBaseFee(ctx, ethCfg) res := &txs.QueryBaseFeeResponse{} diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 8ef039d7..616e174a 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -1,26 +1,15 @@ package keeper import ( + "encoding/base64" "fmt" "math/big" - - "github.com/artela-network/aspect-core/djpm" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - - "github.com/artela-network/artela/x/evm/artela/api" - "github.com/artela-network/artela/x/evm/artela/provider" - - "github.com/artela-network/artela-evm/vm" - - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/states" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/txs/support" + "sync" errorsmod "cosmossdk.io/errors" "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -31,10 +20,18 @@ import ( ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - artelaType "github.com/artela-network/aspect-core/types" - + "github.com/artela-network/artela-evm/vm" + common2 "github.com/artela-network/artela/common" + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/artela/api" + "github.com/artela-network/artela/x/evm/artela/provider" artvmtype "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/txs/support" "github.com/artela-network/artela/x/evm/types" + "github.com/artela-network/aspect-core/djpm" + artelaType "github.com/artela-network/aspect-core/types" ) // Keeper grants access to the EVM module states and implements the go-ethereum StateDB interface. @@ -84,6 +81,9 @@ type Keeper struct { // store the block context, this will be fresh every block. BlockContext *artvmtype.EthBlockContext + + // cache of aspect sig + VerifySigCache *sync.Map } // NewKeeper generates new evm module keeper @@ -131,10 +131,11 @@ func NewKeeper( ss: subSpace, aspectRuntimeContext: aspectRuntimeContext, aspect: aspect, + VerifySigCache: &sync.Map{}, } k.WithChainID(app.ChainId()) - djpm.NewAspect(aspect, k.logger) + djpm.NewAspect(aspect, common2.WrapLogger(k.logger.With("module", "aspect"))) api.InitAspectGlobals(k) // init aspect host api factory @@ -149,7 +150,6 @@ func NewKeeper( artelaType.GetAspectContext = k.GetAspectContext artelaType.SetAspectContext = k.SetAspectContext - artelaType.GetAspectPaymaster = aspect.GetAspectAccount artelaType.JITSenderAspectByContext = k.JITSenderAspectByContext artelaType.IsCommit = k.IsCommit return k @@ -208,10 +208,15 @@ func (k Keeper) GetAuthority() cosmos.AccAddress { // EmitBlockBloomEvent emit block bloom events func (k Keeper) EmitBlockBloomEvent(ctx cosmos.Context, bloom ethereum.Bloom) { + encodedBloom := base64.StdEncoding.EncodeToString(bloom.Bytes()) + + sprintf := fmt.Sprintf("emit block event %d bloom %s header %d, ", len(bloom.Bytes()), encodedBloom, ctx.BlockHeight()) + k.Logger(ctx).Info(sprintf) + ctx.EventManager().EmitEvent( cosmos.NewEvent( types.EventTypeBlockBloom, - cosmos.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())), + cosmos.NewAttribute(types.AttributeKeyEthereumBloom, encodedBloom), ), ) } @@ -236,8 +241,8 @@ func (k Keeper) SetBlockBloomTransient(ctx cosmos.Context, bloom *big.Int) { store.Set(heightBz, bloom.Bytes()) k.Logger(ctx).Debug( - fmt.Sprintf("setState: SetBlockBloomTransient"), - "block-height", fmt.Sprintf("%d", ctx.BlockHeight()), + "setState: SetBlockBloomTransient", + "block-height", ctx.BlockHeight(), "bloom", bloom.String(), ) } @@ -252,9 +257,9 @@ func (k Keeper) SetTxIndexTransient(ctx cosmos.Context, index uint64) { store.Set(types.KeyPrefixTransientTxIndex, cosmos.Uint64ToBigEndian(index)) k.Logger(ctx).Debug( - fmt.Sprintf("setState: SetTxIndexTransient"), + "setState: SetTxIndexTransient", "key", "KeyPrefixTransientTxIndex", - "index", fmt.Sprintf("%d", index), + "index", index, ) } @@ -291,9 +296,9 @@ func (k Keeper) SetLogSizeTransient(ctx cosmos.Context, logSize uint64) { store.Set(types.KeyPrefixTransientLogSize, cosmos.Uint64ToBigEndian(logSize)) k.Logger(ctx).Debug( - fmt.Sprintf("setState: SetLogSizeTransient"), + "setState: SetLogSizeTransient", "key", "KeyPrefixTransientLogSize", - "logSize", fmt.Sprintf("%d", logSize), + "logSize", logSize, ) } @@ -440,7 +445,7 @@ func (k Keeper) SetTransientGasUsed(ctx cosmos.Context, gasUsed uint64) { store.Set(types.KeyPrefixTransientGasUsed, bz) k.Logger(ctx).Debug( - fmt.Sprintf("setState: SetTransientGasUsed, set"), + "setState: SetTransientGasUsed, set", "key", "KeyPrefixTransientGasUsed", "gasUsed", fmt.Sprintf("%d", gasUsed), ) diff --git a/x/evm/keeper/meter.go b/x/evm/keeper/meter.go index 84b8de30..ab2bdf05 100644 --- a/x/evm/keeper/meter.go +++ b/x/evm/keeper/meter.go @@ -3,8 +3,10 @@ package keeper import ( "math/big" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/types" + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + cosmos "github.com/cosmos/cosmos-sdk/types" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authmodule "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -12,21 +14,30 @@ import ( ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - cosmos "github.com/cosmos/cosmos-sdk/types" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/types" + "github.com/artela-network/aspect-core/djpm" ) // GetEthIntrinsicGas returns the intrinsic gas cost for the transaction. -func (k *Keeper) GetEthIntrinsicGas(ctx cosmos.Context, msg *core.Message, cfg *params.ChainConfig, isContractCreation bool) (uint64, error) { +func (k *Keeper) GetEthIntrinsicGas(ctx cosmos.Context, msg *core.Message, cfg *params.ChainConfig, isContractCreation bool, isCustomVerification bool) (uint64, error) { blockHeight := big.NewInt(ctx.BlockHeight()) homestead := cfg.IsHomestead(blockHeight) istanbul := cfg.IsIstanbul(blockHeight) // EIP3860(limit and meter initcode): https://eips.ethereum.org/EIPS/eip-3860 - return core.IntrinsicGas(msg.Data, msg.AccessList, isContractCreation, homestead, istanbul, false) + intrinsic, err := core.IntrinsicGas(msg.Data, msg.AccessList, isContractCreation, homestead, istanbul, false) + if err != nil { + return 0, err + } + + // for custom verification transaction we add an extra tx verification gas cost as intrinsic gas + if isCustomVerification { + intrinsic += djpm.MaxTxVerificationGas + } + + return intrinsic, nil } // RefundGas transfers the leftover gas to the sender of the message, caped to half of the total gas diff --git a/x/evm/keeper/migrations.go b/x/evm/keeper/migrations.go index 5fa16595..a845c031 100644 --- a/x/evm/keeper/migrations.go +++ b/x/evm/keeper/migrations.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/artela-network/artela/x/evm/migrations/v047rc7" + "github.com/artela-network/artela/x/evm/migrations/v048rc8" ) // Migrator is a struct for handling in-place store migrations. @@ -18,7 +19,12 @@ func NewMigrator(keeper Keeper) Migrator { } } -// Migrate3to4 migrates the store from consensus version 3 to 4 +// Migrate5to6 migrates the store from consensus version 5 to 6 func (m Migrator) Migrate5to6(ctx sdk.Context) error { return v047rc7.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.keeper.logger) } + +// Migrate6to7 migrates the store from consensus version 6 to 7 +func (m Migrator) Migrate6to7(ctx sdk.Context) error { + return v048rc8.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc, m.keeper.logger) +} diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 3b75dc1d..12c85fb1 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -6,18 +6,15 @@ import ( "fmt" "strconv" - "github.com/artela-network/artela/x/evm/txs" - - govmodule "github.com/cosmos/cosmos-sdk/x/gov/types" - - tmbytes "github.com/cometbft/cometbft/libs/bytes" - cometbft "github.com/cometbft/cometbft/types" - errorsmod "cosmossdk.io/errors" "github.com/armon/go-metrics" + tmbytes "github.com/cometbft/cometbft/libs/bytes" + cometbft "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/telemetry" cosmos "github.com/cosmos/cosmos-sdk/types" + govmodule "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/artela-network/artela/x/evm/txs" "github.com/artela-network/artela/x/evm/types" ) diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index 6b447fcd..9ff7e1e0 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -2,10 +2,12 @@ package keeper import ( "fmt" - "github.com/artela-network/artela/x/evm/txs/support" - "github.com/artela-network/artela/x/evm/types" + cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela/x/evm/txs/support" + "github.com/artela-network/artela/x/evm/types" ) // GetParams returns the total set of evm parameters. @@ -23,7 +25,7 @@ func (k Keeper) GetParams(ctx cosmos.Context) (params support.Params) { func (k *Keeper) GetChainConfig(ctx cosmos.Context) *params.ChainConfig { chainParams := k.GetParams(ctx) - ethCfg := chainParams.ChainConfig.EthereumConfig(k.ChainID()) + ethCfg := chainParams.ChainConfig.EthereumConfig(ctx.BlockHeight(), k.ChainID()) return ethCfg } diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index 4a826f83..9e7cb536 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -4,17 +4,17 @@ import ( "fmt" "math/big" - artela "github.com/artela-network/artela/ethereum/types" "github.com/status-im/keycard-go/hexutils" - sdkmath "cosmossdk.io/math" - errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela/x/evm/states" - "github.com/artela-network/artela/x/evm/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/store/prefix" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/artela/x/evm/types" ) var _ states.Keeper = &Keeper{} diff --git a/x/evm/keeper/tx_verify.go b/x/evm/keeper/tx_verify.go index 3ee26d18..15811aac 100644 --- a/x/evm/keeper/tx_verify.go +++ b/x/evm/keeper/tx_verify.go @@ -4,17 +4,17 @@ import ( "errors" "math/big" - "github.com/artela-network/artela/ethereum/utils" - "github.com/ethereum/go-ethereum/params" - errorsmod "cosmossdk.io/errors" - artelatype "github.com/artela-network/artela/x/evm/artela/types" - "github.com/artela-network/artela/x/evm/states" - "github.com/artela-network/aspect-core/djpm" cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela/ethereum/utils" + artelatype "github.com/artela-network/artela/x/evm/artela/types" + "github.com/artela-network/artela/x/evm/states" + "github.com/artela-network/aspect-core/djpm" ) func (k *Keeper) VerifySig(ctx cosmos.Context, tx *ethereum.Transaction) (common.Address, []byte, error) { @@ -33,7 +33,7 @@ func (k *Keeper) VerifySig(ctx cosmos.Context, tx *ethereum.Transaction) (common chainID := k.ChainID() evmParams := k.GetParams(ctx) chainCfg := evmParams.GetChainConfig() - ethCfg := chainCfg.EthereumConfig(chainID) + ethCfg := chainCfg.EthereumConfig(ctx.BlockHeight(), chainID) blockNum := big.NewInt(ctx.BlockHeight()) signer := ethereum.MakeSigner(ethCfg, blockNum, uint64(ctx.BlockTime().Unix())) @@ -56,12 +56,38 @@ func (k *Keeper) VerifySig(ctx cosmos.Context, tx *ethereum.Transaction) (common } func (k *Keeper) tryAspectVerifier(ctx cosmos.Context, tx *ethereum.Transaction) (common.Address, []byte, error) { + value, ok := k.VerifySigCache.Load(tx.Hash()) + if ok { + retValue := value.(struct { + sender common.Address + callData []byte + err error + }) + return retValue.sender, retValue.callData, retValue.err + } + // retrieve aspectCtx from sdk.Context aspectCtx, ok := ctx.Value(artelatype.AspectContextKey).(*artelatype.AspectRuntimeContext) if !ok { - return common.Address{}, []byte{}, errors.New("ApplyMessageWithConfig: wrap *artelatype.AspectRuntimeContext failed") + return common.Address{}, []byte{}, errors.New("aspect transaction verification failed") + } + + sender, call, err := djpm.AspectInstance().GetSenderAndCallData(aspectCtx, aspectCtx.EthBlockContext().BlockHeader().Number.Int64(), tx) + + // not cache for eth_all, which hash is empty + if tx.Hash() != (common.Hash{}) { + k.VerifySigCache.Store(tx.Hash(), struct { + sender common.Address + callData []byte + err error + }{ + sender: sender, + callData: call, + err: err, + }) } - return djpm.AspectInstance().GetSenderAndCallData(aspectCtx, aspectCtx.EthBlockContext().BlockHeader().Number.Int64(), tx) + + return sender, call, err } func (k *Keeper) MakeSigner(ctx cosmos.Context, tx *ethereum.Transaction, config *params.ChainConfig, blockNumber *big.Int, blockTime uint64) ethereum.Signer { diff --git a/x/evm/migrations/v047rc7/migrate.go b/x/evm/migrations/v047rc7/migrate.go index 282210d1..898e7ac5 100644 --- a/x/evm/migrations/v047rc7/migrate.go +++ b/x/evm/migrations/v047rc7/migrate.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, logger log.Logger) error { +func MigrateStore(_ sdk.Context, _ storetypes.StoreKey, _ codec.BinaryCodec, logger log.Logger) error { logger.Error("v047rc7 Migrate Store is updating") return nil } diff --git a/x/evm/migrations/v048rc8/migrate.go b/x/evm/migrations/v048rc8/migrate.go new file mode 100644 index 00000000..875c11fc --- /dev/null +++ b/x/evm/migrations/v048rc8/migrate.go @@ -0,0 +1,13 @@ +package v048rc8 + +import ( + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func MigrateStore(_ sdk.Context, _ storetypes.StoreKey, _ codec.BinaryCodec, logger log.Logger) error { + logger.Error("v048rc8 Migrate Store is updating") + return nil +} diff --git a/x/evm/module.go b/x/evm/module.go index 282c3b13..d7f29259 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -8,11 +8,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "github.com/artela-network/artela/x/evm/txs" - "github.com/artela-network/artela/x/evm/txs/support" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -22,11 +18,13 @@ import ( "github.com/artela-network/artela/x/evm/client/cli" "github.com/artela-network/artela/x/evm/keeper" + "github.com/artela-network/artela/x/evm/txs" + "github.com/artela-network/artela/x/evm/txs/support" "github.com/artela-network/artela/x/evm/types" ) // TODO mark ConsensusVersion defines the current x/evm module consensus version. -const ConsensusVersion = 6 +const ConsensusVersion = 7 var ( _ module.AppModule = AppModule{} @@ -120,11 +118,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { txs.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := keeper.NewMigrator(*am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6) - if err != nil { + + if err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 6, m.Migrate6to7); err != nil { + panic(err) + } } // NewAppModule creates a new AppModule object diff --git a/x/evm/states/config.go b/x/evm/states/config.go index bfc14b4b..9b30f65e 100644 --- a/x/evm/states/config.go +++ b/x/evm/states/config.go @@ -3,9 +3,10 @@ package states import ( "math/big" - "github.com/artela-network/artela/x/evm/txs/support" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela/x/evm/txs/support" ) // EVMConfig encapsulates common parameters needed to create an EVM to execute a message diff --git a/x/evm/states/interface.go b/x/evm/states/interface.go index 201b6e7d..5503689b 100644 --- a/x/evm/states/interface.go +++ b/x/evm/states/interface.go @@ -1,9 +1,10 @@ package states import ( - "github.com/artela-network/artela-evm/vm" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela-evm/vm" ) // ExtStateDB defines an extension to the interface provided by the go-ethereum diff --git a/x/evm/states/journal.go b/x/evm/states/journal.go index e38fc80d..6a82d034 100644 --- a/x/evm/states/journal.go +++ b/x/evm/states/journal.go @@ -127,6 +127,11 @@ type ( address *common.Address slot *common.Hash } + + transientStorageChange struct { + account *common.Address + key, prevalue common.Hash + } ) // ---------------------------------------------------------------------------- @@ -273,3 +278,15 @@ func (ch accessListAddSlotChange) Revert(s *StateDB) { func (ch accessListAddSlotChange) Dirtied() *common.Address { return nil } + +// ---------------------------------------------------------------------------- +// transientStorageChange +// ---------------------------------------------------------------------------- + +func (ch transientStorageChange) Revert(s *StateDB) { + s.SetTransientState(*ch.account, ch.key, ch.prevalue) +} + +func (ch transientStorageChange) Dirtied() *common.Address { + return nil +} diff --git a/x/evm/states/statedb.go b/x/evm/states/statedb.go index 1fc2396b..a7cd04b4 100644 --- a/x/evm/states/statedb.go +++ b/x/evm/states/statedb.go @@ -8,12 +8,13 @@ import ( "sort" errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela-evm/vm" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela-evm/vm" ) type revision struct { @@ -35,6 +36,8 @@ type StateDB struct { // This map holds 'live' objects, which will get modified while processing a state transition. stateObjects map[common.Address]*stateObject + transientStorage transientStorage + txConfig TxConfig // The refund counter, also used by states transitioning. @@ -50,31 +53,57 @@ type StateDB struct { // Snapshot and RevertToSnapshot. journal *journal validRevisions []revision - nextRevisionId int + nextRevisionID int } // New creates a new states from a given trie. func New(ctx cosmos.Context, keeper Keeper, txConfig TxConfig) *StateDB { return &StateDB{ - keeper: keeper, - ctx: ctx, - stateObjects: make(map[common.Address]*stateObject), - journal: newJournal(), - accessList: newAccessList(), + keeper: keeper, + ctx: ctx, + stateObjects: make(map[common.Address]*stateObject), + journal: newJournal(), + accessList: newAccessList(), + transientStorage: newTransientStorage(), txConfig: txConfig, } } -func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses ethereum.AccessList) { - // TODO mark this is a new method in ethereum 1.20, implement this here. +// Prepare handles the preparatory steps for executing a state transition with. +// This method must be invoked before state transition. +// +// Berlin fork: +// - Add sender to access list (2929) +// - Add destination to access list (2929) +// - Add precompiles to access list (2929) +// - Add the contents of the optional tx access list (2930) +// +// Potential EIPs: +// - Reset access list (Berlin) +// - Add coinbase to access list (EIP-3651) +// - Reset transient storage (EIP-1153) +func (s *StateDB) Prepare(_ params.Rules, _, _ common.Address, _ *common.Address, _ []common.Address, _ ethereum.AccessList) { + // TODO: complete the prepare for EIP2929 & EIP4762 + // Reset transient storage at the beginning of transaction execution + s.transientStorage = newTransientStorage() } func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash { - return common.Hash{} + return s.transientStorage.Get(addr, key) } func (s *StateDB) SetTransientState(addr common.Address, key, value common.Hash) { + prev := s.GetTransientState(addr, key) + if prev == value { + return + } + s.journal.append(transientStorageChange{ + account: &addr, + key: key, + prevalue: prev, + }) + s.transientStorage.Set(addr, key, value) } // Keeper returns the underlying `Keeper` @@ -426,8 +455,8 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // Snapshot returns an identifier for the current revision of the states. func (s *StateDB) Snapshot() int { - id := s.nextRevisionId - s.nextRevisionId++ + id := s.nextRevisionID + s.nextRevisionID++ s.validRevisions = append(s.validRevisions, revision{id, s.journal.length()}) return id } diff --git a/x/evm/states/storage.go b/x/evm/states/storage.go index f7991521..20b1a909 100644 --- a/x/evm/states/storage.go +++ b/x/evm/states/storage.go @@ -2,6 +2,7 @@ package states import ( "bytes" + "maps" "sort" "github.com/ethereum/go-ethereum/common" @@ -21,3 +22,7 @@ func (s Storage) SortedKeys() []common.Hash { }) return keys } + +func (s Storage) Copy() Storage { + return maps.Clone(s) +} diff --git a/x/evm/states/transient_storage.go b/x/evm/states/transient_storage.go new file mode 100644 index 00000000..a8b0a844 --- /dev/null +++ b/x/evm/states/transient_storage.go @@ -0,0 +1,97 @@ +// Copyright 2022 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package states + +import ( + "bytes" + "fmt" + "slices" + "strings" + + "github.com/ethereum/go-ethereum/common" +) + +// transientStorage is a representation of EIP-1153 "Transient Storage". +type transientStorage map[common.Address]Storage + +// newTransientStorage creates a new instance of a transientStorage. +func newTransientStorage() transientStorage { + return make(transientStorage) +} + +// Set sets the transient-storage `value` for `key` at the given `addr`. +func (t transientStorage) Set(addr common.Address, key, value common.Hash) { + if value == (common.Hash{}) { // this is a 'delete' + if _, ok := t[addr]; ok { + delete(t[addr], key) + if len(t[addr]) == 0 { + delete(t, addr) + } + } + } else { + if _, ok := t[addr]; !ok { + t[addr] = make(Storage) + } + t[addr][key] = value + } +} + +// Get gets the transient storage for `key` at the given `addr`. +func (t transientStorage) Get(addr common.Address, key common.Hash) common.Hash { + val, ok := t[addr] + if !ok { + return common.Hash{} + } + return val[key] +} + +// Copy does a deep copy of the transientStorage +func (t transientStorage) Copy() transientStorage { + storage := make(transientStorage) + for key, value := range t { + storage[key] = value.Copy() + } + return storage +} + +// PrettyPrint prints the contents of the access list in a human-readable form +func (t transientStorage) PrettyPrint() string { + out := new(strings.Builder) + sortedAddrs := make([]common.Address, 0, len(t)) + for addr := range t { + sortedAddrs = append(sortedAddrs, addr) + slices.SortFunc(sortedAddrs, func(a, b common.Address) int { + return bytes.Compare(a[:], b[:]) + }) + } + + for _, addr := range sortedAddrs { + fmt.Fprintf(out, "%#x:", addr) + var sortedKeys []common.Hash + storage := t[addr] + for key := range storage { + sortedKeys = append(sortedKeys, key) + } + slices.SortFunc(sortedKeys, func(a, b common.Hash) int { + return bytes.Compare(a[:], b[:]) + }) + for _, key := range sortedKeys { + fmt.Fprintf(out, " %X : %X\n", key, storage[key]) + } + } + return out.String() +} diff --git a/x/evm/txs/eip2930.go b/x/evm/txs/eip2930.go index f692d4c6..059c722e 100644 --- a/x/evm/txs/eip2930.go +++ b/x/evm/txs/eip2930.go @@ -1,22 +1,23 @@ package txs -//EIP-2930 was part of the Berlin upgrade and is seen as a step towards improving the -//efficiency and flexibility of the Ethereum network. It allows for more sophisticated -//transaction handling and can mitigate some of the effects of increased gas costs -//introduced by other changes in the protocol. +// EIP-2930 was part of the Berlin upgrade and is seen as a step towards improving the +// efficiency and flexibility of the Ethereum network. It allows for more sophisticated +// transaction handling and can mitigate some of the effects of increased gas costs +// introduced by other changes in the protocol. // -//Access lists in EIP-2930 provide several benefits: -//1. **Gas Cost Predictability**: By specifying the addresses and keys that will be accessed, -//the sender can pre-calculate the gas costs, making them more predictable. -//2. **Increased Efficiency**: Clients and miners can txs transactions more efficiently, -//as they know in advance which addresses and keys will be accessed. -//3. **Compatibility with Future Upgrades**: Access lists can facilitate smoother upgrades, -//such as the transition to Ethereum 2.0, by allowing transactions to explicitly states their dependencies. +// Access lists in EIP-2930 provide several benefits: +// 1. **Gas Cost Predictability**: By specifying the addresses and keys that will be accessed, +// the sender can pre-calculate the gas costs, making them more predictable. +// 2. **Increased Efficiency**: Clients and miners can txs transactions more efficiently, +// as they know in advance which addresses and keys will be accessed. +// 3. **Compatibility with Future Upgrades**: Access lists can facilitate smoother upgrades, +// such as the transition to Ethereum 2.0, by allowing transactions to explicitly states their dependencies. import ( - "github.com/artela-network/artela/x/evm/txs/support" "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" + + "github.com/artela-network/artela/x/evm/txs/support" ) // AccessList is EIP-2930 access list diff --git a/x/evm/txs/support/chain_config.go b/x/evm/txs/support/chain_config.go index e243714c..047644a5 100644 --- a/x/evm/txs/support/chain_config.go +++ b/x/evm/txs/support/chain_config.go @@ -1,23 +1,37 @@ package support import ( + "math" "math/big" "strings" - "github.com/artela-network/artela/x/evm/types" - - sdkmath "cosmossdk.io/math" - errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" cosmos "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela/x/evm/types" +) + +const ( + epochZero = uint64(0) + epochInfinite = math.MaxUint64 ) // EthereumConfig returns an Ethereum ChainConfig for EVM states transitions. // All the negative or nil values are converted to nil -func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { +func (cc ChainConfig) EthereumConfig(currentBlock int64, chainID *big.Int) *params.ChainConfig { + // use height instead of time to determine if the fork has been applied + shanghaiTime := epochZero + if currentBlock < cc.ShanghaiBlock.Int64() { + shanghaiTime = epochInfinite + } + cancunTime := epochZero + if currentBlock < cc.CancunBlock.Int64() { + cancunTime = epochInfinite + } + return ¶ms.ChainConfig{ ChainID: chainID, HomesteadBlock: getBlockValue(cc.HomesteadBlock), @@ -25,20 +39,20 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { DAOForkSupport: cc.DAOForkSupport, EIP150Block: getBlockValue(cc.EIP150Block), // EIP150Hash: common.HexToHash(cc.EIP150Hash), - EIP155Block: getBlockValue(cc.EIP155Block), - EIP158Block: getBlockValue(cc.EIP158Block), - ByzantiumBlock: getBlockValue(cc.ByzantiumBlock), - ConstantinopleBlock: getBlockValue(cc.ConstantinopleBlock), - PetersburgBlock: getBlockValue(cc.PetersburgBlock), - IstanbulBlock: getBlockValue(cc.IstanbulBlock), - MuirGlacierBlock: getBlockValue(cc.MuirGlacierBlock), - BerlinBlock: getBlockValue(cc.BerlinBlock), - LondonBlock: getBlockValue(cc.LondonBlock), - ArrowGlacierBlock: getBlockValue(cc.ArrowGlacierBlock), - GrayGlacierBlock: getBlockValue(cc.GrayGlacierBlock), - MergeNetsplitBlock: getBlockValue(cc.MergeNetsplitBlock), - // ShanghaiBlock: getBlockValue(cc.ShanghaiBlock), - // CancunBlock: getBlockValue(cc.CancunBlock), + EIP155Block: getBlockValue(cc.EIP155Block), + EIP158Block: getBlockValue(cc.EIP158Block), + ByzantiumBlock: getBlockValue(cc.ByzantiumBlock), + ConstantinopleBlock: getBlockValue(cc.ConstantinopleBlock), + PetersburgBlock: getBlockValue(cc.PetersburgBlock), + IstanbulBlock: getBlockValue(cc.IstanbulBlock), + MuirGlacierBlock: getBlockValue(cc.MuirGlacierBlock), + BerlinBlock: getBlockValue(cc.BerlinBlock), + LondonBlock: getBlockValue(cc.LondonBlock), + ArrowGlacierBlock: getBlockValue(cc.ArrowGlacierBlock), + GrayGlacierBlock: getBlockValue(cc.GrayGlacierBlock), + MergeNetsplitBlock: getBlockValue(cc.MergeNetsplitBlock), + ShanghaiTime: &shanghaiTime, + CancunTime: &cancunTime, TerminalTotalDifficulty: nil, Ethash: nil, Clique: nil, @@ -146,7 +160,7 @@ func (cc ChainConfig) Validate() error { return errorsmod.Wrap(err, "CancunBlock") } // NOTE: chain ID is not needed to check config order - if err := cc.EthereumConfig(nil).CheckConfigForkOrder(); err != nil { + if err := cc.EthereumConfig(0, nil).CheckConfigForkOrder(); err != nil { return errorsmod.Wrap(err, "invalid config fork order") } return nil diff --git a/x/evm/txs/support/logs.go b/x/evm/txs/support/logs.go index 7d1fdd10..0cba8682 100644 --- a/x/evm/txs/support/logs.go +++ b/x/evm/txs/support/logs.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" - artela "github.com/artela-network/artela/ethereum/types" "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" + + artela "github.com/artela-network/artela/ethereum/types" ) // ---------------------------------------------------------------------------- @@ -109,7 +110,7 @@ func NewLogsFromEth(ethlogs []*ethereum.Log) []*Log { // LogsToEthereum casts the Artela Logs to a slice of Ethereum Logs. func LogsToEthereum(logs []*Log) []*ethereum.Log { - var ethLogs []*ethereum.Log //nolint: prealloc + ethLogs := make([]*ethereum.Log, 0, len(logs)) for i := range logs { ethLogs = append(ethLogs, logs[i].ToEthereum()) } diff --git a/x/evm/txs/support/params.go b/x/evm/txs/support/params.go index 7084c0fd..f798c871 100644 --- a/x/evm/txs/support/params.go +++ b/x/evm/txs/support/params.go @@ -4,14 +4,12 @@ import ( "fmt" "math/big" + cosmos "github.com/cosmos/cosmos-sdk/types" paramsmodule "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/artela-network/artela/ethereum/utils" - - "github.com/artela-network/artela-evm/vm" "github.com/ethereum/go-ethereum/params" - cosmos "github.com/cosmos/cosmos-sdk/types" + "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/artela/ethereum/utils" ) var ( diff --git a/x/evm/txs/support/storage.go b/x/evm/txs/support/storage.go index 277acbd5..902409e0 100644 --- a/x/evm/txs/support/storage.go +++ b/x/evm/txs/support/storage.go @@ -5,9 +5,9 @@ import ( "strings" errorsmod "cosmossdk.io/errors" + "github.com/ethereum/go-ethereum/common" "github.com/artela-network/artela/x/evm/types" - "github.com/ethereum/go-ethereum/common" ) // ---------------------------------------------------------------------------- diff --git a/x/evm/txs/tracer.go b/x/evm/txs/tracer.go index c1d52461..f5e54470 100644 --- a/x/evm/txs/tracer.go +++ b/x/evm/txs/tracer.go @@ -4,12 +4,12 @@ import ( "math/big" "os" - "github.com/artela-network/artela-evm/tracers/logger" - - "github.com/artela-network/artela-evm/vm" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/params" + + "github.com/artela-network/artela-evm/tracers/logger" + "github.com/artela-network/artela-evm/vm" ) const ( diff --git a/x/evm/txs/tx.pb.go b/x/evm/txs/tx.pb.go index ddf8dbd1..e521b665 100644 --- a/x/evm/txs/tx.pb.go +++ b/x/evm/txs/tx.pb.go @@ -49,35 +49,35 @@ type MsgEthereumTx struct { From string `protobuf:"bytes,4,opt,name=from,proto3" json:"from,omitempty"` } -func (m *MsgEthereumTx) Reset() { *m = MsgEthereumTx{} } -func (m *MsgEthereumTx) String() string { return proto.CompactTextString(m) } -func (*MsgEthereumTx) ProtoMessage() {} +func (msg *MsgEthereumTx) Reset() { *msg = MsgEthereumTx{} } +func (msg *MsgEthereumTx) String() string { return proto.CompactTextString(msg) } +func (*MsgEthereumTx) ProtoMessage() {} func (*MsgEthereumTx) Descriptor() ([]byte, []int) { return fileDescriptor_3c43c0836c37bbe6, []int{0} } -func (m *MsgEthereumTx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (msg *MsgEthereumTx) XXX_Unmarshal(b []byte) error { + return msg.Unmarshal(b) } -func (m *MsgEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (msg *MsgEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEthereumTx.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEthereumTx.Marshal(b, msg, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := msg.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *MsgEthereumTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEthereumTx.Merge(m, src) +func (msg *MsgEthereumTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEthereumTx.Merge(msg, src) } -func (m *MsgEthereumTx) XXX_Size() int { - return m.Size() +func (msg *MsgEthereumTx) XXX_Size() int { + return msg.Size() } -func (m *MsgEthereumTx) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEthereumTx.DiscardUnknown(m) +func (msg *MsgEthereumTx) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEthereumTx.DiscardUnknown(msg) } var xxx_messageInfo_MsgEthereumTx proto.InternalMessageInfo @@ -106,35 +106,35 @@ type LegacyTx struct { S []byte `protobuf:"bytes,9,opt,name=s,proto3" json:"s,omitempty"` } -func (m *LegacyTx) Reset() { *m = LegacyTx{} } -func (m *LegacyTx) String() string { return proto.CompactTextString(m) } -func (*LegacyTx) ProtoMessage() {} +func (tx *LegacyTx) Reset() { *tx = LegacyTx{} } +func (tx *LegacyTx) String() string { return proto.CompactTextString(tx) } +func (*LegacyTx) ProtoMessage() {} func (*LegacyTx) Descriptor() ([]byte, []int) { return fileDescriptor_3c43c0836c37bbe6, []int{1} } -func (m *LegacyTx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (tx *LegacyTx) XXX_Unmarshal(b []byte) error { + return tx.Unmarshal(b) } -func (m *LegacyTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (tx *LegacyTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_LegacyTx.Marshal(b, m, deterministic) + return xxx_messageInfo_LegacyTx.Marshal(b, tx, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := tx.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *LegacyTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_LegacyTx.Merge(m, src) +func (tx *LegacyTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyTx.Merge(tx, src) } -func (m *LegacyTx) XXX_Size() int { - return m.Size() +func (tx *LegacyTx) XXX_Size() int { + return tx.Size() } -func (m *LegacyTx) XXX_DiscardUnknown() { - xxx_messageInfo_LegacyTx.DiscardUnknown(m) +func (tx *LegacyTx) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyTx.DiscardUnknown(tx) } var xxx_messageInfo_LegacyTx proto.InternalMessageInfo @@ -165,35 +165,35 @@ type AccessListTx struct { S []byte `protobuf:"bytes,11,opt,name=s,proto3" json:"s,omitempty"` } -func (m *AccessListTx) Reset() { *m = AccessListTx{} } -func (m *AccessListTx) String() string { return proto.CompactTextString(m) } -func (*AccessListTx) ProtoMessage() {} +func (tx *AccessListTx) Reset() { *tx = AccessListTx{} } +func (tx *AccessListTx) String() string { return proto.CompactTextString(tx) } +func (*AccessListTx) ProtoMessage() {} func (*AccessListTx) Descriptor() ([]byte, []int) { return fileDescriptor_3c43c0836c37bbe6, []int{2} } -func (m *AccessListTx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (tx *AccessListTx) XXX_Unmarshal(b []byte) error { + return tx.Unmarshal(b) } -func (m *AccessListTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (tx *AccessListTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_AccessListTx.Marshal(b, m, deterministic) + return xxx_messageInfo_AccessListTx.Marshal(b, tx, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := tx.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *AccessListTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccessListTx.Merge(m, src) +func (tx *AccessListTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccessListTx.Merge(tx, src) } -func (m *AccessListTx) XXX_Size() int { - return m.Size() +func (tx *AccessListTx) XXX_Size() int { + return tx.Size() } -func (m *AccessListTx) XXX_DiscardUnknown() { - xxx_messageInfo_AccessListTx.DiscardUnknown(m) +func (tx *AccessListTx) XXX_DiscardUnknown() { + xxx_messageInfo_AccessListTx.DiscardUnknown(tx) } var xxx_messageInfo_AccessListTx proto.InternalMessageInfo @@ -226,35 +226,35 @@ type DynamicFeeTx struct { S []byte `protobuf:"bytes,12,opt,name=s,proto3" json:"s,omitempty"` } -func (m *DynamicFeeTx) Reset() { *m = DynamicFeeTx{} } -func (m *DynamicFeeTx) String() string { return proto.CompactTextString(m) } -func (*DynamicFeeTx) ProtoMessage() {} +func (tx *DynamicFeeTx) Reset() { *tx = DynamicFeeTx{} } +func (tx *DynamicFeeTx) String() string { return proto.CompactTextString(tx) } +func (*DynamicFeeTx) ProtoMessage() {} func (*DynamicFeeTx) Descriptor() ([]byte, []int) { return fileDescriptor_3c43c0836c37bbe6, []int{3} } -func (m *DynamicFeeTx) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (tx *DynamicFeeTx) XXX_Unmarshal(b []byte) error { + return tx.Unmarshal(b) } -func (m *DynamicFeeTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (tx *DynamicFeeTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DynamicFeeTx.Marshal(b, m, deterministic) + return xxx_messageInfo_DynamicFeeTx.Marshal(b, tx, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + n, err := tx.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (m *DynamicFeeTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_DynamicFeeTx.Merge(m, src) +func (tx *DynamicFeeTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_DynamicFeeTx.Merge(tx, src) } -func (m *DynamicFeeTx) XXX_Size() int { - return m.Size() +func (tx *DynamicFeeTx) XXX_Size() int { + return tx.Size() } -func (m *DynamicFeeTx) XXX_DiscardUnknown() { - xxx_messageInfo_DynamicFeeTx.DiscardUnknown(m) +func (tx *DynamicFeeTx) XXX_DiscardUnknown() { + xxx_messageInfo_DynamicFeeTx.DiscardUnknown(tx) } var xxx_messageInfo_DynamicFeeTx proto.InternalMessageInfo @@ -645,49 +645,49 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "artela/evm/v1/txs.proto", } -func (m *MsgEthereumTx) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (msg *MsgEthereumTx) Marshal() (dAtA []byte, err error) { + size := msg.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := msg.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *MsgEthereumTx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (msg *MsgEthereumTx) MarshalTo(dAtA []byte) (int, error) { + size := msg.Size() + return msg.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (msg *MsgEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.From) > 0 { - i -= len(m.From) - copy(dAtA[i:], m.From) - i = encodeVarintTx(dAtA, i, uint64(len(m.From))) + if len(msg.From) > 0 { + i -= len(msg.From) + copy(dAtA[i:], msg.From) + i = encodeVarintTx(dAtA, i, uint64(len(msg.From))) i-- dAtA[i] = 0x22 } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) + if len(msg.Hash) > 0 { + i -= len(msg.Hash) + copy(dAtA[i:], msg.Hash) + i = encodeVarintTx(dAtA, i, uint64(len(msg.Hash))) i-- dAtA[i] = 0x1a } - if m.Size_ != 0 { + if msg.Size_ != 0 { i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Size_)))) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(msg.Size_)))) i-- dAtA[i] = 0x11 } - if m.Data != nil { + if msg.Data != nil { { - size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + size, err := msg.Data.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -700,59 +700,59 @@ func (m *MsgEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *LegacyTx) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (tx *LegacyTx) Marshal() (dAtA []byte, err error) { + size := tx.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := tx.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *LegacyTx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (tx *LegacyTx) MarshalTo(dAtA []byte) (int, error) { + size := tx.Size() + return tx.MarshalToSizedBuffer(dAtA[:size]) } -func (m *LegacyTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (tx *LegacyTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.S) > 0 { - i -= len(m.S) - copy(dAtA[i:], m.S) - i = encodeVarintTx(dAtA, i, uint64(len(m.S))) + if len(tx.S) > 0 { + i -= len(tx.S) + copy(dAtA[i:], tx.S) + i = encodeVarintTx(dAtA, i, uint64(len(tx.S))) i-- dAtA[i] = 0x4a } - if len(m.R) > 0 { - i -= len(m.R) - copy(dAtA[i:], m.R) - i = encodeVarintTx(dAtA, i, uint64(len(m.R))) + if len(tx.R) > 0 { + i -= len(tx.R) + copy(dAtA[i:], tx.R) + i = encodeVarintTx(dAtA, i, uint64(len(tx.R))) i-- dAtA[i] = 0x42 } - if len(m.V) > 0 { - i -= len(m.V) - copy(dAtA[i:], m.V) - i = encodeVarintTx(dAtA, i, uint64(len(m.V))) + if len(tx.V) > 0 { + i -= len(tx.V) + copy(dAtA[i:], tx.V) + i = encodeVarintTx(dAtA, i, uint64(len(tx.V))) i-- dAtA[i] = 0x3a } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + if len(tx.Data) > 0 { + i -= len(tx.Data) + copy(dAtA[i:], tx.Data) + i = encodeVarintTx(dAtA, i, uint64(len(tx.Data))) i-- dAtA[i] = 0x32 } - if m.Amount != nil { + if tx.Amount != nil { { - size := m.Amount.Size() + size := tx.Amount.Size() i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.Amount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -760,23 +760,23 @@ func (m *LegacyTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTx(dAtA, i, uint64(len(m.To))) + if len(tx.To) > 0 { + i -= len(tx.To) + copy(dAtA[i:], tx.To) + i = encodeVarintTx(dAtA, i, uint64(len(tx.To))) i-- dAtA[i] = 0x22 } - if m.GasLimit != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GasLimit)) + if tx.GasLimit != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.GasLimit)) i-- dAtA[i] = 0x18 } - if m.GasPrice != nil { + if tx.GasPrice != nil { { - size := m.GasPrice.Size() + size := tx.GasPrice.Size() i -= size - if _, err := m.GasPrice.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.GasPrice.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -784,59 +784,59 @@ func (m *LegacyTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.Nonce != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Nonce)) + if tx.Nonce != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.Nonce)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *AccessListTx) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (tx *AccessListTx) Marshal() (dAtA []byte, err error) { + size := tx.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := tx.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *AccessListTx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (tx *AccessListTx) MarshalTo(dAtA []byte) (int, error) { + size := tx.Size() + return tx.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (tx *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.S) > 0 { - i -= len(m.S) - copy(dAtA[i:], m.S) - i = encodeVarintTx(dAtA, i, uint64(len(m.S))) + if len(tx.S) > 0 { + i -= len(tx.S) + copy(dAtA[i:], tx.S) + i = encodeVarintTx(dAtA, i, uint64(len(tx.S))) i-- dAtA[i] = 0x5a } - if len(m.R) > 0 { - i -= len(m.R) - copy(dAtA[i:], m.R) - i = encodeVarintTx(dAtA, i, uint64(len(m.R))) + if len(tx.R) > 0 { + i -= len(tx.R) + copy(dAtA[i:], tx.R) + i = encodeVarintTx(dAtA, i, uint64(len(tx.R))) i-- dAtA[i] = 0x52 } - if len(m.V) > 0 { - i -= len(m.V) - copy(dAtA[i:], m.V) - i = encodeVarintTx(dAtA, i, uint64(len(m.V))) + if len(tx.V) > 0 { + i -= len(tx.V) + copy(dAtA[i:], tx.V) + i = encodeVarintTx(dAtA, i, uint64(len(tx.V))) i-- dAtA[i] = 0x4a } - if len(m.Accesses) > 0 { - for iNdEx := len(m.Accesses) - 1; iNdEx >= 0; iNdEx-- { + if len(tx.Accesses) > 0 { + for iNdEx := len(tx.Accesses) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := tx.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -847,18 +847,18 @@ func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x42 } } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + if len(tx.Data) > 0 { + i -= len(tx.Data) + copy(dAtA[i:], tx.Data) + i = encodeVarintTx(dAtA, i, uint64(len(tx.Data))) i-- dAtA[i] = 0x3a } - if m.Amount != nil { + if tx.Amount != nil { { - size := m.Amount.Size() + size := tx.Amount.Size() i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.Amount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -866,23 +866,23 @@ func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTx(dAtA, i, uint64(len(m.To))) + if len(tx.To) > 0 { + i -= len(tx.To) + copy(dAtA[i:], tx.To) + i = encodeVarintTx(dAtA, i, uint64(len(tx.To))) i-- dAtA[i] = 0x2a } - if m.GasLimit != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GasLimit)) + if tx.GasLimit != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.GasLimit)) i-- dAtA[i] = 0x20 } - if m.GasPrice != nil { + if tx.GasPrice != nil { { - size := m.GasPrice.Size() + size := tx.GasPrice.Size() i -= size - if _, err := m.GasPrice.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.GasPrice.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -890,16 +890,16 @@ func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.Nonce != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Nonce)) + if tx.Nonce != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.Nonce)) i-- dAtA[i] = 0x10 } - if m.ChainID != nil { + if tx.ChainID != nil { { - size := m.ChainID.Size() + size := tx.ChainID.Size() i -= size - if _, err := m.ChainID.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.ChainID.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -910,51 +910,51 @@ func (m *AccessListTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DynamicFeeTx) Marshal() (dAtA []byte, err error) { - size := m.Size() +func (tx *DynamicFeeTx) Marshal() (dAtA []byte, err error) { + size := tx.Size() dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + n, err := tx.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } -func (m *DynamicFeeTx) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (tx *DynamicFeeTx) MarshalTo(dAtA []byte) (int, error) { + size := tx.Size() + return tx.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (tx *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.S) > 0 { - i -= len(m.S) - copy(dAtA[i:], m.S) - i = encodeVarintTx(dAtA, i, uint64(len(m.S))) + if len(tx.S) > 0 { + i -= len(tx.S) + copy(dAtA[i:], tx.S) + i = encodeVarintTx(dAtA, i, uint64(len(tx.S))) i-- dAtA[i] = 0x62 } - if len(m.R) > 0 { - i -= len(m.R) - copy(dAtA[i:], m.R) - i = encodeVarintTx(dAtA, i, uint64(len(m.R))) + if len(tx.R) > 0 { + i -= len(tx.R) + copy(dAtA[i:], tx.R) + i = encodeVarintTx(dAtA, i, uint64(len(tx.R))) i-- dAtA[i] = 0x5a } - if len(m.V) > 0 { - i -= len(m.V) - copy(dAtA[i:], m.V) - i = encodeVarintTx(dAtA, i, uint64(len(m.V))) + if len(tx.V) > 0 { + i -= len(tx.V) + copy(dAtA[i:], tx.V) + i = encodeVarintTx(dAtA, i, uint64(len(tx.V))) i-- dAtA[i] = 0x52 } - if len(m.Accesses) > 0 { - for iNdEx := len(m.Accesses) - 1; iNdEx >= 0; iNdEx-- { + if len(tx.Accesses) > 0 { + for iNdEx := len(tx.Accesses) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := tx.Accesses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -965,18 +965,18 @@ func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x4a } } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + if len(tx.Data) > 0 { + i -= len(tx.Data) + copy(dAtA[i:], tx.Data) + i = encodeVarintTx(dAtA, i, uint64(len(tx.Data))) i-- dAtA[i] = 0x42 } - if m.Amount != nil { + if tx.Amount != nil { { - size := m.Amount.Size() + size := tx.Amount.Size() i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.Amount.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -984,23 +984,23 @@ func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTx(dAtA, i, uint64(len(m.To))) + if len(tx.To) > 0 { + i -= len(tx.To) + copy(dAtA[i:], tx.To) + i = encodeVarintTx(dAtA, i, uint64(len(tx.To))) i-- dAtA[i] = 0x32 } - if m.GasLimit != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GasLimit)) + if tx.GasLimit != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.GasLimit)) i-- dAtA[i] = 0x28 } - if m.GasFeeCap != nil { + if tx.GasFeeCap != nil { { - size := m.GasFeeCap.Size() + size := tx.GasFeeCap.Size() i -= size - if _, err := m.GasFeeCap.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.GasFeeCap.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1008,11 +1008,11 @@ func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.GasTipCap != nil { + if tx.GasTipCap != nil { { - size := m.GasTipCap.Size() + size := tx.GasTipCap.Size() i -= size - if _, err := m.GasTipCap.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.GasTipCap.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1020,16 +1020,16 @@ func (m *DynamicFeeTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.Nonce != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Nonce)) + if tx.Nonce != 0 { + i = encodeVarintTx(dAtA, i, uint64(tx.Nonce)) i-- dAtA[i] = 0x10 } - if m.ChainID != nil { + if tx.ChainID != nil { { - size := m.ChainID.Size() + size := tx.ChainID.Size() i -= size - if _, err := m.ChainID.MarshalTo(dAtA[i:]); err != nil { + if _, err := tx.ChainID.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -1205,177 +1205,177 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgEthereumTx) Size() (n int) { - if m == nil { +func (msg *MsgEthereumTx) Size() (n int) { + if msg == nil { return 0 } var l int _ = l - if m.Data != nil { - l = m.Data.Size() + if msg.Data != nil { + l = msg.Data.Size() n += 1 + l + sovTx(uint64(l)) } - if m.Size_ != 0 { + if msg.Size_ != 0 { n += 9 } - l = len(m.Hash) + l = len(msg.Hash) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.From) + l = len(msg.From) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *LegacyTx) Size() (n int) { - if m == nil { +func (tx *LegacyTx) Size() (n int) { + if tx == nil { return 0 } var l int _ = l - if m.Nonce != 0 { - n += 1 + sovTx(uint64(m.Nonce)) + if tx.Nonce != 0 { + n += 1 + sovTx(uint64(tx.Nonce)) } - if m.GasPrice != nil { - l = m.GasPrice.Size() + if tx.GasPrice != nil { + l = tx.GasPrice.Size() n += 1 + l + sovTx(uint64(l)) } - if m.GasLimit != 0 { - n += 1 + sovTx(uint64(m.GasLimit)) + if tx.GasLimit != 0 { + n += 1 + sovTx(uint64(tx.GasLimit)) } - l = len(m.To) + l = len(tx.To) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Amount != nil { - l = m.Amount.Size() + if tx.Amount != nil { + l = tx.Amount.Size() n += 1 + l + sovTx(uint64(l)) } - l = len(m.Data) + l = len(tx.Data) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.V) + l = len(tx.V) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.R) + l = len(tx.R) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.S) + l = len(tx.S) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *AccessListTx) Size() (n int) { - if m == nil { +func (tx *AccessListTx) Size() (n int) { + if tx == nil { return 0 } var l int _ = l - if m.ChainID != nil { - l = m.ChainID.Size() + if tx.ChainID != nil { + l = tx.ChainID.Size() n += 1 + l + sovTx(uint64(l)) } - if m.Nonce != 0 { - n += 1 + sovTx(uint64(m.Nonce)) + if tx.Nonce != 0 { + n += 1 + sovTx(uint64(tx.Nonce)) } - if m.GasPrice != nil { - l = m.GasPrice.Size() + if tx.GasPrice != nil { + l = tx.GasPrice.Size() n += 1 + l + sovTx(uint64(l)) } - if m.GasLimit != 0 { - n += 1 + sovTx(uint64(m.GasLimit)) + if tx.GasLimit != 0 { + n += 1 + sovTx(uint64(tx.GasLimit)) } - l = len(m.To) + l = len(tx.To) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Amount != nil { - l = m.Amount.Size() + if tx.Amount != nil { + l = tx.Amount.Size() n += 1 + l + sovTx(uint64(l)) } - l = len(m.Data) + l = len(tx.Data) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Accesses) > 0 { - for _, e := range m.Accesses { + if len(tx.Accesses) > 0 { + for _, e := range tx.Accesses { l = e.Size() n += 1 + l + sovTx(uint64(l)) } } - l = len(m.V) + l = len(tx.V) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.R) + l = len(tx.R) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.S) + l = len(tx.S) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *DynamicFeeTx) Size() (n int) { - if m == nil { +func (tx *DynamicFeeTx) Size() (n int) { + if tx == nil { return 0 } var l int _ = l - if m.ChainID != nil { - l = m.ChainID.Size() + if tx.ChainID != nil { + l = tx.ChainID.Size() n += 1 + l + sovTx(uint64(l)) } - if m.Nonce != 0 { - n += 1 + sovTx(uint64(m.Nonce)) + if tx.Nonce != 0 { + n += 1 + sovTx(uint64(tx.Nonce)) } - if m.GasTipCap != nil { - l = m.GasTipCap.Size() + if tx.GasTipCap != nil { + l = tx.GasTipCap.Size() n += 1 + l + sovTx(uint64(l)) } - if m.GasFeeCap != nil { - l = m.GasFeeCap.Size() + if tx.GasFeeCap != nil { + l = tx.GasFeeCap.Size() n += 1 + l + sovTx(uint64(l)) } - if m.GasLimit != 0 { - n += 1 + sovTx(uint64(m.GasLimit)) + if tx.GasLimit != 0 { + n += 1 + sovTx(uint64(tx.GasLimit)) } - l = len(m.To) + l = len(tx.To) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Amount != nil { - l = m.Amount.Size() + if tx.Amount != nil { + l = tx.Amount.Size() n += 1 + l + sovTx(uint64(l)) } - l = len(m.Data) + l = len(tx.Data) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Accesses) > 0 { - for _, e := range m.Accesses { + if len(tx.Accesses) > 0 { + for _, e := range tx.Accesses { l = e.Size() n += 1 + l + sovTx(uint64(l)) } } - l = len(m.V) + l = len(tx.V) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.R) + l = len(tx.R) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.S) + l = len(tx.S) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1454,7 +1454,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { +func (msg *MsgEthereumTx) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1512,10 +1512,10 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Data == nil { - m.Data = &types.Any{} + if msg.Data == nil { + msg.Data = &types.Any{} } - if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := msg.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1529,7 +1529,7 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { } v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 - m.Size_ = float64(math.Float64frombits(v)) + msg.Size_ = float64(math.Float64frombits(v)) case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) @@ -1560,7 +1560,7 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Hash = string(dAtA[iNdEx:postIndex]) + msg.Hash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -1592,7 +1592,7 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.From = string(dAtA[iNdEx:postIndex]) + msg.From = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1615,7 +1615,7 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { } return nil } -func (m *LegacyTx) Unmarshal(dAtA []byte) error { +func (tx *LegacyTx) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1648,7 +1648,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) } - m.Nonce = 0 + tx.Nonce = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1658,7 +1658,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift + tx.Nonce |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1694,8 +1694,8 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.GasPrice = &v - if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.GasPrice = &v + if err := tx.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1703,7 +1703,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) } - m.GasLimit = 0 + tx.GasLimit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1713,7 +1713,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GasLimit |= uint64(b&0x7F) << shift + tx.GasLimit |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1748,7 +1748,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.To = string(dAtA[iNdEx:postIndex]) + tx.To = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -1781,8 +1781,8 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.Amount = &v - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.Amount = &v + if err := tx.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1815,9 +1815,9 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + tx.Data = append(tx.Data[:0], dAtA[iNdEx:postIndex]...) + if tx.Data == nil { + tx.Data = []byte{} } iNdEx = postIndex case 7: @@ -1849,9 +1849,9 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...) - if m.V == nil { - m.V = []byte{} + tx.V = append(tx.V[:0], dAtA[iNdEx:postIndex]...) + if tx.V == nil { + tx.V = []byte{} } iNdEx = postIndex case 8: @@ -1883,9 +1883,9 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...) - if m.R == nil { - m.R = []byte{} + tx.R = append(tx.R[:0], dAtA[iNdEx:postIndex]...) + if tx.R == nil { + tx.R = []byte{} } iNdEx = postIndex case 9: @@ -1917,9 +1917,9 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...) - if m.S == nil { - m.S = []byte{} + tx.S = append(tx.S[:0], dAtA[iNdEx:postIndex]...) + if tx.S == nil { + tx.S = []byte{} } iNdEx = postIndex default: @@ -1943,7 +1943,7 @@ func (m *LegacyTx) Unmarshal(dAtA []byte) error { } return nil } -func (m *AccessListTx) Unmarshal(dAtA []byte) error { +func (tx *AccessListTx) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2003,8 +2003,8 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.ChainID = &v - if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.ChainID = &v + if err := tx.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2012,7 +2012,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) } - m.Nonce = 0 + tx.Nonce = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2022,7 +2022,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift + tx.Nonce |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2058,8 +2058,8 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.GasPrice = &v - if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.GasPrice = &v + if err := tx.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2067,7 +2067,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) } - m.GasLimit = 0 + tx.GasLimit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2077,7 +2077,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GasLimit |= uint64(b&0x7F) << shift + tx.GasLimit |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2112,7 +2112,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.To = string(dAtA[iNdEx:postIndex]) + tx.To = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 6: if wireType != 2 { @@ -2145,8 +2145,8 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.Amount = &v - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.Amount = &v + if err := tx.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2179,9 +2179,9 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + tx.Data = append(tx.Data[:0], dAtA[iNdEx:postIndex]...) + if tx.Data == nil { + tx.Data = []byte{} } iNdEx = postIndex case 8: @@ -2213,8 +2213,8 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Accesses = append(m.Accesses, support.AccessTuple{}) - if err := m.Accesses[len(m.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.Accesses = append(tx.Accesses, support.AccessTuple{}) + if err := tx.Accesses[len(tx.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2247,9 +2247,9 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...) - if m.V == nil { - m.V = []byte{} + tx.V = append(tx.V[:0], dAtA[iNdEx:postIndex]...) + if tx.V == nil { + tx.V = []byte{} } iNdEx = postIndex case 10: @@ -2281,9 +2281,9 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...) - if m.R == nil { - m.R = []byte{} + tx.R = append(tx.R[:0], dAtA[iNdEx:postIndex]...) + if tx.R == nil { + tx.R = []byte{} } iNdEx = postIndex case 11: @@ -2315,9 +2315,9 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...) - if m.S == nil { - m.S = []byte{} + tx.S = append(tx.S[:0], dAtA[iNdEx:postIndex]...) + if tx.S == nil { + tx.S = []byte{} } iNdEx = postIndex default: @@ -2341,7 +2341,7 @@ func (m *AccessListTx) Unmarshal(dAtA []byte) error { } return nil } -func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { +func (tx *DynamicFeeTx) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2401,8 +2401,8 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.ChainID = &v - if err := m.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.ChainID = &v + if err := tx.ChainID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2410,7 +2410,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) } - m.Nonce = 0 + tx.Nonce = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2420,7 +2420,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift + tx.Nonce |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2456,8 +2456,8 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.GasTipCap = &v - if err := m.GasTipCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.GasTipCap = &v + if err := tx.GasTipCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2492,8 +2492,8 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.GasFeeCap = &v - if err := m.GasFeeCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.GasFeeCap = &v + if err := tx.GasFeeCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2501,7 +2501,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) } - m.GasLimit = 0 + tx.GasLimit = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2511,7 +2511,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GasLimit |= uint64(b&0x7F) << shift + tx.GasLimit |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -2546,7 +2546,7 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.To = string(dAtA[iNdEx:postIndex]) + tx.To = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 7: if wireType != 2 { @@ -2579,8 +2579,8 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_cosmos_cosmos_sdk_types.Int - m.Amount = &v - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.Amount = &v + if err := tx.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2613,9 +2613,9 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + tx.Data = append(tx.Data[:0], dAtA[iNdEx:postIndex]...) + if tx.Data == nil { + tx.Data = []byte{} } iNdEx = postIndex case 9: @@ -2647,8 +2647,8 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Accesses = append(m.Accesses, support.AccessTuple{}) - if err := m.Accesses[len(m.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + tx.Accesses = append(tx.Accesses, support.AccessTuple{}) + if err := tx.Accesses[len(tx.Accesses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2681,9 +2681,9 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...) - if m.V == nil { - m.V = []byte{} + tx.V = append(tx.V[:0], dAtA[iNdEx:postIndex]...) + if tx.V == nil { + tx.V = []byte{} } iNdEx = postIndex case 11: @@ -2715,9 +2715,9 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...) - if m.R == nil { - m.R = []byte{} + tx.R = append(tx.R[:0], dAtA[iNdEx:postIndex]...) + if tx.R == nil { + tx.R = []byte{} } iNdEx = postIndex case 12: @@ -2749,9 +2749,9 @@ func (m *DynamicFeeTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...) - if m.S == nil { - m.S = []byte{} + tx.S = append(tx.S[:0], dAtA[iNdEx:postIndex]...) + if tx.S == nil { + tx.S = []byte{} } iNdEx = postIndex default: diff --git a/x/evm/txs/tx_access_list.go b/x/evm/txs/tx_access_list.go index e7442e25..7de5c74d 100644 --- a/x/evm/txs/tx_access_list.go +++ b/x/evm/txs/tx_access_list.go @@ -3,19 +3,16 @@ package txs import ( "math/big" - "github.com/artela-network/aspect-core/djpm" - - "github.com/artela-network/artela/ethereum/utils" - errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" + ethereum "github.com/ethereum/go-ethereum/core/types" artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/ethereum/utils" evmmodule "github.com/artela-network/artela/x/evm/types" - - sdkmath "cosmossdk.io/math" - "github.com/ethereum/go-ethereum/common" - ethereum "github.com/ethereum/go-ethereum/core/types" + "github.com/artela-network/aspect-core/djpm" ) func newAccessListTx(tx *ethereum.Transaction) (*AccessListTx, error) { diff --git a/x/evm/txs/tx_dynamic_fee.go b/x/evm/txs/tx_dynamic_fee.go index 2d4fa4dc..2063ab05 100644 --- a/x/evm/txs/tx_dynamic_fee.go +++ b/x/evm/txs/tx_dynamic_fee.go @@ -3,20 +3,16 @@ package txs import ( "math/big" - "github.com/artela-network/aspect-core/djpm" - - "github.com/artela-network/artela/ethereum/utils" - - sdkmath "cosmossdk.io/math" - - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/types" - errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" errortypes "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" + + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/ethereum/utils" + "github.com/artela-network/artela/x/evm/types" + "github.com/artela-network/aspect-core/djpm" ) func newDynamicFeeTx(tx *ethereum.Transaction) (*DynamicFeeTx, error) { diff --git a/x/evm/txs/tx_helper.go b/x/evm/txs/tx_helper.go index 605d9e5f..be9d86dd 100644 --- a/x/evm/txs/tx_helper.go +++ b/x/evm/txs/tx_helper.go @@ -5,15 +5,15 @@ import ( "fmt" "math/big" - "github.com/artela-network/artela-evm/vm" - sdkmath "cosmossdk.io/math" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core" ethereum "github.com/ethereum/go-ethereum/core/types" + + "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/aspect-core/djpm" ) var ( @@ -124,7 +124,7 @@ func (args *TransactionArgs) GetFrom() common.Address { return *args.From } -// GetData retrieves the transaction calldata. Input field is preferred. +// GetData retrieves the transaction data. Input field is preferred. func (args *TransactionArgs) GetData() []byte { if args.Input != nil { return *args.Input @@ -135,6 +135,28 @@ func (args *TransactionArgs) GetData() []byte { return nil } +// GetValidationData retrieves the validation data if the call is for a customized validation. +func (args *TransactionArgs) GetValidationData() []byte { + data := args.GetData() + validation, _, err := djpm.DecodeValidationAndCallData(data) + if err != nil { + // decode fail + return data + } + return validation +} + +// GetCallData retrieves the call data if the call is for a customized validation. +func (args *TransactionArgs) GetCallData() []byte { + data := args.GetData() + _, call, err := djpm.DecodeValidationAndCallData(data) + if err != nil { + // decode fail + return data + } + return call +} + // ToTransaction converts the arguments to an ethereum transaction. // This assumes that setTxDefaults has been called. func (args *TransactionArgs) ToTransaction() *MsgEthereumTx { @@ -296,7 +318,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (* if args.Value != nil { value = args.Value.ToInt() } - data := args.GetData() + data := args.GetCallData() var accessList ethereum.AccessList if args.AccessList != nil { accessList = *args.AccessList diff --git a/x/evm/txs/tx_legacy.go b/x/evm/txs/tx_legacy.go index ba34431f..19c9224f 100644 --- a/x/evm/txs/tx_legacy.go +++ b/x/evm/txs/tx_legacy.go @@ -1,16 +1,16 @@ package txs import ( - "github.com/artela-network/artela/ethereum/utils" - "github.com/artela-network/aspect-core/djpm" "math/big" - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/x/evm/types" - errorsmod "cosmossdk.io/errors" "github.com/ethereum/go-ethereum/common" ethereum "github.com/ethereum/go-ethereum/core/types" + + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/ethereum/utils" + "github.com/artela-network/artela/x/evm/types" + "github.com/artela-network/aspect-core/djpm" ) func newLegacyTx(tx *ethereum.Transaction) (*LegacyTx, error) { diff --git a/x/evm/txs/tx_utils.go b/x/evm/txs/tx_utils.go index 9f1224b5..ea895f65 100644 --- a/x/evm/txs/tx_utils.go +++ b/x/evm/txs/tx_utils.go @@ -4,22 +4,19 @@ import ( "fmt" "math/big" - "github.com/artela-network/artela/x/evm/txs/support" - //"github.com/artela-network/artela/x/evm/txs" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cosmos "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/gogoproto/proto" - - errorsmod "cosmossdk.io/errors" - cosmos "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" + + "github.com/artela-network/artela/x/evm/txs/support" ) const ( diff --git a/x/evm/txs/tx_wrapper.go b/x/evm/txs/tx_wrapper.go index ea066ac7..8ed96fc8 100644 --- a/x/evm/txs/tx_wrapper.go +++ b/x/evm/txs/tx_wrapper.go @@ -5,12 +5,6 @@ import ( "fmt" "math/big" - artela "github.com/artela-network/artela/ethereum/types" - "github.com/artela-network/artela/ethereum/utils" - - // rpctypes "github.com/artela-network/artela/ethereum/rpc/types" - "github.com/artela-network/artela/x/evm/types" - errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client" @@ -25,6 +19,10 @@ import ( cmath "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core" ethereum "github.com/ethereum/go-ethereum/core/types" + + artela "github.com/artela-network/artela/ethereum/types" + "github.com/artela-network/artela/ethereum/utils" + "github.com/artela-network/artela/x/evm/types" ) var ( @@ -326,15 +324,14 @@ func (msg *MsgEthereumTx) GetSender(chainID *big.Int) (from common.Address, err tx := msg.AsTransaction() // retrieve sender info from aspect if tx is not signed if utils.IsCustomizedVerification(tx) { - // TODO, more checkings, should never reach here return common.Address{}, errors.New("failed to get sender of customized tx") - } else { - signer := ethereum.LatestSignerForChainID(chainID) - from, err = signer.Sender(tx) - if err != nil { - return common.Address{}, err - } + } + + signer := ethereum.LatestSignerForChainID(chainID) + from, err = signer.Sender(tx) + if err != nil { + return common.Address{}, err } msg.From = from.Hex() diff --git a/x/evm/types/interfaces.go b/x/evm/types/interfaces.go index fb79bd85..7ad8f600 100644 --- a/x/evm/types/interfaces.go +++ b/x/evm/types/interfaces.go @@ -4,7 +4,6 @@ import ( "math/big" cosmos "github.com/cosmos/cosmos-sdk/types" - authmodule "github.com/cosmos/cosmos-sdk/x/auth/types" paramsmodule "github.com/cosmos/cosmos-sdk/x/params/types" stakingmodule "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/fee/blocker.go b/x/fee/blocker.go index db089c2c..847caad1 100644 --- a/x/fee/blocker.go +++ b/x/fee/blocker.go @@ -3,14 +3,13 @@ package fee import ( "fmt" - "github.com/artela-network/artela/x/fee/keeper" - - "github.com/artela-network/artela/x/fee/types" - abci "github.com/cometbft/cometbft/abci/types" - sdkmath "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" cosmos "github.com/cosmos/cosmos-sdk/types" + + "github.com/artela-network/artela/x/fee/keeper" + "github.com/artela-network/artela/x/fee/types" ) // BeginBlock updates base fee diff --git a/x/fee/client/cli/query.go b/x/fee/client/cli/query.go index 504fe079..b79d1944 100644 --- a/x/fee/client/cli/query.go +++ b/x/fee/client/cli/query.go @@ -35,7 +35,7 @@ func GetBlockGasCmd() *cobra.Command { Long: `Get the block gas used at a given block height. If the height is not provided, it will use the latest height from context`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -93,7 +93,7 @@ func GetBaseFeeCmd() *cobra.Command { Long: `Get the base fee amount at a given block height. If the height is not provided, it will use the latest height from context.`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/fee/genesis.go b/x/fee/genesis.go index ca439811..f3909d61 100644 --- a/x/fee/genesis.go +++ b/x/fee/genesis.go @@ -2,10 +2,10 @@ package fee import ( errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela/x/fee/keeper" abci "github.com/cometbft/cometbft/abci/types" cosmos "github.com/cosmos/cosmos-sdk/types" + "github.com/artela-network/artela/x/fee/keeper" "github.com/artela-network/artela/x/fee/types" ) diff --git a/x/fee/keeper/base_fee.go b/x/fee/keeper/base_fee.go index 0192e514..e12f7095 100644 --- a/x/fee/keeper/base_fee.go +++ b/x/fee/keeper/base_fee.go @@ -4,10 +4,11 @@ import ( "fmt" "math/big" - "github.com/artela-network/artela/x/fee/types" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + + "github.com/artela-network/artela/x/fee/types" ) // CalculateBaseFee calculates the base fee for the current block. This is only calculated once per diff --git a/x/fee/keeper/msg_server.go b/x/fee/keeper/msg_server.go index 190d28be..8b4ba9e9 100644 --- a/x/fee/keeper/msg_server.go +++ b/x/fee/keeper/msg_server.go @@ -4,9 +4,10 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/artela-network/artela/x/fee/types" cosmos "github.com/cosmos/cosmos-sdk/types" govmodule "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/artela-network/artela/x/fee/types" ) // UpdateParams implements the gRPC MsgServer interface. When an UpdateParams diff --git a/x/fee/module.go b/x/fee/module.go index c5fab5f1..7e6d4104 100644 --- a/x/fee/module.go +++ b/x/fee/module.go @@ -9,7 +9,6 @@ import ( "github.com/spf13/cobra" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -155,8 +154,7 @@ func (am AppModule) ExportGenesis(ctx cosmos.Context, cdc codec.JSONCodec) json. func (am AppModule) RegisterStoreDecoder(_ cosmos.StoreDecoderRegistry) {} // ProposalContents doesn't return any content functions for governance proposals. -// nolint -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { //nolint return nil }