Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport scope/attributes, gov deposit, and java distribution changes #636

Merged
merged 3 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-and-publish-proto-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: Java Setup
uses: actions/setup-java@v2.5.0
with:
distribution: 'zulu'
java-version: 11
server-id: github

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Upgrade provenance to 0.45 cosmos sdk release [#607](https://github.com/provenance-io/provenance/issues/607)
* Upgrade wasmd to v0.22.0 Note: this removes dependency on provenance-io's wasmd fork [#479](https://github.com/provenance-io/provenance/issues/479)
* Add support for Scope mutation via wasm Smart Contracts [#531](https://github.com/provenance-io/provenance/issues/531)
* Increase governance deposit amount and add create proposal msg fee [#632](https://github.com/provenance-io/provenance/issues/632)
* Allow attributes to be associated with scopes [#631](https://github.com/provenance-io/provenance/issues/631)

### Improvements

Expand All @@ -72,6 +74,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Allow manager to adjust grants on finalized markers [#545](https://github.com/provenance-io/provenance/issues/545)
* Add migration to re-index the metadata indexes involving addresses [#541](https://github.com/provenance-io/provenance/issues/541)
* Add migration to delete empty sessions [#480](https://github.com/provenance-io/provenance/issues/480)
* Add Java distribution tag to workflow [#624](https://github.com/provenance-io/provenance/issues/624)

## [v1.7.6](https://github.com/provenance-io/provenance/releases/tag/v1.7.6) - 2021-12-15

Expand Down
23 changes: 17 additions & 6 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v2/modules/core/exported"
ibcctmtypes "github.com/cosmos/ibc-go/v2/modules/light-clients/07-tendermint/types"
Expand Down Expand Up @@ -47,6 +48,13 @@ var handlers = map[string]appUpgrade{
return false
})

// set governance deposit requirement to 50,000HASH
govParams := app.GovKeeper.GetDepositParams(ctx)
beforeDeposit := govParams.MinDeposit
govParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50_000_000_000_000)))
app.GovKeeper.SetDepositParams(ctx, govParams)
ctx.Logger().Info(fmt.Sprintf("Updated governance module minimum deposit from %s to %s", beforeDeposit, govParams.MinDeposit))

// set attribute param length to 1,000 from 10,000
attrParams := app.AttributeKeeper.GetParams(ctx)
beforeLength := attrParams.MaxValueLength
Expand All @@ -73,27 +81,30 @@ var handlers = map[string]appUpgrade{

// AddMsgBasedFees adds pio specific msg based fees for BindName, AddMarker, AddAttribute, WriteScope, P8EMemorializeContract requests for v1.8.0 upgrade
func AddMsgBasedFees(app *App, ctx sdk.Context) error {
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgBindNameRequest (1/5)")
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgBindNameRequest (1/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&nametypes.MsgBindNameRequest{}), sdk.NewCoin("nhash", sdk.NewInt(10_000_000_000)))); err != nil {
return err
}
ctx.Logger().Info("Adding a 100 hash (100,000,000,000 nhash) msg fee to MsgAddMarkerRequest (2/5)")
ctx.Logger().Info("Adding a 100 hash (100,000,000,000 nhash) msg fee to MsgAddMarkerRequest (2/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&markertypes.MsgAddMarkerRequest{}), sdk.NewCoin("nhash", sdk.NewInt(100_000_000_000)))); err != nil {
return err
}
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgAddAttributeRequest (3/5)")
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgAddAttributeRequest (3/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&attributetypes.MsgAddAttributeRequest{}), sdk.NewCoin("nhash", sdk.NewInt(10_000_000_000)))); err != nil {
return err
}
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgWriteScopeRequest (4/5)")
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgWriteScopeRequest (4/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&metadatatypes.MsgWriteScopeRequest{}), sdk.NewCoin("nhash", sdk.NewInt(10_000_000_000)))); err != nil {
return err
}
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgP8EMemorializeContractRequest (5/5)")
ctx.Logger().Info("Adding a 10 hash (10,000,000,000 nhash) msg fee to MsgP8EMemorializeContractRequest (5/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&metadatatypes.MsgP8EMemorializeContractRequest{}), sdk.NewCoin("nhash", sdk.NewInt(10_000_000_000)))); err != nil {
return err
}

