Skip to content

Commit

Permalink
// params for expanse
Browse files Browse the repository at this point in the history
// params for expanse
  • Loading branch information
yuriy0803 committed Nov 28, 2023
1 parent 0dd343b commit 7977ba2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
56 changes: 39 additions & 17 deletions payouts/unlocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type UnlockerConfig struct {
Network string `json:"network"`
}

const minDepth = 16
const minDepth = 61

// params for canxium
const HydroForkBlock = 4204800
Expand Down Expand Up @@ -64,10 +64,9 @@ var ubiqStartReward = big.NewInt(8e+18)
var octaspaceStartReward = big.NewInt(650e+16)

// params for expanse
const byzantiumHardForkHeight = 800000

var homesteadExpanseReward = math.MustParseBig256("8000000000000000000")
var byzantiumExpanseReward = math.MustParseBig256("4000000000000000000")
var frontierBlockRewardExpanse = big.NewInt(8e+18)
var byzantiumBlockRewardExpanse = big.NewInt(4e+18)
var constantinopleBlockRewardExpanse = big.NewInt(4e+18)

// misc consts
var big32 = big.NewInt(32)
Expand Down Expand Up @@ -95,10 +94,16 @@ func NewBlockUnlocker(cfg *UnlockerConfig, backend *storage.RedisClient, network
case "mordor":
cfg.Ecip1017FBlock = 0
cfg.Ecip1017EraRounds = big.NewInt(2000000)
case "rebirth":
cfg.ByzantiumFBlock = big.NewInt(0)
cfg.ConstantinopleFBlock = big.NewInt(0)
case "expanse":
cfg.ByzantiumFBlock = big.NewInt(800000)
cfg.ConstantinopleFBlock = big.NewInt(1860000)
case "ethereum":
cfg.ByzantiumFBlock = big.NewInt(4370000)
cfg.ConstantinopleFBlock = big.NewInt(7280000)
case "ethereumPow", "expanse", "etica", "callisto", "ubiq", "octaspace", "universal", "canxium":
case "ethereumPow", "etica", "callisto", "ubiq", "octaspace", "universal", "canxium":
// Nothing needs configuring here, simply proceed.
case "ethereumFair":
cfg.ByzantiumFBlock = big.NewInt(4370000)
Expand Down Expand Up @@ -304,12 +309,18 @@ func (u *BlockUnlocker) handleBlock(block *rpc.GetBlockReply, candidate *storage
reward.Add(reward, rewardForUncles)

} else if u.config.Network == "expanse" {
reward = getConstRewardExpanse(candidate.Height)
reward = getConstRewardExpanse(candidate.Height, u.config)
// Add reward for including uncles
uncleReward := new(big.Int).Div(reward, big32)
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
reward.Add(reward, rewardForUncles)

} else if u.config.Network == "rebirth" {
reward = getConstRewardExpanse(candidate.Height, u.config)
// Add reward for including uncles
uncleReward := new(big.Int).Div(reward, big32)
rewardForUncles := big.NewInt(0).Mul(uncleReward, big.NewInt(int64(len(block.Uncles))))
reward.Add(reward, rewardForUncles)
} else if u.config.Network == "etica" {
reward = getConstRewardetica(candidate.Height)
// Add reward for including uncles
Expand Down Expand Up @@ -400,8 +411,8 @@ func handleUncle(height int64, uncle *rpc.GetBlockReply, candidate *storage.Bloc
reward = getUncleReward(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), era, getConstReward(era))
} else if cfg.Network == "ubiq" {
reward = getUncleRewardUbiq(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardUbiq(height))
} else if cfg.Network == "expanse" {
reward = getUncleRewardExpanse(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardExpanse(height))
} else if cfg.Network == "expanse" || cfg.Network == "rebirth" {
reward = getUncleRewardExpanse(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardExpanse(height, cfg))
} else if cfg.Network == "etica" {
reward = getUncleRewardEthereum(new(big.Int).SetInt64(uncleHeight), new(big.Int).SetInt64(height), getConstRewardetica(height))
} else if cfg.Network == "callisto" {
Expand Down Expand Up @@ -761,14 +772,6 @@ func getUncleReward(uHeight *big.Int, height *big.Int, era *big.Int, reward *big
return getRewardForUncle(reward)
}

// expanse
func getConstRewardExpanse(height int64) *big.Int {
if height >= byzantiumHardForkHeight {
return new(big.Int).Set(byzantiumExpanseReward)
}
return new(big.Int).Set(homesteadExpanseReward)
}

func getConstRewardEthereumpow(height int64) *big.Int {
// Rewards)
// EthereumPow
Expand Down Expand Up @@ -965,13 +968,32 @@ func getUncleRewardUniversal(uHeight *big.Int, height *big.Int, reward *big.Int)

}

// expanse
func getConstRewardExpanse(height int64, cfg *UnlockerConfig) *big.Int {
// Select the correct block reward based on chain progression
blockReward := frontierBlockRewardExpanse
headerNumber := big.NewInt(height)
if cfg.ByzantiumFBlock.Cmp(headerNumber) <= 0 {
blockReward = byzantiumBlockRewardExpanse
}
if cfg.ConstantinopleFBlock.Cmp(headerNumber) <= 0 {
blockReward = constantinopleBlockRewardExpanse
}
// Accumulate the rewards for the miner and any included uncles
reward := new(big.Int).Set(blockReward)
return reward
}

// expanse Uncle rw
func getUncleRewardExpanse(uHeight *big.Int, height *big.Int, reward *big.Int) *big.Int {
r := new(big.Int)
r.Add(uHeight, big8)
r.Sub(r, height)
r.Mul(r, reward)
r.Div(r, big8)
if r.Cmp(big.NewInt(0)) < 0 {
r = big.NewInt(0)
}

return r
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *ProxyServer) processShare(login, id, ip string, t *BlockTemplate, param

if hasher == nil {
switch s.config.Network {
case "expanse":
case "expanse", "rebirth":
hasher = etchash.New(nil, nil, &xip5Block) // expanse rebirth network
case "classic":
hasher = etchash.New(&ecip1099FBlockClassic, nil, nil) // classic mainnet
Expand Down

0 comments on commit 7977ba2

Please sign in to comment.