Skip to content

Commit

Permalink
Merge branch 'main' into feat/btc-fee-rate
Browse files Browse the repository at this point in the history
  • Loading branch information
secp256r1 authored Apr 8, 2024
2 parents bd37542 + 004f1e6 commit d660dd7
Show file tree
Hide file tree
Showing 67 changed files with 7,694 additions and 114 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog

## [Unreleased]

### API Breaking

### State Machine Breaking

### Features

### Bug Fixes

### Security

## 1.0.0

### Features

* (Lorenzo) [\#1](https://github.com/Lorenzo-Protocol/lorenzo/pull/1) Add btclightclient module from version v0.8.5 & v0.7.2 of third party
* (Lorenzo) [\#8](https://github.com/Lorenzo-Protocol/lorenzo/pull/8) support nonfee transaction
* (Lorenzo) [\#11](https://github.com/Lorenzo-Protocol/lorenzo/pull/11) set MsgInsertHeaders to be fee free
* (Lorenzo) [\#12](https://github.com/Lorenzo-Protocol/lorenzo/pull/12) add fee module
* (Lorenzo) [\#13](https://github.com/Lorenzo-Protocol/lorenzo/pull/13) added implementation for submitting bitcoin fee rate in module btclightclient

### Bug Fixes

* (Lorenzo) [\#5](https://github.com/Lorenzo-Protocol/lorenzo/pull/5) Fix btc lightclient
* (Lorenzo) [\#9](https://github.com/Lorenzo-Protocol/lorenzo/pull/9) Fix GetSigners method of MsgUpdateParams
* (Lorenzo) [\#14](https://github.com/Lorenzo-Protocol/lorenzo/pull/14) Fix btcstaking genesis init
2 changes: 2 additions & 0 deletions app/ante/ante_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

errorsmod "cosmossdk.io/errors"
bbn "github.com/Lorenzo-Protocol/lorenzo/types"
feekeeper "github.com/Lorenzo-Protocol/lorenzo/x/fee/keeper"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
)

Expand All @@ -24,6 +25,7 @@ type HandlerOptions struct {
MaxTxGasWanted uint64
ExtensionOptionChecker ante.ExtensionOptionChecker
BtcConfig bbn.BtcConfig
FeeKeeper *feekeeper.Keeper
}

func (options HandlerOptions) validate() error {
Expand Down
7 changes: 4 additions & 3 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package ante
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ethante "github.com/evmos/ethermint/app/ante"

vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"

feekeeper "github.com/Lorenzo-Protocol/lorenzo/x/fee/keeper"
)

func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
Expand Down Expand Up @@ -81,7 +82,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, ethante.DefaultSigVerificationGasConsumer),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, checkTxFee),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, feekeeper.TxFeeChecker(options.FeeKeeper)),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
Expand Down
132 changes: 69 additions & 63 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,76 @@ import (
"os"
"path/filepath"

"github.com/Lorenzo-Protocol/lorenzo/app/ante"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/x/crisis"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"

"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/upgrade"
"github.com/evmos/ethermint/server/flags"
"github.com/evmos/ethermint/x/evm/vm/geth"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

simappparams "cosmossdk.io/simapp/params"
"github.com/Lorenzo-Protocol/lorenzo/app/ante"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store/streaming"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"

"github.com/cosmos/cosmos-sdk/version"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/evmos/ethermint/ethereum/eip712"
"github.com/evmos/ethermint/server/flags"
ethermint "github.com/evmos/ethermint/types"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/evmos/ethermint/x/evm/vm/geth"
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"

simappparams "cosmossdk.io/simapp/params"
"github.com/cosmos/cosmos-sdk/client"

"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"

sdk "github.com/cosmos/cosmos-sdk/types"

appparams "github.com/Lorenzo-Protocol/lorenzo/app/params"

"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

lrztypes "github.com/Lorenzo-Protocol/lorenzo/types"
btclightclientkeeper "github.com/Lorenzo-Protocol/lorenzo/x/btclightclient/keeper"
btclightclienttypes "github.com/Lorenzo-Protocol/lorenzo/x/btclightclient/types"
btcstakingkeeper "github.com/Lorenzo-Protocol/lorenzo/x/btcstaking/keeper"
btcstakingtypes "github.com/Lorenzo-Protocol/lorenzo/x/btcstaking/types"

// ibc
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
Expand All @@ -111,7 +97,15 @@ import (

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
/* ------------------------------ ethermint imports ----------------------------- */)
/* ------------------------------ ethermint imports ----------------------------- */

appparams "github.com/Lorenzo-Protocol/lorenzo/app/params"
lrztypes "github.com/Lorenzo-Protocol/lorenzo/types"
btclightclientkeeper "github.com/Lorenzo-Protocol/lorenzo/x/btclightclient/keeper"
btclightclienttypes "github.com/Lorenzo-Protocol/lorenzo/x/btclightclient/types"
feekeeper "github.com/Lorenzo-Protocol/lorenzo/x/fee/keeper"
feetypes "github.com/Lorenzo-Protocol/lorenzo/x/fee/types"
)

var (
_ servertypes.Application = (*LorenzoApp)(nil)
Expand Down Expand Up @@ -163,6 +157,9 @@ type LorenzoApp struct {
ConsensusParamsKeeper consensuskeeper.Keeper

BTCLightClientKeeper btclightclientkeeper.Keeper
FeeKeeper *feekeeper.Keeper

BTCStakingKeeper btcstakingkeeper.Keeper

// Ethermint keepers
EvmKeeper *evmkeeper.Keeper
Expand Down Expand Up @@ -193,7 +190,6 @@ func NewLorenzoApp(
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *LorenzoApp {

appCodec := encodingConfig.Codec
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down Expand Up @@ -242,6 +238,8 @@ func NewLorenzoApp(
evmtypes.StoreKey,
feemarkettypes.StoreKey,
btclightclienttypes.StoreKey,
feetypes.StoreKey,
btcstakingtypes.StoreKey,
)

tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
Expand Down Expand Up @@ -452,6 +450,13 @@ func NewLorenzoApp(
btclightclienttypes.NewMultiBTCLightClientHooks(),
)

app.FeeKeeper = feekeeper.NewKeeper(
appCodec,
keys[feetypes.StoreKey],
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.BTCStakingKeeper = btcstakingkeeper.NewKeeper(appCodec, keys[btcstakingtypes.StoreKey], app.BTCLightClientKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String())

var transferStack ibcporttypes.IBCModule
transferStack = ibctransfer.NewIBCModule(app.TransferKeeper)

Expand All @@ -465,7 +470,7 @@ func NewLorenzoApp(

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.mm = module.NewManager(appModules(app, encodingConfig, skipGenesisInvariants)...)
Expand Down Expand Up @@ -513,8 +518,9 @@ func NewLorenzoApp(
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
MaxTxGasWanted: maxGasWanted,
ExtensionOptionChecker: nil, //uses default
ExtensionOptionChecker: nil, // uses default
BtcConfig: btcConfig,
FeeKeeper : app.FeeKeeper,
})
if err != nil {
panic(err)
Expand Down
20 changes: 17 additions & 3 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import (
appparams "github.com/Lorenzo-Protocol/lorenzo/app/params"
"github.com/Lorenzo-Protocol/lorenzo/x/btclightclient"
btclightclienttypes "github.com/Lorenzo-Protocol/lorenzo/x/btclightclient/types"
"github.com/Lorenzo-Protocol/lorenzo/x/btcstaking"
btcstakingtypes "github.com/Lorenzo-Protocol/lorenzo/x/btcstaking/types"
"github.com/Lorenzo-Protocol/lorenzo/x/fee"
feetypes "github.com/Lorenzo-Protocol/lorenzo/x/fee/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
Expand Down Expand Up @@ -102,6 +106,8 @@ var (
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
btclightclient.AppModuleBasic{},
fee.AppModuleBasic{},
btcstaking.AppModuleBasic{},
)
// module account permissions
maccPerms = map[string][]string{
Expand All @@ -114,7 +120,8 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// this line is used by starport scaffolding # stargate/app/maccPerms

evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
btcstakingtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}
)

Expand Down Expand Up @@ -194,6 +201,8 @@ func appModules(

app.transferModule,
btclightclient.NewAppModule(appCodec, app.BTCLightClientKeeper),
fee.NewAppModule(appCodec, app.FeeKeeper),
btcstaking.NewAppModule(appCodec, app.BTCStakingKeeper),

// this line is used by starport scaffolding # stargate/app/appModule

Expand Down Expand Up @@ -237,8 +246,9 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,
btclightclienttypes.ModuleName,
feetypes.ModuleName,
//self module

btcstakingtypes.ModuleName,
}
}

Expand Down Expand Up @@ -273,8 +283,9 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,
btclightclienttypes.ModuleName,
feetypes.ModuleName,
//self module

btcstakingtypes.ModuleName,
}
}

Expand All @@ -288,6 +299,8 @@ can do so safely.
*/
func orderInitBlockers() []string {
return []string{
feetypes.ModuleName,

capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand All @@ -312,6 +325,7 @@ func orderInitBlockers() []string {

//self module
btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,

// NOTE: crisis module must go at the end to check for invariants on each module
crisistypes.ModuleName,
Expand Down
Loading

0 comments on commit d660dd7

Please sign in to comment.