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

Commit

Permalink
tweaks to lifeline
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Jan 17, 2022
1 parent 5915f77 commit d0a695f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions chain/claim_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func (c *ClaimTx) Execute(t *TransactionContext) error {
return nil
}

// [spaceUnits] requires the caller to pay more to get spaces of
// [spaceNameUnits] requires the caller to pay more to get spaces of
// a shorter length because they are more desirable. This creates a "lottery"
// mechanism where the people that spend the most mining power will win the
// space.
//
// [spaceUnits] should only be called on a space that is valid
func spaceUnits(g *Genesis, s string) uint64 {
// [spaceNameUnits] should only be called on a space that is valid
func spaceNameUnits(g *Genesis, s string) uint64 {
desirability := uint64(parser.MaxIdentifierSize - len(s))
if uint64(len(s)) > g.ClaimTier2Size {
return desirability * g.ClaimTier3Multiplier
Expand All @@ -81,7 +81,7 @@ func spaceUnits(g *Genesis, s string) uint64 {
}

func (c *ClaimTx) FeeUnits(g *Genesis) uint64 {
return c.LoadUnits(g) + spaceUnits(g, c.Space)
return c.LoadUnits(g) + spaceNameUnits(g, c.Space)
}

func (c *ClaimTx) LoadUnits(g *Genesis) uint64 {
Expand Down
9 changes: 4 additions & 5 deletions chain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Genesis struct {
ClaimTier1Multiplier uint64 `serialize:"true" json:"claimTier1Multiplier"`

// Lifeline Params
PrefixRenewalDiscount uint64 `serialize:"true" json:"prefixRenewalDiscount"`
SpaceRenewalDiscount uint64 `serialize:"true" json:"prefixRenewalDiscount"`

// Reward Params
ClaimReward uint64 `serialize:"true" json:"claimReward"`
Expand Down Expand Up @@ -91,11 +91,10 @@ func DefaultGenesis() *Genesis {
ClaimTier1Multiplier: 25,

// Lifeline Params
PrefixRenewalDiscount: 5,
SpaceRenewalDiscount: 10,

// Reward Params
ClaimReward: 60 * 60 * 24 * 15, // 15 Days
LifelineUnitReward: 60 * 60, // 1 Hours Per Fee Unit
ClaimReward: 60 * 60 * 24 * 30, // 30 Days

// Lottery Reward (80% of tx.FeeUnits() * block.Price)
LotteryRewardMultipler: 80,
Expand All @@ -105,7 +104,7 @@ func DefaultGenesis() *Genesis {
BlockTarget: 1, // 1 Block per Second
LookbackTarget: 1500 * 60, // 1500 Units Per Block (~768KB of SetTx)
MaxBlockSize: 2000, // 2000 Units (~1MB)
MinPrice: 1, // (50 for easiest claim)
MinPrice: 1,
}
}

Expand Down
7 changes: 4 additions & 3 deletions chain/lifeline_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ func (l *LifelineTx) Execute(t *TransactionContext) error {
}
// Lifeline spread across all units
lastExpiry := i.Expiry
i.Expiry += g.LifelineUnitReward * l.Units / i.Units
adjUnits := l.Units + 1
i.Expiry += (g.ClaimReward * adjUnits) / i.Units
return PutSpaceInfo(t.Database, []byte(l.Space), i, lastExpiry)
}

func (l *LifelineTx) FeeUnits(g *Genesis) uint64 {
// FeeUnits are discounted so that, all else equal, it is easier for an owner
// to retain their space than for another to claim it.
discountedPrefixUnits := spaceUnits(g, l.Space) / g.PrefixRenewalDiscount
dSpaceNameUnits := spaceNameUnits(g, l.Space) / g.SpaceRenewalDiscount

// The more desirable the space, the more it costs to maintain it.
//
// Note, this heavy base cost incentivizes users to send fewer transactions
// to extend their space's life instead of many small ones.
return l.LoadUnits(g) + discountedPrefixUnits + l.Units
return l.LoadUnits(g) + dSpaceNameUnits*l.Units
}

func (l *LifelineTx) Copy() UnsignedTransaction {
Expand Down

0 comments on commit d0a695f

Please sign in to comment.