Skip to content

Commit

Permalink
Staging/07-22 (#157)
Browse files Browse the repository at this point in the history
* fix(api): websocket bytes encode

* fix: fixed transaction & receipt retrieve issue for customized verification transactions when state pruned

* fix: gov minum deposite demon

* feat: added support for evm transient storage

* feat: convert hardfork block number to time

* fix: added journal entry for transient storage operation

* fix: add some comments

* fix: replace iavl & artela-cosmos-sdk with local repo (#119)

* feat: add gas measurement for aspect core contract

* fix: optimize logs

* fix: fix deploy aspect gas cost too high issue

* fix: fix deployment join point decode issue

* fix: optimized gas cost and fixed unbinding issue

* fix: jit call can be only triggered at pre-/post-contract call

* fix: replace aspect-core for new apis (#123)

* fix: add a debug tool converting cosmos tx to ethereum tx (#124)

* fix: call db compaction (#128)

* fix: fix trace api determinism issue (#135)

* feat: update bytecode validation method (#136)

* fix: fix code validation panic issue

* feat: change module validation method

* feat: load compressed bytecode with brotli (#137)

* fix: fix gas estimation inaccuracy (#140)

* fix: fix gas estimation in-accuracy issue

* fix: fix verifier tx estimation gas issue

* feat: add constructor (#141)

* merge: rebase main

* feat: add trace for aspect (#144)

* feat: init evm native tracers

* feat: added aspect call trace

* fix: trigger post tx execute when tx not reverted

* fix: fix execution context json marshal format issue

* add upgrade handler to v1 (#145)

* migrate evm from 6 to 7 (#147)

* fix: incorrect use of errorsmod (#148)

* add cache for aspect verifier (#149)

* fix: fix staging test issues (#150)

* fix: fix panic issue when query empty aspect bound contracts

* fix: fixed some corner cases in binding

* fix: fix change version fail

* fix: fixed some minor issues

* fix: fixed aspect core issues

* fix: change version to no-joinpoint aspect issue

* add upgrade handler to v.4.8-rc8 (#152)

* fix: handle error of json-rpc calls (#153)

* fix: lint issues (#154)

* fix: fix most of the linting issues

* fix: fix most of the linting issues

* fix: format imports (#155)

---------

Co-authored-by: Luke <[email protected]>

* feat: return aspect id in receipt (#156)

* chroe/bump: bump to v0.4.8-rc8

---------

Co-authored-by: zhanjun <[email protected]>
Co-authored-by: dumbeng <[email protected]>
Co-authored-by: Luke <[email protected]>
Co-authored-by: No-Brainer <[email protected]>
Co-authored-by: Gene <[email protected]>
  • Loading branch information
6 people authored Jul 25, 2024
1 parent 2857a2b commit 5d73109
Show file tree
Hide file tree
Showing 168 changed files with 3,384 additions and 2,847 deletions.
156 changes: 76 additions & 80 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
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)
3 changes: 2 additions & 1 deletion app/ante/cosmos/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion app/ante/cosmos/msg_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/ante/cosmos/sig_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down
15 changes: 6 additions & 9 deletions app/ante/decorator.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
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"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"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
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 6 additions & 4 deletions app/ante/evm/aspect_context.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 7 additions & 8 deletions app/ante/evm/basic_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions app/ante/evm/context_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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()
Expand Down
8 changes: 3 additions & 5 deletions app/ante/evm/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions app/ante/evm/gasprice_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 5d73109

Please sign in to comment.