From ba7359e37d6dc233d8988701ab4204ccb0cbe027 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 20:28:30 +0100 Subject: [PATCH 01/12] Set MintTotalSupply --- node/mint.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 node/mint.go diff --git a/node/mint.go b/node/mint.go new file mode 100644 index 0000000..b4275a9 --- /dev/null +++ b/node/mint.go @@ -0,0 +1,43 @@ +package node + +// Special structure for the mint amount +type MintSupply struct { + Token string // token + Amount float64 // amount of token to mint +} + +var ( + MintTotalSupply = []MintSupply{ + {"PEG", 334509613}, + {"pUSD", 3184409}, + {"pKRW", 118}, + {"pXAU", 1}, + {"pXAG", 599}, + {"pXBT", 2}, + {"pETH", 5476}, + {"pLTC", 2004}, + {"pRVN", 13124813}, + {"pXBC", 243}, + {"pBNB", 3461}, + {"pXLM", 45892}, + {"pADA", 1414096}, + {"pXMR", 682}, + {"pDASH", 6001}, + {"pZEC", 2696}, + {"pEOS", 2059}, + {"pLINK", 9110}, + {"pATOM", 101}, + {"pNEO", 2}, + {"pCRO", 164}, + {"pETC", 5}, + {"pVET", 22400000}, + {"pHT", 5}, + {"pDCR", 1049}, + {"pAUD", 9}, + {"pNOK", 59}, + {"pXTZ", 11117}, + {"pDOGE", 9870}, + {"pALGO", 457602}, + {"pDGB", 51175}, + } +) From 569d27e76a6766ee9d49aee6eb780a0a62fd38fb Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 20:30:11 +0100 Subject: [PATCH 02/12] activation of PegNet 2.0.4 --- node/node.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/node.go b/node/node.go index d0ebf6c..22a56be 100644 --- a/node/node.go +++ b/node/node.go @@ -72,6 +72,10 @@ var ( // V202EnhanceActivation indicates the activation of PegNet 2.0.2. // Estimated to be Dec 3th 2020 V202EnhanceActivation uint32 = 274036 + + // V204EnhanceActivation indicates the activation of PegNet 2.0.4. + // Estimated to be Mar 15th 2021 + V204EnhanceActivation uint32 = 999999 ) func SetAllActivations(act uint32) { From 3f3d7aa272752dc1a6b9702313f3690c308184c2 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 20:34:22 +0100 Subject: [PATCH 03/12] MintTokensForBalance --- node/sync.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/node/sync.go b/node/sync.go index 2918338..a63b1e3 100644 --- a/node/sync.go +++ b/node/sync.go @@ -172,6 +172,12 @@ OuterSyncLoop: } } +func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height uint32) error { + fLog := log.WithFields(log.Fields{"height": height}) + + return nil +} + func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uint32) error { fLog := log.WithFields(log.Fields{"height": height}) @@ -215,7 +221,7 @@ func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uin }).Info("zeroing burn | balances retrieval failed") } - i := 0 // value to keep witin 0-9 range for mock tx + i := 0 // value to keep witin 0-9 range for mock tx j := 0 // value for uniqueness if height >= V202EnhanceActivation { j = 50 @@ -278,6 +284,12 @@ func (d *Pegnetd) SyncBlock(ctx context.Context, tx *sql.Tx, height uint32) erro return context.Canceled } + if height == V204EnhanceActivation { + if err := d.MintTokensForBalance(ctx, tx, d.Sync.Synced+1); err != nil { + return err + } + } + dblock := new(factom.DBlock) dblock.Height = height if err := dblock.Get(nil, d.FactomClient); err != nil { @@ -1404,4 +1416,4 @@ func (d *Pegnetd) GetAssetRatesV0(oprWinners []opr.AssetUint, sprWinners []opr.A return filteredRates, nil } return nil, fmt.Errorf("no winners") -} \ No newline at end of file +} From 22a2a9fe8189f2b2cb8fb64dde050f39aee2917a Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 20:59:07 +0100 Subject: [PATCH 04/12] MintTotalSupplyMap --- node/mint.go | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/node/mint.go b/node/mint.go index b4275a9..cee9025 100644 --- a/node/mint.go +++ b/node/mint.go @@ -1,43 +1,45 @@ package node +import "github.com/pegnet/pegnetd/fat/fat2" + // Special structure for the mint amount type MintSupply struct { - Token string // token - Amount float64 // amount of token to mint + Ticker fat2.PTicker // token + Amount uint64 // amount of token to mint } var ( - MintTotalSupply = []MintSupply{ - {"PEG", 334509613}, - {"pUSD", 3184409}, - {"pKRW", 118}, - {"pXAU", 1}, - {"pXAG", 599}, - {"pXBT", 2}, - {"pETH", 5476}, - {"pLTC", 2004}, - {"pRVN", 13124813}, - {"pXBC", 243}, - {"pBNB", 3461}, - {"pXLM", 45892}, - {"pADA", 1414096}, - {"pXMR", 682}, - {"pDASH", 6001}, - {"pZEC", 2696}, - {"pEOS", 2059}, - {"pLINK", 9110}, - {"pATOM", 101}, - {"pNEO", 2}, - {"pCRO", 164}, - {"pETC", 5}, - {"pVET", 22400000}, - {"pHT", 5}, - {"pDCR", 1049}, - {"pAUD", 9}, - {"pNOK", 59}, - {"pXTZ", 11117}, - {"pDOGE", 9870}, - {"pALGO", 457602}, - {"pDGB", 51175}, + MintTotalSupplyMap = []MintSupply{ + {fat2.PTickerPEG, 334509613}, + {fat2.PTickerUSD, 3184409}, + {fat2.PTickerKRW, 118}, + {fat2.PTickerXAU, 1}, + {fat2.PTickerXAG, 599}, + {fat2.PTickerXBT, 2}, + {fat2.PTickerETH, 5476}, + {fat2.PTickerLTC, 2004}, + {fat2.PTickerRVN, 13124813}, + {fat2.PTickerXBC, 243}, + {fat2.PTickerBNB, 3461}, + {fat2.PTickerXLM, 45892}, + {fat2.PTickerADA, 1414096}, + {fat2.PTickerXMR, 682}, + {fat2.PTickerDASH, 6001}, + {fat2.PTickerZEC, 2696}, + {fat2.PTickerEOS, 2059}, + {fat2.PTickerLINK, 9110}, + {fat2.PTickerATOM, 101}, + {fat2.PTickerNEO, 2}, + {fat2.PTickerCRO, 164}, + {fat2.PTickerETC, 5}, + {fat2.PTickerVET, 22400000}, + {fat2.PTickerHT, 5}, + {fat2.PTickerDCR, 1049}, + {fat2.PTickerAUD, 9}, + {fat2.PTickerNOK, 59}, + {fat2.PTickerXTZ, 11117}, + {fat2.PTickerDOGE, 9870}, + {fat2.PTickerALGO, 457602}, + {fat2.PTickerDGB, 51175}, } ) From cd1efd4868faf9ce42abf7dfae7628aa0285943d Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:08:02 +0100 Subject: [PATCH 05/12] MintTokensForBalance --- node/burns.go | 2 ++ node/sync.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/node/burns.go b/node/burns.go index 3f9a5ee..2c2e541 100644 --- a/node/burns.go +++ b/node/burns.go @@ -13,6 +13,8 @@ var ( GlobalOldBurnAddress = "FA1y5ZGuHSLmf2TqNf6hVMkPiNGyQpQDTFJvDLRkKQaoPo4bmbgu" + GlobalMintAddress = "FA3j16WPCiqsAFHVZcEoL85Khh5RhPCNe6PWHBKgUxrx8MAnbNoy" + // BurnRCD is the rcd representation of the burn address BurnRCD = [32]byte{} ) diff --git a/node/sync.go b/node/sync.go index a63b1e3..e1ab1e9 100644 --- a/node/sync.go +++ b/node/sync.go @@ -175,6 +175,26 @@ OuterSyncLoop: func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height uint32) error { fLog := log.WithFields(log.Fields{"height": height}) + FAGlobalMintAddress, err := factom.NewFAAddress(GlobalMintAddress) + if err != nil { + log.WithFields(log.Fields{ + "error": err, + }).Info("error getting mint address") + return err + } + + for _, tokenSupply := range MintTotalSupplyMap { + _, err := d.Pegnet.AddToBalance(tx, &FAGlobalMintAddress, tokenSupply.Ticker, tokenSupply.Amount) + if err != nil { + fLog.WithFields(log.Fields{ + "token": tokenSupply.Ticker, + "amount": tokenSupply.Amount, + "error": err, + }).Info("error minting token is failed") + return err + } + } + return nil } From 7d600bc9aaf935219a8a1ea76a7297857d50e9bb Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:17:21 +0100 Subject: [PATCH 06/12] NullifyMintTokens --- node/node.go | 4 ++++ node/sync.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/node/node.go b/node/node.go index 22a56be..caf6a8b 100644 --- a/node/node.go +++ b/node/node.go @@ -76,6 +76,10 @@ var ( // V204EnhanceActivation indicates the activation of PegNet 2.0.4. // Estimated to be Mar 15th 2021 V204EnhanceActivation uint32 = 999999 + + // V204EnhanceActivation indicates the activation of PegNet 2.0.4. + // Estimated to be Mar 15th 2021 + V204BurnMintTokenActivation uint32 = 999999 ) func SetAllActivations(act uint32) { diff --git a/node/sync.go b/node/sync.go index e1ab1e9..12e1657 100644 --- a/node/sync.go +++ b/node/sync.go @@ -198,6 +198,41 @@ func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height u return nil } +func (d *Pegnetd) NullifyMintTokens(ctx context.Context, tx *sql.Tx, height uint32) error { + fLog := log.WithFields(log.Fields{"height": height}) + + FAGlobalMintAddress, err := factom.NewFAAddress(GlobalMintAddress) + if err != nil { + log.WithFields(log.Fields{ + "error": err, + }).Info("error getting mint address") + return err + } + + // Get all balances for the address + balances, err := d.Pegnet.SelectBalances(&FAGlobalMintAddress) + if err != nil { + fLog.WithFields(log.Fields{ + "err": err, + }).Info("zeroing burn | balances retrieval failed") + } + + for _, tokenSupply := range MintTotalSupplyMap { + // Substract from every issuance + ticker := tokenSupply.Ticker + value, _ := balances[ticker] + _, _, err := d.Pegnet.SubFromBalance(tx, &FAGlobalMintAddress, ticker, value) // lastInd, txErr, err + if err != nil { + fLog.WithFields(log.Fields{ + "ticker": ticker, + "balance": value, + }).Info("zeroing burn | substract from balance failed") + return err + } + } + return nil +} + func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uint32) error { fLog := log.WithFields(log.Fields{"height": height}) @@ -310,6 +345,12 @@ func (d *Pegnetd) SyncBlock(ctx context.Context, tx *sql.Tx, height uint32) erro } } + if height == V204BurnMintTokenActivation { + if err := d.NullifyMintTokens(ctx, tx, d.Sync.Synced+1); err != nil { + return err + } + } + dblock := new(factom.DBlock) dblock.Height = height if err := dblock.Get(nil, d.FactomClient); err != nil { From 9a12d744c1e77c9bb7787f8df62766f2cee39229 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:18:43 +0100 Subject: [PATCH 07/12] activation height --- node/node.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/node/node.go b/node/node.go index caf6a8b..ab8f792 100644 --- a/node/node.go +++ b/node/node.go @@ -97,6 +97,8 @@ func SetAllActivations(act uint32) { OneWaySmallAssetsConversions = act SprSignatureActivation = act V202EnhanceActivation = act + V204EnhanceActivation = act + V204BurnMintTokenActivation = act } type Pegnetd struct { From 7d881ddc88142f5923bb656348121332d14d4f7d Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:20:16 +0100 Subject: [PATCH 08/12] activation height --- node/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/sync.go b/node/sync.go index 12e1657..1ba472e 100644 --- a/node/sync.go +++ b/node/sync.go @@ -276,7 +276,7 @@ func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uin }).Info("zeroing burn | balances retrieval failed") } - i := 0 // value to keep witin 0-9 range for mock tx + i := 0 // value to keep witin 0-9 range for mock tx j := 0 // value for uniqueness if height >= V202EnhanceActivation { j = 50 From 0707fed24d737c174928b6abc94055ad4a1d85fd Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:21:16 +0100 Subject: [PATCH 09/12] tokenSupply Amount --- node/sync.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/sync.go b/node/sync.go index 1ba472e..5910ee2 100644 --- a/node/sync.go +++ b/node/sync.go @@ -184,7 +184,7 @@ func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height u } for _, tokenSupply := range MintTotalSupplyMap { - _, err := d.Pegnet.AddToBalance(tx, &FAGlobalMintAddress, tokenSupply.Ticker, tokenSupply.Amount) + _, err := d.Pegnet.AddToBalance(tx, &FAGlobalMintAddress, tokenSupply.Ticker, tokenSupply.Amount*1e8) if err != nil { fLog.WithFields(log.Fields{ "token": tokenSupply.Ticker, @@ -276,7 +276,7 @@ func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uin }).Info("zeroing burn | balances retrieval failed") } - i := 0 // value to keep witin 0-9 range for mock tx + i := 0 // value to keep witin 0-9 range for mock tx j := 0 // value for uniqueness if height >= V202EnhanceActivation { j = 50 From 13ab301e83e38d03fc746e12222817e3df52fb72 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:23:17 +0100 Subject: [PATCH 10/12] V204BurnMintTokenActivation --- node/node.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/node.go b/node/node.go index ab8f792..aeebef8 100644 --- a/node/node.go +++ b/node/node.go @@ -77,8 +77,8 @@ var ( // Estimated to be Mar 15th 2021 V204EnhanceActivation uint32 = 999999 - // V204EnhanceActivation indicates the activation of PegNet 2.0.4. - // Estimated to be Mar 15th 2021 + // V204EnhanceActivation indicates the activation that burns remaining airdrop amount. + // Estimated to be April 15th 2021 V204BurnMintTokenActivation uint32 = 999999 ) From 9f2842a30150af7beacd26c7b04640b21366ed08 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:50:26 +0100 Subject: [PATCH 11/12] Set real activation heights --- node/node.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/node.go b/node/node.go index aeebef8..2b4a786 100644 --- a/node/node.go +++ b/node/node.go @@ -74,12 +74,12 @@ var ( V202EnhanceActivation uint32 = 274036 // V204EnhanceActivation indicates the activation of PegNet 2.0.4. - // Estimated to be Mar 15th 2021 - V204EnhanceActivation uint32 = 999999 + // Estimated to be Mar 16th 2021 + V204EnhanceActivation uint32 = 288878 // V204EnhanceActivation indicates the activation that burns remaining airdrop amount. - // Estimated to be April 15th 2021 - V204BurnMintTokenActivation uint32 = 999999 + // Estimated to be April 16th 2021 + V204BurnMintTokenActivation uint32 = 294206 ) func SetAllActivations(act uint32) { From 094ee2d20302e4e3c8209d80785dd960b5c46443 Mon Sep 17 00:00:00 2001 From: dragonheaven Date: Wed, 10 Mar 2021 21:58:04 +0100 Subject: [PATCH 12/12] Set real activation heights --- node/node.go | 4 ++-- node/sync.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/node.go b/node/node.go index 2b4a786..2fd5706 100644 --- a/node/node.go +++ b/node/node.go @@ -79,7 +79,7 @@ var ( // V204EnhanceActivation indicates the activation that burns remaining airdrop amount. // Estimated to be April 16th 2021 - V204BurnMintTokenActivation uint32 = 294206 + V204BurnMintedTokenActivation uint32 = 294206 ) func SetAllActivations(act uint32) { @@ -98,7 +98,7 @@ func SetAllActivations(act uint32) { SprSignatureActivation = act V202EnhanceActivation = act V204EnhanceActivation = act - V204BurnMintTokenActivation = act + V204BurnMintedTokenActivation = act } type Pegnetd struct { diff --git a/node/sync.go b/node/sync.go index 5910ee2..e4844a0 100644 --- a/node/sync.go +++ b/node/sync.go @@ -198,7 +198,7 @@ func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height u return nil } -func (d *Pegnetd) NullifyMintTokens(ctx context.Context, tx *sql.Tx, height uint32) error { +func (d *Pegnetd) NullifyMintedTokens(ctx context.Context, tx *sql.Tx, height uint32) error { fLog := log.WithFields(log.Fields{"height": height}) FAGlobalMintAddress, err := factom.NewFAAddress(GlobalMintAddress) @@ -345,8 +345,8 @@ func (d *Pegnetd) SyncBlock(ctx context.Context, tx *sql.Tx, height uint32) erro } } - if height == V204BurnMintTokenActivation { - if err := d.NullifyMintTokens(ctx, tx, d.Sync.Synced+1); err != nil { + if height == V204BurnMintedTokenActivation { + if err := d.NullifyMintedTokens(ctx, tx, d.Sync.Synced+1); err != nil { return err } }