Skip to content

Commit

Permalink
removed GenesisSupplyOffsets. It was inconsistent with upstream and t…
Browse files Browse the repository at this point in the history
…he interface expected by ibc-go
  • Loading branch information
nicolaslara committed Aug 4, 2022
1 parent 9b50abf commit 35ef510
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 439 deletions.
19 changes: 0 additions & 19 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
- [cosmos/bank/v1beta1/genesis.proto](#cosmos/bank/v1beta1/genesis.proto)
- [Balance](#cosmos.bank.v1beta1.Balance)
- [GenesisState](#cosmos.bank.v1beta1.GenesisState)
- [GenesisSupplyOffset](#cosmos.bank.v1beta1.GenesisSupplyOffset)

- [cosmos/bank/v1beta1/query.proto](#cosmos/bank/v1beta1/query.proto)
- [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest)
Expand Down Expand Up @@ -1704,24 +1703,6 @@ GenesisState defines the bank module's genesis state.
| `balances` | [Balance](#cosmos.bank.v1beta1.Balance) | repeated | balances is an array containing the balances of all the accounts. |
| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply represents the total supply. If it is left empty, then supply will be calculated based on the provided balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. |
| `denom_metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | denom_metadata defines the metadata of the differents coins. |
| `supply_offsets` | [GenesisSupplyOffset](#cosmos.bank.v1beta1.GenesisSupplyOffset) | repeated | supply_offsets defines the amount of supply offset. |






<a name="cosmos.bank.v1beta1.GenesisSupplyOffset"></a>

### GenesisSupplyOffset
GenesisSupplyOffset encodes the supply offsets, just for genesis.
The offsets are serialized directly by denom in state.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `denom` | [string](#string) | | Denom |
| `offset` | [string](#string) | | SupplyOffset |



Expand Down
69 changes: 1 addition & 68 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,74 +51,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
)

require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/lib/pq v1.10.4 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
nhooyr.io/websocket v1.8.6 // indirect
)
require github.com/onsi/ginkgo v1.16.4 // indirect

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
Expand Down
17 changes: 2 additions & 15 deletions proto/cosmos/bank/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ message GenesisState {
repeated Metadata denom_metadata = 4 [(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false];

// supply_offsets defines the amount of supply offset.
repeated GenesisSupplyOffset supply_offsets = 5
[(gogoproto.moretags) = "yaml:\"supply_offsets\"", (gogoproto.nullable) = false];
// repeated GenesisSupplyOffset supply_offsets = 5
// [(gogoproto.moretags) = "yaml:\"supply_offsets\"", (gogoproto.nullable) = false];
}

// Balance defines an account address and balance pair used in the bank module's
Expand All @@ -41,16 +41,3 @@ message Balance {
repeated cosmos.base.v1beta1.Coin coins = 2
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
}

// GenesisSupplyOffset encodes the supply offsets, just for genesis.
// The offsets are serialized directly by denom in state.
message GenesisSupplyOffset {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// Denom
string denom = 1;

// SupplyOffset
string offset = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
}
4 changes: 2 additions & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
})

// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.GenesisSupplyOffset{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down Expand Up @@ -180,7 +180,7 @@ func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...ba
totalSupply = totalSupply.Add(b.Coins...)
}

bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, []banktypes.GenesisSupplyOffset{})
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{})
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down
5 changes: 0 additions & 5 deletions x/bank/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) {
for _, meta := range genState.DenomMetadata {
k.SetDenomMetaData(ctx, meta)
}

for _, supplyOffset := range genState.SupplyOffsets {
k.setSupplyOffset(ctx, supplyOffset.Denom, supplyOffset.Offset)
}
}

// ExportGenesis returns the bank module's genesis state.
Expand All @@ -57,6 +53,5 @@ func (k BaseKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
k.GetAccountsBalances(ctx),
totalSupply,
k.GetAllDenomMetaData(ctx),
k.getGenesisSupplyOffsets(ctx),
)
}
19 changes: 0 additions & 19 deletions x/bank/keeper/supply_offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,3 @@ func (k BaseViewKeeper) IterateTotalSupplyWithOffsets(ctx sdk.Context, cb func(s
}
}
}

// getGenesisSupplyOffsets returns supply offset for genesis, encoded with denom in state
func (k BaseViewKeeper) getGenesisSupplyOffsets(ctx sdk.Context) []types.GenesisSupplyOffset {
store := ctx.KVStore(k.storeKey)
supplyStore := prefix.NewStore(store, types.SupplyKey)

iterator := supplyStore.Iterator(nil, nil)
defer iterator.Close()

supplyOffsets := []types.GenesisSupplyOffset{}
for ; iterator.Valid(); iterator.Next() {
supplyOffset := types.GenesisSupplyOffset{
Denom: string(iterator.Key()),
Offset: k.GetSupplyOffset(ctx, string(iterator.Key())),
}
supplyOffsets = append(supplyOffsets, supplyOffset)
}
return supplyOffsets
}
5 changes: 2 additions & 3 deletions x/bank/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@ func (gs GenesisState) Validate() error {

// NewGenesisState creates a new genesis state.
func NewGenesisState(params Params, balances []Balance, supply sdk.Coins,
denomMetaData []Metadata, supplyOffsets []GenesisSupplyOffset) *GenesisState {
denomMetaData []Metadata) *GenesisState {
return &GenesisState{
Params: params,
Balances: balances,
Supply: supply,
DenomMetadata: denomMetaData,
SupplyOffsets: supplyOffsets,
}
}

// DefaultGenesisState returns a default bank module genesis state.
func DefaultGenesisState() *GenesisState {
return NewGenesisState(DefaultParams(), []Balance{}, sdk.Coins{}, []Metadata{}, []GenesisSupplyOffset{})
return NewGenesisState(DefaultParams(), []Balance{}, sdk.Coins{}, []Metadata{})
}

// GetGenesisStateFromAppState returns x/bank GenesisState given raw application
Expand Down
Loading

0 comments on commit 35ef510

Please sign in to comment.