Skip to content

Commit

Permalink
Peggy types updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim committed Apr 19, 2021
1 parent 4508bd8 commit 04091ae
Show file tree
Hide file tree
Showing 12 changed files with 1,854 additions and 746 deletions.
5 changes: 3 additions & 2 deletions chain/peggy/types/attestation.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chain/peggy/types/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (p PeggyDenom) TokenContract() (common.Address, error) {

func NewPeggyDenom(tokenContract common.Address) PeggyDenom {
buf := make([]byte, 0, PeggyDenomLen)
buf = append(buf, (PeggyDenomPrefix + PeggyDenomSeparator)...)
buf = append(buf, PeggyDenomPrefix+PeggyDenomSeparator...)
buf = append(buf, tokenContract.Bytes()...)

return PeggyDenom(buf)
Expand Down
42 changes: 21 additions & 21 deletions chain/peggy/types/events.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package types

const (
EventTypeObservation = "observation"
EventTypeOutgoingBatch = "outgoing_batch"
EventTypeMultisigBootstrap = "multisig_bootstrap"
EventTypeMultisigUpdateRequest = "multisig_update_request"
EventTypeOutgoingBatchCanceled = "outgoing_batch_canceled"
EventTypeBridgeWithdrawalReceived = "withdrawal_received"
EventTypeBridgeDepositReceived = "deposit_received"
EventTypeObservation = "observation"
EventTypeOutgoingBatch = "outgoing_batch"

AttributeKeyAttestationID = "attestation_id"
AttributeKeyAttestationIDs = "attestation_ids"
AttributeKeyBatchConfirmKey = "batch_confirm_key"
AttributeKeyValsetConfirmKey = "valset_confirm_key"
AttributeKeyMultisigID = "multisig_id"
AttributeKeyOutgoingBatchID = "batch_id"
AttributeKeyOutgoingTXID = "outgoing_tx_id"
AttributeKeyAttestationType = "attestation_type"
AttributeKeyContract = "bridge_contract"
AttributeKeyNonce = "nonce"
AttributeKeyValsetNonce = "valset_nonce"
AttributeKeyBatchNonce = "batch_nonce"
AttributeKeyBridgeChainID = "bridge_chain_id"
AttributeKeySetOperatorAddr = "set_operator_address"
EventTypeMultisigUpdateRequest = "multisig_update_request"
EventTypeOutgoingBatchCanceled = "outgoing_batch_canceled"
EventTypeBridgeWithdrawalReceived = "withdrawal_received"
EventTypeBridgeDepositReceived = "deposit_received"
EventTypeBridgeWithdrawCanceled = "withdraw_canceled"

AttributeKeyAttestationID = "attestation_id"
AttributeKeyBatchConfirmKey = "batch_confirm_key"
AttributeKeyValsetConfirmKey = "valset_confirm_key"
AttributeKeyMultisigID = "multisig_id"
AttributeKeyOutgoingBatchID = "batch_id"
AttributeKeyOutgoingTXID = "outgoing_tx_id"
AttributeKeyAttestationType = "attestation_type"
AttributeKeyContract = "bridge_contract"
AttributeKeyNonce = "nonce"
AttributeKeyValsetNonce = "valset_nonce"
AttributeKeyBatchNonce = "batch_nonce"
AttributeKeyBridgeChainID = "bridge_chain_id"
AttributeKeySetOperatorAddr = "set_operator_address"
)
30 changes: 30 additions & 0 deletions chain/peggy/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ var (
// ParamsStoreKeyBridgeContractAddress stores the contract address
ParamsStoreKeyBridgeContractAddress = []byte("BridgeContractAddress")

// ParamsStoreKeyBridgeContractStartHeight stores the bridge contract deployed height
ParamsStoreKeyBridgeContractStartHeight = []byte("BridgeContractChainHeight")

// ParamsStoreKeyBridgeContractChainID stores the bridge chain id
ParamsStoreKeyBridgeContractChainID = []byte("BridgeChainID")

Expand Down Expand Up @@ -76,6 +79,9 @@ var (
// ParamStoreUnbondSlashingValsetsWindow stores unbond slashing valset window
ParamStoreUnbondSlashingValsetsWindow = []byte("UnbondSlashingValsetsWindow")

// ParamStoreClaimSlashingEnabled stores ClaimSlashing is enabled or not
ParamStoreClaimSlashingEnabled = []byte("ClaimSlashingEnabled")

// Ensure that params implements the proper interface
_ paramtypes.ParamSet = &Params{}
)
Expand Down Expand Up @@ -113,6 +119,7 @@ func DefaultParams() *Params {
SlashFractionConflictingClaim: sdk.NewDec(1).Quo(sdk.NewDec(1000)),
CosmosCoinDenom: "inj",
UnbondSlashingValsetsWindow: 10000,
ClaimSlashingEnabled: false,
}
}

Expand All @@ -127,6 +134,9 @@ func (p Params) ValidateBasic() error {
if err := validateBridgeContractAddress(p.BridgeEthereumAddress); err != nil {
return sdkerrors.Wrap(err, "bridge contract address")
}
if err := validateBridgeContractStartHeight(p.BridgeContractStartHeight); err != nil {
return sdkerrors.Wrap(err, "bridge contract start height")
}
if err := validateBridgeChainID(p.BridgeChainId); err != nil {
return sdkerrors.Wrap(err, "bridge chain id")
}
Expand Down Expand Up @@ -169,6 +179,9 @@ func (p Params) ValidateBasic() error {
if err := validateUnbondSlashingValsetsWindow(p.UnbondSlashingValsetsWindow); err != nil {
return sdkerrors.Wrap(err, "unbond Slashing valset window")
}
if err := validateClaimSlashingEnabled(p.ClaimSlashingEnabled); err != nil {
return sdkerrors.Wrap(err, "claim slashing enabled")
}

return nil
}
Expand Down Expand Up @@ -199,6 +212,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(ParamsStoreSlashFractionClaim, &p.SlashFractionClaim, validateSlashFractionClaim),
paramtypes.NewParamSetPair(ParamsStoreSlashFractionConflictingClaim, &p.SlashFractionConflictingClaim, validateSlashFractionConflictingClaim),
paramtypes.NewParamSetPair(ParamStoreUnbondSlashingValsetsWindow, &p.UnbondSlashingValsetsWindow, validateUnbondSlashingValsetsWindow),
paramtypes.NewParamSetPair(ParamStoreClaimSlashingEnabled, &p.ClaimSlashingEnabled, validateClaimSlashingEnabled),
paramtypes.NewParamSetPair(ParamsStoreKeyBridgeContractStartHeight, &p.BridgeContractStartHeight, validateBridgeContractStartHeight),
}
}

Expand Down Expand Up @@ -244,6 +259,13 @@ func validateBridgeChainID(i interface{}) error {
return nil
}

func validateBridgeContractStartHeight(i interface{}) error {
if _, ok := i.(uint64); !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return nil
}

func validateTargetBatchTimeout(i interface{}) error {
val, ok := i.(uint64)
if !ok {
Expand Down Expand Up @@ -386,3 +408,11 @@ func validateCosmosCoinErc20Contract(i interface{}) error {

return ValidateEthAddress(v)
}

func validateClaimSlashingEnabled(i interface{}) error {
_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return nil
}
Loading

0 comments on commit 04091ae

Please sign in to comment.