-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix app hash mismatch for genesis block
- Loading branch information
1 parent
9a9d0d5
commit 4c17ae3
Showing
12 changed files
with
1,029 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax = "proto3"; | ||
|
||
package greenfield.payment.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "greenfield/payment/auto_settle_record.proto"; | ||
import "greenfield/payment/payment_account.proto"; | ||
import "greenfield/payment/payment_account_count.proto"; | ||
import "greenfield/payment/stream_record.proto"; | ||
import "greenfield/payment/v1/params.proto"; | ||
|
||
// this line is used by starport scaffolding # genesis/proto/import | ||
|
||
option go_package = "github.com/bnb-chain/greenfield/x/payment/types/v1"; | ||
|
||
// GenesisState defines the payment module's genesis state. | ||
message GenesisState { | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
repeated StreamRecord stream_record_list = 2 [(gogoproto.nullable) = false]; | ||
repeated PaymentAccountCount payment_account_count_list = 3 [(gogoproto.nullable) = false]; | ||
repeated PaymentAccount payment_account_list = 4 [(gogoproto.nullable) = false]; | ||
repeated AutoSettleRecord auto_settle_record_list = 5 [(gogoproto.nullable) = false]; | ||
// this line is used by starport scaffolding # genesis/proto/state | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
syntax = "proto3"; | ||
package greenfield.payment.v1; | ||
|
||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/bnb-chain/greenfield/x/payment/types/v1"; | ||
|
||
// Params defines the parameters for the module. | ||
message Params { | ||
VersionedParams versioned_params = 1 [(gogoproto.nullable) = false]; | ||
// The maximum number of payment accounts that can be created by one user | ||
uint64 payment_account_count_limit = 2 [(gogoproto.moretags) = "yaml:\"payment_account_count_limit\""]; | ||
// Time duration threshold of forced settlement. | ||
// If dynamic balance is less than NetOutFlowRate * forcedSettleTime, the account can be forced settled. | ||
uint64 forced_settle_time = 3 [(gogoproto.moretags) = "yaml:\"forced_settle_time\""]; | ||
// the maximum number of flows that will be auto forced settled in one block | ||
uint64 max_auto_settle_flow_count = 4 [(gogoproto.moretags) = "yaml:\"max_auto_settle_flow_count\""]; | ||
// the maximum number of flows that will be auto resumed in one block | ||
uint64 max_auto_resume_flow_count = 5 [(gogoproto.moretags) = "yaml:\"max_auto_resume_flow_count\""]; | ||
// The denom of fee charged in payment module | ||
string fee_denom = 6 [(gogoproto.moretags) = "yaml:\"fee_denom\""]; | ||
} | ||
|
||
// VersionedParams defines the parameters with multiple versions, each version is stored with different timestamp. | ||
message VersionedParams { | ||
// Time duration which the buffer balance need to be reserved for NetOutFlow e.g. 6 month | ||
uint64 reserve_time = 1 [(gogoproto.moretags) = "yaml:\"reserve_time\""]; | ||
// The tax rate to pay for validators in storage payment. The default value is 1%(0.01) | ||
string validator_tax_rate = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package v1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/bnb-chain/greenfield/x/payment/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// DefaultIndex is the default global index | ||
const DefaultIndex uint64 = 1 | ||
|
||
// DefaultGenesis returns the default genesis state | ||
func DefaultGenesis() *GenesisState { | ||
return &GenesisState{ | ||
StreamRecordList: []types.StreamRecord{}, | ||
PaymentAccountCountList: []types.PaymentAccountCount{}, | ||
PaymentAccountList: []types.PaymentAccount{}, | ||
AutoSettleRecordList: []types.AutoSettleRecord{}, | ||
// this line is used by starport scaffolding # genesis/types/default | ||
Params: DefaultParams(), | ||
} | ||
} | ||
|
||
// Validate performs basic genesis state validation returning an error upon any | ||
// failure. | ||
func (gs GenesisState) Validate() error { | ||
// Check for duplicated index in streamRecord | ||
streamRecordIndexMap := make(map[string]struct{}) | ||
|
||
for _, elem := range gs.StreamRecordList { | ||
index := string(types.StreamRecordKey(sdk.MustAccAddressFromHex(elem.Account))) | ||
if _, ok := streamRecordIndexMap[index]; ok { | ||
return fmt.Errorf("duplicated index for streamRecord") | ||
} | ||
streamRecordIndexMap[index] = struct{}{} | ||
} | ||
// Check for duplicated index in paymentAccountCount | ||
paymentAccountCountIndexMap := make(map[string]struct{}) | ||
|
||
for _, elem := range gs.PaymentAccountCountList { | ||
index := string(types.PaymentAccountCountKey(sdk.MustAccAddressFromHex(elem.Owner))) | ||
if _, ok := paymentAccountCountIndexMap[index]; ok { | ||
return fmt.Errorf("duplicated index for paymentAccountCount") | ||
} | ||
paymentAccountCountIndexMap[index] = struct{}{} | ||
} | ||
// Check for duplicated index in paymentAccount | ||
paymentAccountIndexMap := make(map[string]struct{}) | ||
|
||
for _, elem := range gs.PaymentAccountList { | ||
index := string(types.PaymentAccountKey(sdk.MustAccAddressFromHex(elem.Addr))) | ||
if _, ok := paymentAccountIndexMap[index]; ok { | ||
return fmt.Errorf("duplicated index for paymentAccount") | ||
} | ||
paymentAccountIndexMap[index] = struct{}{} | ||
} | ||
|
||
// Check for duplicated index in autoSettleRecord | ||
autoSettleRecordIndexMap := make(map[string]struct{}) | ||
|
||
for _, elem := range gs.AutoSettleRecordList { | ||
index := string(types.AutoSettleRecordKey(elem.Timestamp, sdk.MustAccAddressFromHex(elem.Addr))) | ||
if _, ok := autoSettleRecordIndexMap[index]; ok { | ||
return fmt.Errorf("duplicated index for autoSettleRecord") | ||
} | ||
autoSettleRecordIndexMap[index] = struct{}{} | ||
} | ||
// this line is used by starport scaffolding # genesis/types/validate | ||
|
||
return gs.Params.Validate() | ||
} |
Oops, something went wrong.