Skip to content

Commit

Permalink
Merge pull request #249 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.21.0
  • Loading branch information
danil-lashin authored May 11, 2019
2 parents bc23845 + e41b5dc commit 499f35b
Show file tree
Hide file tree
Showing 12 changed files with 37,038 additions and 218 deletions.
1,474 changes: 1,288 additions & 186 deletions cmd/make_genesis/data.csv

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions cmd/make_genesis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (
"encoding/csv"
"encoding/json"
"github.com/MinterTeam/go-amino"
"github.com/MinterTeam/minter-go-node/core/developers"
"github.com/MinterTeam/minter-go-node/core/dao"
"github.com/MinterTeam/minter-go-node/core/minter"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/MinterTeam/minter-go-node/helpers"
tmTypes "github.com/tendermint/tendermint/types"
"math"
"math/big"
"os"
"sort"
"strconv"
"time"
)

Expand Down Expand Up @@ -41,7 +43,7 @@ func main() {
reader.FieldsPerRecord = 5
rawCSVdata, err := reader.ReadAll()

p := big.NewFloat(0).SetInt(big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))
p := big.NewInt(0).Set(big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))

for _, line := range rawCSVdata {
role, address, balMain, balBonus, balAirdrop := line[0], line[1], line[2], line[3], line[4]
Expand All @@ -58,20 +60,20 @@ func main() {
airdropBalances[address] = big.NewInt(0)
}

balMainFloat, _ := big.NewFloat(0).SetString(balMain)
balMainInt, _ := big.NewFloat(0).Mul(balMainFloat, p).Int(nil)
balMainFloat, _ := strconv.ParseFloat(balMain, 64)
balMainInt := big.NewInt(0).Mul(big.NewInt(int64(math.Round(balMainFloat))), p)
if balMainInt.Cmp(helpers.BipToPip(big.NewInt(100000))) != -1 || role == "pool_admin" {
firstBalances[address].Add(firstBalances[address], balMainInt)
} else {
secondBalances[address].Add(secondBalances[address], balMainInt)
}

balBonusFloat, _ := big.NewFloat(0).SetString(balBonus)
balBonusInt, _ := big.NewFloat(0).Mul(balBonusFloat, p).Int(nil)
balBonusFloat, _ := strconv.ParseFloat(balBonus, 64)
balBonusInt := big.NewInt(0).Mul(big.NewInt(int64(math.Round(balBonusFloat))), p)
bonusBalances[address].Add(bonusBalances[address], balBonusInt)

balAirdropFloat, _ := big.NewFloat(0).SetString(balAirdrop)
balAirdropInt, _ := big.NewFloat(0).Mul(balAirdropFloat, p).Int(nil)
balAirdropFloat, _ := strconv.ParseFloat(balAirdrop, 64)
balAirdropInt := big.NewInt(0).Mul(big.NewInt(int64(math.Round(balAirdropFloat))), p)
airdropBalances[address].Add(airdropBalances[address], balAirdropInt)
}

Expand All @@ -83,7 +85,7 @@ func main() {
}

