Skip to content

Commit

Permalink
Merge pull request #11 from onomyprotocol/onex-dev
Browse files Browse the repository at this point in the history
Onex 1.0.2
  • Loading branch information
AaronKutch authored Oct 6, 2023
2 parents fb54856 + 816cb56 commit c474c4a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 28 deletions.
27 changes: 17 additions & 10 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ import (
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
Expand Down Expand Up @@ -139,6 +142,8 @@ var (
mint.AppModuleBasic{},
ccvdistr.AppModuleBasic{},
gov.NewAppModuleBasic(
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
// TODO: eventually remove upgrade proposal handler and cancel proposal handler
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
),
Expand Down Expand Up @@ -391,13 +396,24 @@ func New(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks()),
)

app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
keys[ibchost.StoreKey],
app.GetSubspace(ibchost.ModuleName),
&app.ConsumerKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
)

// register the proposal types
ccvgovRouter := govtypes.NewRouter()
ccvgovRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
// TODO: remove upgrade handler from gov once admin module or decision for only signaling proposal is made.
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&ccvstakingKeeper, ccvgovRouter,
Expand All @@ -409,15 +425,6 @@ func New(
),
)

app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
keys[ibchost.StoreKey],
app.GetSubspace(ibchost.ModuleName),
&app.ConsumerKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
)

// Create CCV consumer and modules
app.ConsumerKeeper = consumerkeeper.NewKeeper(
appCodec,
Expand Down
8 changes: 1 addition & 7 deletions app/consumer-democracy/proposals_whitelisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
consumertypes "github.com/cosmos/interchain-security/x/ccv/consumer/types"
marketmoduletypes "github.com/pendulum-labs/market/x/market/types"
Expand All @@ -18,13 +17,8 @@ func IsProposalWhitelisted(content govtypes.Content) bool {
switch c := content.(type) {
case *proposal.ParameterChangeProposal:
return isParamChangeWhitelisted(c.Changes)
case *upgradetypes.SoftwareUpgradeProposal:
return true
case *upgradetypes.CancelSoftwareUpgradeProposal:
return true

default:
return false
return true
}
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
// NOTE: the canonical consumer version can be different from the producer, check the ICS repo
github.com/cosmos/interchain-security v1.2.0-multiden
github.com/gorilla/mux v1.8.0
github.com/pendulum-labs/market v0.1.4 // NOTE: change the version in the replace line
github.com/pendulum-labs/market v1.1.0 // NOTE: change the version in the replace line
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
github.com/stretchr/testify v1.8.3
Expand Down Expand Up @@ -155,7 +155,7 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
github.com/pendulum-labs/market => github.com/onomyprotocol/market v0.1.4
github.com/pendulum-labs/market => github.com/onomyprotocol/market v1.1.0
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2204,8 +2204,8 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onomyprotocol/market v0.1.4 h1:0pEauEsJ43XHt9fihvpvfEhrVwNhJKq2gePoBY7sn0Y=
github.com/onomyprotocol/market v0.1.4/go.mod h1:PWXq76Fbc9LbcNW4rEBfCQbns+4ZHnAmM0dOS4waiBM=
github.com/onomyprotocol/market v1.1.0 h1:erVL2LMdv8cRbrKeCyQfo7TAPdFuedpv1L7fBxR19sE=
github.com/onomyprotocol/market v1.1.0/go.mod h1:0AHp+qkE0BFNb0B+Y32Z9Zzbs5pRWctQ0QzbLrqTwiU=
github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
3 changes: 2 additions & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ path = "src/lib/common.rs"
clap = { version = "4", features = ["derive"] }
log = "0.4"
#onomy_test_lib = { path = "./../../onomy_tests/onomy_test_lib" }
onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "00194b44f4d1089fced454f9767f7f0872f55179" }
onomy_test_lib = { git = "https://github.com/pendulum-labs/onomy_tests", rev = "2895d3dedb66517ff7ce4dde2c162f0953c31561" }
serde_json = "1.0"
tokio = { version = "1", default-features = false }
32 changes: 26 additions & 6 deletions tests/src/bin/ics_with_onomyd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use onomy_test_lib::{
},
yaml_str_to_json_value, Args, ONOMY_IBC_NOM, TEST_AMOUNT, TIMEOUT,
};
use serde_json::json;
use tokio::time::sleep;

#[tokio::main]
Expand All @@ -48,7 +49,7 @@ async fn main() -> Result<()> {
_ => Err(Error::from(format!("entry_name \"{s}\" is not recognized"))),
}
} else {
sh(&format!("make build"), &[]).await.stack()?;
sh("make build", &[]).await.stack()?;
sh(
&format!(
"mv ./{} ./tests/dockerfiles/dockerfile_resources/{}",
Expand Down Expand Up @@ -418,15 +419,15 @@ async fn consumer(args: &Args) -> Result<()> {
info!("sending back to {}", test_addr);

// avoid conflict with hermes relayer
wait_for_num_blocks(4).await.stack()?;
wait_for_num_blocks(5).await.stack()?;

// send some IBC NOM back to origin chain using it as gas
ibc_pair
.a
.cosmovisor_ibc_transfer("validator", test_addr, "5000", ibc_nom)
.await
.stack()?;
wait_for_num_blocks(4).await.stack()?;
wait_for_num_blocks(5).await.stack()?;

// market module specific sanity checks (need to check all tx commands
// specifically to make sure permissions are correct)
Expand Down Expand Up @@ -514,13 +515,32 @@ async fn consumer(args: &Args) -> Result<()> {
// termination signal
nm_onomyd.recv::<()>().await.stack()?;

wait_for_num_blocks(1).await.stack()?;

// test a simple text proposal
let test_deposit = token18(500.0, ONOMY_IBC_NOM);
let proposal = json!({
"title": "Text Proposal",
"description": "a text proposal",
"type": "Text",
"deposit": test_deposit
});
cosmovisor_gov_file_proposal(
daemon_home,
None,
&proposal.to_string(),
&format!("1{ibc_nom}"),
)
.await
.stack()?;
let proposals = sh_cosmovisor("query gov proposals", &[]).await.stack()?;
assert!(proposals.contains("PROPOSAL_STATUS_PASSED"));

// but first, test governance with IBC NOM as the token
let test_crisis_denom = ONOMY_IBC_NOM;
let test_deposit = token18(2000.0, ONOMY_IBC_NOM);
wait_for_num_blocks(1).await.stack()?;
cosmovisor_gov_file_proposal(
daemon_home,
"param-change",
Some("param-change"),
&format!(
r#"
{{
Expand Down

0 comments on commit c474c4a

Please sign in to comment.