Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1087 from irisnet/develop
Browse files Browse the repository at this point in the history
R4R: prepare release v0.10.2
  • Loading branch information
weichang-x authored Sep 25, 2019
2 parents a2c129f + d40de8a commit 6652498
Show file tree
Hide file tree
Showing 74 changed files with 6,244 additions and 2,165 deletions.
2 changes: 1 addition & 1 deletion backend/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func init() {

func loadDefault() {
defaultConfig[EnvironmentDevelop] = map[string]string{
KeyDbAddr: "localhost:27217",
KeyDbAddr: "192.168.150.31:27017",
KeyDATABASE: "sync-iris",
KeyDbUser: "iris",
KeyDbPwd: "irispassword",
Expand Down
34 changes: 32 additions & 2 deletions backend/lcd/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
GovModuleMint = "mint"
GovModuleDistr = "distr"
GovModuleSlashing = "slashing"
GovModuleAsset = "asset"
//auth key
GovModuleAuthGasPriceThreshold string = "gas_price_threshold"
GovModuleAuthTxSize string = "tx_size"
Expand All @@ -39,13 +40,21 @@ const (
GovModuleSlashingSlashFractionDoubleSign = "slash_fraction_double_sign"
GovModuleSlashingSlashFractionDowntime = "slash_fraction_downtime"
GovModuleSlashingDowntimJailDuration = "downtime_jail_duration"

//asset key
GovModuleAssetAssetTaxRate = "asset_tax_rate"
GovModuleAssetIssueTokenBaseFee = "issue_token_base_fee"
GovModuleAssetMintTokenFeeRatio = "mint_token_fee_ratio"
GovModuleAssetCreateGatewayBaseFee = "create_gateway_base_fee"
GovModuleAssetGatewayAssetFeeRatio = "gateway_asset_fee_ratio"
)

var GovModuleList = []string{GovModuleAuth, GovModuleStake, GovModuleMint, GovModuleDistr, GovModuleSlashing}

type RangeDescription struct {
Range string
Description string
Range string
Description string
InitialValue string
}

func GetAuthKeyWithRangeMap() map[string]RangeDescription {
Expand Down Expand Up @@ -90,6 +99,16 @@ func GetSlashingKeyWithRangeMap() map[string]RangeDescription {
result[GovModuleSlashingDowntimJailDuration] = RangeDescription{Range: "0,604800000000000", Description: "Jail duration of Downtime"}
return result
}

func GetAssetKeyWithRangeMap() map[string]RangeDescription {
result := map[string]RangeDescription{}
result[GovModuleAssetAssetTaxRate] = RangeDescription{InitialValue: "0.4", Range: "0,1", Description: "Community Tax rate for issuing or minting assets"}
result[GovModuleAssetIssueTokenBaseFee] = RangeDescription{InitialValue: "60000", Range: "0,", Description: "Benchmark fees for issuing Fungible Token"}
result[GovModuleAssetMintTokenFeeRatio] = RangeDescription{InitialValue: "0.1", Range: "0,1", Description: "Fungible Token mint rate (relative to the issue fee)"}
result[GovModuleAssetCreateGatewayBaseFee] = RangeDescription{InitialValue: "120000", Range: "0,", Description: "Benchmark fees for creating Gateways"}
result[GovModuleAssetGatewayAssetFeeRatio] = RangeDescription{InitialValue: "0.1", Range: "0,1", Description: "Rate of issuing gateway tokens (relative to the issue fee of native tokens)"}
return result
}
func GetGovModuleParam(module string) ([]byte, error) {
url := fmt.Sprintf(UrlGovParam, conf.Get().Hub.LcdUrl, module)
return utils.Get(url)
Expand Down Expand Up @@ -129,6 +148,10 @@ func GetGovSlashingParam() (map[string]interface{}, error) {
return GetGovModuleParamMap(GovModuleSlashing)
}

func GetGovAssetParam() (map[string]interface{}, error) {
return GetGovModuleParamMap(GovModuleAsset)
}

func GetAllGovModuleParam() (map[string]interface{}, error) {

result := map[string]interface{}{}
Expand All @@ -153,6 +176,10 @@ func GetAllGovModuleParam() (map[string]interface{}, error) {
if err != nil {
return nil, err
}
assetMap, err := GetGovAssetParam()
if err != nil {
return nil, err
}

for k, v := range authMap {
result[k] = v
Expand All @@ -170,5 +197,8 @@ func GetAllGovModuleParam() (map[string]interface{}, error) {
for k, v := range slashingMap {
result[k] = v
}
for k, v := range assetMap {
result[k] = v
}
return result, nil
}
10 changes: 4 additions & 6 deletions backend/lcd/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func GetDelegationsByDelAddr(delAddr string) (delegations []DelegationVo) {
return
}


func GetDelegationsByValidatorAddr(valAddr string) (delegations []DelegationVo) {

url := fmt.Sprintf(UrlDelegationsByValidator, conf.Get().Hub.LcdUrl, valAddr)
Expand Down Expand Up @@ -116,23 +115,23 @@ func GetDistributionRewardsByValidatorAcc(validatorAcc string) (utils.CoinsAsStr
return rewards.Commission, nil
}

func GetJailedUntilAndMissedBlocksCountByConsensusPublicKey(publicKey string) (string, string, error) {
func GetJailedUntilAndMissedBlocksCountByConsensusPublicKey(publicKey string) (string, string, string, error) {

url := fmt.Sprintf(UrlValidatorsSigningInfoByConsensuPublicKey, conf.Get().Hub.LcdUrl, publicKey)
resAsBytes, err := utils.Get(url)
if err != nil {
logger.Error("get delegations by delegator adr from lcd error", logger.String("err", err.Error()), logger.String("URL", url))
return "", "", err
return "", "", "", err
}

var valSign ValidatorSigningInfo

err = json.Unmarshal(resAsBytes, &valSign)
if err != nil {
return "", "", err
return "", "", "", err
}

return valSign.JailedUntil, valSign.MissedBlocksCount, nil
return valSign.JailedUntil, valSign.MissedBlocksCount, valSign.StartHeight, nil
}

func GetRedelegationsByValidatorAddr(valAddr string) (redelegations []ReDelegations) {
Expand Down Expand Up @@ -165,7 +164,6 @@ func GetUnbondingDelegationsByValidatorAddr(valAddr string) (unbondingDelegation
return
}


func DelegationByValidator(address string) (result []DelegationVo) {
url := fmt.Sprintf(UrlDelegationByVal, conf.Get().Hub.LcdUrl, address)
resBytes, err := utils.Get(url)
Expand Down
76 changes: 56 additions & 20 deletions backend/lcd/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ var (
CriticalMinDeposit document.Coin
CriticalParticipation string
CriticalVeto string
CriticalPenalty string

ImportantThreshold string
ImportantMinDeposit document.Coin
ImportantParticipation string
ImportantVeto string
ImportantPenalty string

NormalThreshold string
NormalMinDeposit document.Coin
NormalParticipation string
NormalVeto string
NormalPenalty string
)

const (
Expand All @@ -36,73 +39,94 @@ const (
CriticalMinDepositKey = "critical_min_deposit"
CriticalParticipationKey = "critical_participation"
CriticalVetoKey = "critical_veto"
CriticalPenaltyKey = "critical_penalty"

ImportantThresholdKey = "important_threshold"
ImportantParticipationKey = "important_participation"
ImportantMinDepositKey = "important_min_deposit"
ImportantVetoKey = "important_veto"
ImportantPenaltyKey = "important_penalty"

NormalMinDepositKey = "normal_min_deposit"
NormalThresholdKey = "normal_threshold"
NormalParticipationKey = "normal_participation"
NormalVetoKey = "normal_veto"
NormalPenaltyKey = "normal_penalty"

Critical = "Critical"
Important = "Important"
Normal = "Normal"
// Critical:SoftwareUpgrade, SystemHalt
// Important:ParameterChange
// Normal:TxTaxUsage
ProposalTypeSoftwareUpgrade = "SoftwareUpgrade"
ProposalTypeSystemHalt = "SystemHalt"
ProposalTypeParameter = "Parameter"
ProposalTypeTxTaxUsage = "TxTaxUsage"
ProposalTypeSoftwareUpgrade = "SoftwareUpgrade"
ProposalTypeSystemHalt = "SystemHalt"
ProposalTypeParameter = "Parameter"
ProposalTypeTokenAddition = "TokenAddition"
ProposalTypeTxTaxUsage = "TxTaxUsage"
ProposalTypeCommunityTaxUsage = "CommunityTaxUsage"
ProposalTypePlainText = "PlainText"
)

func GetProposalLevelByType(proposalType string) (string, error) {
switch proposalType {
case ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt:
return Critical, nil
case ProposalTypeParameter:
case ProposalTypeParameter, ProposalTypeTokenAddition:
return Important, nil
case ProposalTypeTxTaxUsage:
case ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText:
return Normal, nil
default:
return "", errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTxTaxUsage, proposalType))
return "", errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTokenAddition, ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText, proposalType))
}
}

func GetProposalBurnPercentByResult(result string, isRejectVote bool) (float32, error) {
switch result {
case document.ProposalStatusPassed:
return 0.2, nil
case document.ProposalStatusRejected:
if isRejectVote {
return 1, nil
}
return 0.2, nil
default:
return 0, errors.New(fmt.Sprintf("expect proposal result status: %v %v ,but actual: %v",
document.ProposalStatusPassed, document.ProposalStatusRejected, result))
}
}

func GetMinDepositByProposalType(proposalType string) (document.Coin, error) {
switch proposalType {
case ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt:
return CriticalMinDeposit, nil
case ProposalTypeParameter:
case ProposalTypeParameter, ProposalTypeTokenAddition:
return ImportantMinDeposit, nil
case ProposalTypeTxTaxUsage:
case ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText:
return NormalMinDeposit, nil

default:
return document.Coin{}, errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTxTaxUsage, proposalType))
return document.Coin{}, errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTokenAddition, ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText, proposalType))
}

}

func GetPassVetoThresholdAndParticipationMinDeposit(proposalType string) (string, string, string, error) {
func GetPassVetoThresholdAndParticipationMinDeposit(proposalType string) (string, string, string, string, error) {

switch proposalType {
case ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt:
return CriticalThreshold, CriticalVeto, CriticalParticipation, nil
return CriticalThreshold, CriticalVeto, CriticalParticipation, CriticalPenalty, nil

case ProposalTypeParameter:
return ImportantThreshold, ImportantVeto, ImportantParticipation, nil
case ProposalTypeTxTaxUsage:
return NormalThreshold, NormalVeto, NormalParticipation, nil
case ProposalTypeParameter, ProposalTypeTokenAddition:
return ImportantThreshold, ImportantVeto, ImportantParticipation, ImportantPenalty, nil
case ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText:
return NormalThreshold, NormalVeto, NormalParticipation, NormalPenalty, nil

default:
return "", "", "", errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTxTaxUsage, proposalType))
return "", "", "", "", errors.New(fmt.Sprintf("expect proposal type: %v %v %v %v %v %v %v ,but actual: %v",
ProposalTypeSoftwareUpgrade, ProposalTypeSystemHalt, ProposalTypeParameter, ProposalTypeTokenAddition, ProposalTypeTxTaxUsage, ProposalTypeCommunityTaxUsage, ProposalTypePlainText, proposalType))
}
}

Expand Down Expand Up @@ -177,6 +201,18 @@ func init() {
NormalParticipation = v
}

if v, ok := govParamMap[CriticalPenaltyKey].(string); ok {
CriticalPenalty = v
}

if v, ok := govParamMap[ImportantPenaltyKey].(string); ok {
ImportantPenalty = v
}

if v, ok := govParamMap[NormalPenaltyKey].(string); ok {
NormalPenalty = v
}

}

func NodeInfo() (result NodeInfoVo, err error) {
Expand Down
18 changes: 9 additions & 9 deletions backend/orm/document/asset.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package document

import (
"github.com/irisnet/explorer/backend/logger"
"github.com/irisnet/explorer/backend/orm"
"gopkg.in/mgo.v2/bson"
"gopkg.in/mgo.v2/txn"
"github.com/irisnet/explorer/backend/logger"
)

const (
Expand All @@ -15,7 +15,7 @@ const (
FungibleFamily = "fungible"
)

type Asset struct {
type AssetToken struct {
ID bson.ObjectId `bson:"_id"`
TokenId string `bson:"token_id" json:"id"`
Family string `bson:"family" json:"family"`
Expand All @@ -33,8 +33,8 @@ type Asset struct {
Owner string `bson:"owner" json:"owner"`
}

func (_ Asset) GetAllAssets() ([]Asset, error) {
var assets []Asset
func (_ AssetToken) GetAllAssets() ([]AssetToken, error) {
var assets []AssetToken
var qeury = orm.NewQuery()
defer qeury.Release()
qeury.SetCollection(CollectionNmAsset).
Expand All @@ -44,8 +44,8 @@ func (_ Asset) GetAllAssets() ([]Asset, error) {
return assets, err
}

func (_ Asset) GetAssetTokens(source string) ([]Asset, error) {
var assets []Asset
func (_ AssetToken) GetAssetTokens(source string) ([]AssetToken, error) {
var assets []AssetToken
cond := bson.M{}
if source != "" {
cond[AssetFieldSource] = source
Expand All @@ -59,8 +59,8 @@ func (_ Asset) GetAssetTokens(source string) ([]Asset, error) {
return assets, nil
}

func (_ Asset) GetAssetTokenDetail(tokenid string) (Asset, error) {
var asset Asset
func (_ AssetToken) GetAssetTokenDetail(tokenid string) (AssetToken, error) {
var asset AssetToken
cond := bson.M{}
if tokenid != "" {
cond[AssetFieldTokenId] = tokenid
Expand All @@ -73,6 +73,6 @@ func (_ Asset) GetAssetTokenDetail(tokenid string) (Asset, error) {
return asset, nil
}

func (_ Asset) Batch(txs []txn.Op) error {
func (_ AssetToken) Batch(txs []txn.Op) error {
return orm.Batch(txs)
}
2 changes: 1 addition & 1 deletion backend/orm/document/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func TestAsset_GetAllAssets(t *testing.T) {
allAsset, err := document.Asset{}.GetAllAssets()
allAsset, err := document.AssetToken{}.GetAllAssets()
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit 6652498

Please sign in to comment.