frozenFunds = append(frozenFunds, types.FrozenFund{
Height: 17280 * 1,
Height: 17280 * 8,
Address: types.HexToAddress(address),
CandidateKey: []byte{0},
Coin: types.GetBaseCoin(),
Expand All @@ -97,7 +99,7 @@ func main() {
}

frozenFunds = append(frozenFunds, types.FrozenFund{
Height: 17280 * 2,
Height: 17280 * 15,
Address: types.HexToAddress(address),
CandidateKey: []byte{0},
Coin: types.GetBaseCoin(),
Expand All @@ -111,7 +113,7 @@ func main() {
}

frozenFunds = append(frozenFunds, types.FrozenFund{
Height: 17280 * 3,
Height: 17280 * 29,
Address: types.HexToAddress(address),
CandidateKey: []byte{0},
Coin: types.GetBaseCoin(),
Expand Down Expand Up @@ -156,11 +158,11 @@ func main() {
}

appHash := [32]byte{}
networkId := "minter-test-network-39"
networkId := "minter-test-network-40"

// Compose Genesis
genesis := tmTypes.GenesisDoc{
GenesisTime: time.Date(2019, time.April, 22, 17, 0, 0, 0, time.UTC),
GenesisTime: time.Date(2019, time.May, 12, 11, 0, 0, 0, time.UTC),
ChainID: networkId,
ConsensusParams: &tmTypes.ConsensusParams{
Block: tmTypes.BlockParams{
Expand Down Expand Up @@ -192,7 +194,7 @@ func main() {
func makeValidatorsAndCandidates(pubkeys []string, stake *big.Int) ([]types.Validator, []types.Candidate) {
validators := make([]types.Validator, len(pubkeys))
candidates := make([]types.Candidate, len(pubkeys))
addr := developers.Address
addr := dao.Address

for i, val := range pubkeys {
pkey, err := base64.StdEncoding.DecodeString(val)
Expand Down Expand Up @@ -249,9 +251,8 @@ func makeBalances(balances map[string]*big.Int, balances2 map[string]*big.Int, b
totalBalances.Add(totalBalances, val)
}

totalBalances.Add(totalBalances, big.NewInt(4)) // first validators' stakes

balances[developers.Address.String()] = big.NewInt(0).Sub(helpers.BipToPip(big.NewInt(200000000)), totalBalances) // Developers account
totalBalances.Add(totalBalances, big.NewInt(4)) // first validators' stakes
balances[dao.Address.String()] = big.NewInt(0).Sub(helpers.BipToPip(big.NewInt(200000000)), totalBalances) // DAO account

var result []types.Account
for address, balance := range balances {
Expand Down
1 change: 1 addition & 0 deletions cmd/minter/cmd/a_cmd-packr.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (

var (
NetworkId string
DefaultNetworkId = "minter-test-network-39"
DefaultNetworkId = "minter-test-network-40"

defaultConfigFilePath = filepath.Join(defaultConfigDir, defaultConfigFileName)
defaultGenesisJSONPath = filepath.Join(defaultConfigDir, defaultGenesisJSONName)
Expand Down
2 changes: 1 addition & 1 deletion core/dao/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package dao
import "github.com/MinterTeam/minter-go-node/core/types"

var (
Address = types.HexToAddress("Mx444c4f1953ea170f74eabef4eee52ed8276a7d5e")
Address = types.HexToAddress("Mx18467bbb64a8edf890201d526c35957d82be3d95")
Commission = 10
)
2 changes: 1 addition & 1 deletion core/developers/developers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package developers
import "github.com/MinterTeam/minter-go-node/core/types"

var (
Address = types.HexToAddress("Mxee81347211c72524338f9680072af90744333146")
Address = types.HexToAddress("Mx04bea23efb744dc93b4fda4c20bf4a21c6e195f1")
Commission = 10
)
5 changes: 2 additions & 3 deletions core/state/state_frozen_fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ type FrozenFund struct {
}

type FrozenFunds struct {
BlockHeight uint64
List []FrozenFund
List []FrozenFund
}

func (f FrozenFunds) String() string {
return fmt.Sprintf("Frozen funds at block %d (%d items)", f.BlockHeight, len(f.List))
return fmt.Sprintf("Frozen funds (%d items)", len(f.List))
}

// newFrozenFund creates a state frozen fund.
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sort"
)

const UnbondPeriod = 720 // in mainnet will be 518400 (30 days)
const UnbondPeriod = 518400
const MaxDelegatorsPerCandidate = 1000

var (
Expand Down Expand Up @@ -1676,7 +1676,7 @@ func (s *StateDB) deleteCoin(symbol types.CoinSymbol) {
frozenFunds := s.GetStateFrozenFunds(binary.BigEndian.Uint64(key[1:]))
for _, ff := range frozenFunds.data.List {
if ff.Coin == symbol {
frozenFundsHeights = append(frozenFundsHeights, frozenFunds.data.BlockHeight)
frozenFundsHeights = append(frozenFundsHeights, frozenFunds.BlockHeight())
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func TestStateDB_Commit(t *testing.T) {
big.NewInt(2))

hash, version, err := state.Commit()

if err != nil {
t.Errorf("Error: %s", err.Error())
}
Expand All @@ -103,8 +102,7 @@ func TestStateDB_Commit(t *testing.T) {
t.Errorf("Version should be 1, got %d", version)
}

targetHash, _ := hex.DecodeString("890866e0a38f831ab825dedc0fa6996c0afe47c40ab184fbf88b2b156343970d")

targetHash, _ := hex.DecodeString("c5ffd98054e8ecb08c3f6b64f0c91dc629a664eca07b62782317d4760868f623")
if !bytes.Equal(hash, targetHash) {
t.Errorf("Hash should be %x, got %x", targetHash, hash)
}
Expand Down
2 changes: 1 addition & 1 deletion core/transaction/unbond.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"math/big"
)

const unbondPeriod = 720 // in mainnet will be 518400 (30 days)
const unbondPeriod = 518400

type UnbondData struct {
PubKey types.Pubkey `json:"pub_key"`
Expand Down
Loading

0 comments on commit 499f35b

Please sign in to comment.