ctx.Logger().Info("Adding a 100 hash (100,000,000,000 nhash) msg fee to MsgSubmitProposal (6/6)")
if err := app.MsgFeesKeeper.SetMsgFee(ctx, msgfeestypes.NewMsgFee(sdk.MsgTypeURL(&govtypes.MsgSubmitProposal{}), sdk.NewCoin("nhash", sdk.NewInt(100_000_000_000)))); err != nil {
return err
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/provenanced/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import (
)

func TestIAVLConfig(t *testing.T) {
require.Equal(t,getIAVLCacheSize(app.EmptyAppOptions{}),cast.ToInt(serverconfig.DefaultConfig().IAVLCacheSize))
require.Equal(t, getIAVLCacheSize(app.EmptyAppOptions{}), cast.ToInt(serverconfig.DefaultConfig().IAVLCacheSize))
}
3 changes: 0 additions & 3 deletions internal/antewrapper/msg_fees_decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/provenance-io/provenance/internal/antewrapper"
)



// checkTx true, high min gas price(high enough so that additional fee in same denom tips it over,
//and this is what sets it apart from MempoolDecorator which has already been run)
func (suite *AnteTestSuite) TestEnsureMempoolAndMsgFees() {
Expand Down Expand Up @@ -363,4 +361,3 @@ func setUpApp(suite *AnteTestSuite, checkTx bool, additionalFeeCoinDenom string,
antehandler := sdk.ChainAnteDecorators(mfd)
return err, antehandler
}

3 changes: 1 addition & 2 deletions internal/antewrapper/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,10 @@ func (suite *AnteTestSuite) CreateMsgFee(fee sdk.Coin, msgs ...sdk.Msg) error {

// NewTestGasLimit is a test fee gas limit.
// they keep changing this value and our tests break, hence moving it to test.
func (suite *AnteTestSuite)NewTestGasLimit() uint64 {
func (suite *AnteTestSuite) NewTestGasLimit() uint64 {
return 100000
}


func TestAnteTestSuite(t *testing.T) {
suite.Run(t, new(AnteTestSuite))
}
8 changes: 4 additions & 4 deletions x/attribute/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,26 @@ func (s *IntegrationTestSuite) SetupSuite() {
attributeData.Attributes = append(attributeData.Attributes,
attributetypes.NewAttribute(
"example.attribute",
s.account1Addr,
s.account1Str,
attributetypes.AttributeType_String,
[]byte("example attribute value string")))
attributeData.Attributes = append(attributeData.Attributes,
attributetypes.NewAttribute(
"example.attribute.count",
s.account1Addr,
s.account1Str,
attributetypes.AttributeType_Int,
[]byte("2")))
for i := 0; i < s.accAttrCount; i++ {
attributeData.Attributes = append(attributeData.Attributes,
attributetypes.NewAttribute(
fmt.Sprintf("example.attribute.%s", toWritten(i)),
s.account3Addr,
s.account3Str,
attributetypes.AttributeType_Int,
[]byte(fmt.Sprintf("%d", i))))
attributeData.Attributes = append(attributeData.Attributes,
attributetypes.NewAttribute(
"example.attribute.overload",
s.account4Addr,
s.account4Str,
attributetypes.AttributeType_String,
[]byte(toWritten(i))))
}
Expand Down
26 changes: 14 additions & 12 deletions x/attribute/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/provenance-io/provenance/x/attribute/types"
)

Expand Down Expand Up @@ -53,9 +51,11 @@ Refer to %s tx name bind --help for more information on how to do this.`, versio
}

name := args[0]
account, err := sdk.AccAddressFromBech32(args[1])
account := args[1]

err = types.ValidateAttributeAddress(account)
if err != nil {
return fmt.Errorf("account address must be a Bech32 string: %w", err)
return fmt.Errorf("invalid address: %w", err)
}
attributeType, err := types.AttributeTypeFromString(strings.TrimSpace(args[2]))
if err != nil {
Expand Down Expand Up @@ -98,9 +98,11 @@ func NewUpdateAccountAttributeCmd() *cobra.Command {
}

name := args[0]
account, err := sdk.AccAddressFromBech32(args[1])
account := args[1]

err = types.ValidateAttributeAddress(account)
if err != nil {
return fmt.Errorf("account address must be a Bech32 string: %w", err)
return fmt.Errorf("invalid account address: %w", err)
}
origAttributeType, err := types.AttributeTypeFromString(strings.TrimSpace(args[2]))
if err != nil {
Expand Down Expand Up @@ -166,9 +168,9 @@ func NewDeleteDistinctAccountAttributeCmd() *cobra.Command {
return err
}

account, err := sdk.AccAddressFromBech32(args[1])
err = types.ValidateAttributeAddress(args[1])
if err != nil {
return fmt.Errorf("account address must be a Bech32 string: %w", err)
return fmt.Errorf("invalid attribute address: %w", err)
}
attributeType, err := types.AttributeTypeFromString(strings.TrimSpace(args[2]))
if err != nil {
Expand All @@ -178,7 +180,7 @@ func NewDeleteDistinctAccountAttributeCmd() *cobra.Command {
if err != nil {
return fmt.Errorf("error encoding value %s to type %s : %v", deleteValue, attributeType.String(), err)
}
msg := types.NewMsgDeleteDistinctAttributeRequest(account, clientCtx.GetFromAddress(), args[0], deleteValue)
msg := types.NewMsgDeleteDistinctAttributeRequest(args[1], clientCtx.GetFromAddress(), args[0], deleteValue)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
Expand All @@ -202,12 +204,12 @@ func NewDeleteAccountAttributeCmd() *cobra.Command {
return err
}

account, err := sdk.AccAddressFromBech32(args[1])
err = types.ValidateAttributeAddress(args[1])
if err != nil {
return fmt.Errorf("account address must be a Bech32 string: %w", err)
return fmt.Errorf("invalid address: %w", err)
}
msg := types.NewMsgDeleteAttributeRequest(
account,
args[1],
clientCtx.GetFromAddress(),
args[0],
)
Expand Down
10 changes: 6 additions & 4 deletions x/attribute/client/rest/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type IntegrationTestSuite struct {

accountAddr sdk.AccAddress
accountKey *secp256r1.PrivKey
accountStr string
}

func (s *IntegrationTestSuite) SetupSuite() {
Expand All @@ -40,6 +41,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
addr, err := sdk.AccAddressFromHex(s.accountKey.PubKey().Address().String())
s.Require().NoError(err)
s.accountAddr = addr
s.accountStr = s.accountAddr.String()
s.T().Log("setting up integration test suite")

cfg := testutil.DefaultTestNetworkConfig()
Expand Down Expand Up @@ -74,7 +76,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
accountData.Attributes = append(accountData.Attributes,
attributetypes.NewAttribute(
"example.attribute",
s.accountAddr,
s.accountStr,
attributetypes.AttributeType_String,
[]byte("example attribute value string")))
accountData.Params.MaxValueLength = 32
Expand Down Expand Up @@ -131,7 +133,7 @@ func (s *IntegrationTestSuite) TestGRPCQueries() {
Account: s.accountAddr.String(),
Attributes: []attributetypes.Attribute{
attributetypes.NewAttribute("example.attribute",
s.accountAddr,
s.accountStr,
attributetypes.AttributeType_String,
[]byte("example attribute value string")),
},
Expand All @@ -148,7 +150,7 @@ func (s *IntegrationTestSuite) TestGRPCQueries() {
Account: s.accountAddr.String(),
Attributes: []attributetypes.Attribute{
attributetypes.NewAttribute("example.attribute",
s.accountAddr,
s.accountStr,
attributetypes.AttributeType_String,
[]byte("example attribute value string")),
},
Expand Down Expand Up @@ -177,7 +179,7 @@ func (s *IntegrationTestSuite) TestGRPCQueries() {
Account: s.accountAddr.String(),
Attributes: []attributetypes.Attribute{
attributetypes.NewAttribute("example.attribute",
s.accountAddr,
s.accountStr,
attributetypes.AttributeType_String,
[]byte("example attribute value string")),
},
Expand Down
14 changes: 2 additions & 12 deletions x/attribute/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ func NewAddAttributeRequestHandlerFn(clientCtx client.Context) http.HandlerFunc
if !req.BaseReq.ValidateBasic(w) {
return
}
account, err := sdk.AccAddressFromBech32(req.Account)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
owner, err := sdk.AccAddressFromBech32(req.BaseReq.From)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
Expand All @@ -70,7 +65,7 @@ func NewAddAttributeRequestHandlerFn(clientCtx client.Context) http.HandlerFunc
return
}
msg := types.NewMsgAddAttributeRequest(
account,
req.Account,
owner, // name must resolve to this address
req.Name,
at,
Expand Down Expand Up @@ -103,18 +98,13 @@ func NewDeleteAttributeHandlerFn(clientCtx client.Context) http.HandlerFunc {
if !req.BaseReq.ValidateBasic(w) {
return
}
account, err := sdk.AccAddressFromBech32(req.Account)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
owner, err := sdk.AccAddressFromBech32(req.BaseReq.From)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
msg := types.NewMsgDeleteAttributeRequest(
account,
req.Account,
owner, // name must resolve to this address
req.Name,
)
Expand Down
8 changes: 4 additions & 4 deletions x/attribute/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (s HandlerTestSuite) TestMsgAddAttributeRequest() {
cases := []CommonTest{
{
"should successfully add new attribute",
types.NewMsgAddAttributeRequest(s.user1Addr,
types.NewMsgAddAttributeRequest(s.user1,
s.user1Addr, "example.name", types.AttributeType_String, []byte("value")),
[]string{s.user1},
"",
Expand Down Expand Up @@ -133,7 +133,7 @@ func (s HandlerTestSuite) TestMsgUpdateAttributeRequest() {
{
"should successfully update attribute",
types.NewMsgUpdateAttributeRequest(
s.user1Addr,
s.user1,
s.user1Addr, "example.name",
[]byte("value"), []byte("1"),
types.AttributeType_String,
Expand Down Expand Up @@ -169,7 +169,7 @@ func (s HandlerTestSuite) TestMsgDistinctDeleteAttributeRequest() {
cases := []CommonTest{
{
"should successfully delete attribute with value",
types.NewMsgDeleteDistinctAttributeRequest(s.user1Addr, s.user1Addr, "example.name", []byte("value")),
types.NewMsgDeleteDistinctAttributeRequest(s.user1, s.user1Addr, "example.name", []byte("value")),
[]string{s.user1},
"",
types.NewEventDistinctAttributeDelete("example.name", string([]byte("value")), s.user1, s.user1),
Expand All @@ -193,7 +193,7 @@ func (s HandlerTestSuite) TestMsgDeleteAttributeRequest() {
cases := []CommonTest{
{
"should successfully add new attribute",
types.NewMsgDeleteAttributeRequest(s.user1Addr, s.user1Addr, "example.name"),
types.NewMsgDeleteAttributeRequest(s.user1, s.user1Addr, "example.name"),
[]string{s.user1},
"",
types.NewEventAttributeDelete("example.name", s.user1, s.user1),
Expand Down
Loading