Skip to content

Commit

Permalink
Regenerate json, fix bug for single payment on unlocking schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed Feb 4, 2025
1 parent 49317e0 commit ab7463f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
7 changes: 6 additions & 1 deletion cmd/genallocs/genesis_alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"

"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/log"
"github.com/dominant-strategies/go-quai/params"
orderedmap "github.com/wk8/go-ordered-map/v2"
"lukechampine.com/blake3"
Expand Down Expand Up @@ -186,6 +187,10 @@ func (account *GenesisAccount) calculateLockedBalances() {
// Calculate total added vs expected total. Add rounding balance to final unlock.
roundingDifference := new(big.Int).Sub(account.Vested, totalDistributed)
lastUnlockBlock := lastUnlockIndex * params.BlocksPerMonth
account.BalanceSchedule.Set(lastUnlockBlock, new(big.Int).Add(quaiPerUnlock, roundingDifference))
finalUnlockAmount, ok := account.BalanceSchedule.Get(lastUnlockBlock)
if !ok {
log.Global.WithField("lastUnlockBlock", lastUnlockBlock).Fatal("Issue generating balance schedule")
}
account.BalanceSchedule.Set(lastUnlockBlock, new(big.Int).Add(finalUnlockAmount, roundingDifference))
}
}
1 change: 1 addition & 0 deletions cmd/genallocs/genesis_alloc.json

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions cmd/genallocs/genesis_alloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ const (
},
{
"unlockSchedule": 2,
"address": "0x0000000000000000000000000000000000000001",
"address": "0x0000000000000000000000000000000000000002",
"award": 500000000000000000000000,
"vested": 500000000000000000000000
},
{
"unlockSchedule": 3,
"address": "0x0000000000000000000000000000000000000002",
"address": "0x0000000000000000000000000000000000000003",
"award": 7000000000000000000000000,
"vested": 7000000000000000000000000
},
{
"unlockSchedule": 3,
"address": "0x0000000000000000000000000000000000000003",
"award": 4000000000000000000000000,
"vested": 1000000000000000000000000
},
{
"unlockSchedule": 3,
"address": "0x0000000000000000000000000000000000000003",
Expand All @@ -42,7 +48,7 @@ const (
)

var (
expectedAllocs = [4]*GenesisAccount{
expectedAllocs = [5]*GenesisAccount{
{
UnlockSchedule: 1,
Address: common.HexToAddress("0x0000000000000000000000000000000000000001", common.Location{0, 0}),
Expand All @@ -53,20 +59,28 @@ var (

{
UnlockSchedule: 2,
Address: common.HexToAddress("0x0000000000000000000000000000000000000001", common.Location{0, 0}),
Address: common.HexToAddress("0x0000000000000000000000000000000000000002", common.Location{0, 0}),
Award: new(big.Int).Mul(big.NewInt(500000), common.Big10e18),
Vested: new(big.Int).Mul(big.NewInt(500000), common.Big10e18),
BalanceSchedule: &orderedmap.OrderedMap[uint64, *big.Int]{},
},

{
UnlockSchedule: 3,
Address: common.HexToAddress("0x0000000000000000000000000000000000000002", common.Location{0, 0}),
Address: common.HexToAddress("0x0000000000000000000000000000000000000003", common.Location{0, 0}),
Award: new(big.Int).Mul(big.NewInt(7000000), common.Big10e18),
Vested: new(big.Int).Mul(big.NewInt(7000000), common.Big10e18),
BalanceSchedule: &orderedmap.OrderedMap[uint64, *big.Int]{},
},

{
UnlockSchedule: 3,
Address: common.HexToAddress("0x0000000000000000000000000000000000000003", common.Location{0, 0}),
Award: new(big.Int).Mul(big.NewInt(4000000), common.Big10e18),
Vested: new(big.Int).Mul(big.NewInt(1000000), common.Big10e18),
BalanceSchedule: &orderedmap.OrderedMap[uint64, *big.Int]{},
},

{
UnlockSchedule: 3,
Address: common.HexToAddress("0x0000000000000000000000000000000000000003", common.Location{0, 0}),
Expand Down Expand Up @@ -151,7 +165,6 @@ func TestCalculatingGenallocs(t *testing.T) {
require.Equal(t, expectedAllocValues.numUnlocks, uint64(actualAlloc.BalanceSchedule.Len()))

totalAdded := new(big.Int)
// for blockNum, actualUnlock := range actualAlloc.BalanceSchedule.Oldest() {
for actualUnlock := actualAlloc.BalanceSchedule.Oldest(); actualUnlock != nil; actualUnlock = actualUnlock.Next() {
blockNum := actualUnlock.Key
// There should never be unlocks after month 0, before month 12.
Expand Down
1 change: 0 additions & 1 deletion cmd/genallocs/testnet_genesis_alloc.json

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ func SetQuaiConfig(stack *node.Node, cfg *quaiconfig.Config, slicesRunning []com

cfg.Genesis.AllocHash = params.AllocHash
if nodeLocation.Equal(common.Location{0, 0}) {
cfg.GenesisAllocs, err = genallocs.VerifyGenesisAllocs("cmd/genallocs/testnet_genesis_alloc.json", cfg.Genesis.AllocHash)
cfg.GenesisAllocs, err = genallocs.VerifyGenesisAllocs("cmd/genallocs/genesis_alloc.json", cfg.Genesis.AllocHash)
if err != nil {
log.Global.WithField("err", err).Fatal("Unable to allocate genesis accounts")
}
Expand Down
4 changes: 2 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// Genesis hashes to enforce below configs on.
var (
// Progpow GenesisHashes
ProgpowColosseumGenesisHash = common.HexToHash("0x69c4b9f74aa293e57255ec90e355aff1d0afdbf2db6b5c5ba19ebe4da5816231")
ProgpowColosseumGenesisHash = common.HexToHash("0xf3fdc676bfd5ef8081c36523cfa3b8ca6136ff1073ded0e0404895804662a075")
ProgpowGardenGenesisHash = common.HexToHash("0xe6d0f9327aae915db55ab0cf9da7841c64e4ae39baa251c17586d8d25b59afbc")
ProgpowOrchardGenesisHash = common.HexToHash("0x12c80fbe68b732139343da9d7a97d06862b29a962b8749f2b977b83364612c96")
ProgpowLighthouseGenesisHash = common.HexToHash("0xf86f23baa7818c62b0d4bd5f2100230eab65392e0b115b91f446b299fddf38d8")
Expand All @@ -39,7 +39,7 @@ var (
Blake3PowLighthouseGenesisHash = common.HexToHash("0x7006882c75e8f445b754947f623d619716bac1cf8ab24005e396369d0d0a65e3")
Blake3PowLocalGenesisHash = common.HexToHash("0x2facaeb87e9770b76880a2dcb2554013626aa937a2f089fa2c18bd55e7ba9354")

AllocHash = common.HexToHash("0xd0399928c3cd2bd693a2777e1bec663fc7356d931754aac69b8b5b765b85dd4f")
AllocHash = common.HexToHash("0x36706e3417a823ac87b9becfa5a5b0efce60928b5f60a32d5c112c89766ef1e6")
)

// Different Network names
Expand Down

0 comments on commit ab7463f

Please sign in to comment.