Skip to content

Commit

Permalink
resolve conflicts with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
intosKai committed Dec 22, 2023
1 parent a0e3992 commit fbfc5e0
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 44 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func unlockAccounts(ctx *cli.Context, stack *node.Node) {
// If insecure account unlocking is not allowed if node's APIs are exposed to external.
// Print warning log to user and skip unlocking.
isDevMode := false
if ctx.GlobalIsSet(utils.NetworkIdFlag.Name) && ctx.GlobalUint64(utils.NetworkIdFlag.Name) == 1337 {
if ctx.IsSet(utils.NetworkIdFlag.Name) && ctx.Uint64(utils.NetworkIdFlag.Name) == 1337 {
isDevMode = true
}
if !stack.Config().InsecureUnlockAllowed && stack.Config().ExtRPCEnabled() && !isDevMode {
Expand Down
2 changes: 1 addition & 1 deletion consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ type PoSA interface {
VerifyVote(chain ChainHeaderReader, vote *types.VoteEnvelope) error
IsActiveValidatorAt(chain ChainHeaderReader, header *types.Header, checkVoteKeyFn func(bLSPublicKey *types.BLSPublicKey) bool) bool

BlockRewards(blockNumber *big.Int) *big.Int
BlockRewards(blockNumber *big.Int, isMerge bool, timestamp uint64) *big.Int
}
8 changes: 4 additions & 4 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,8 @@ func (p *Parlia) getCurrentValidators(blockHash common.Hash, blockNum *big.Int)
}
return valSet, voteAddrmap, nil
}
func (p *Parlia) BlockRewards(blockNumber *big.Int) *big.Int {
if rules := p.chainConfig.Rules(blockNumber); rules.HasBlockRewards {
func (p *Parlia) BlockRewards(blockNumber *big.Int, isMerge bool, timestamp uint64) *big.Int {
if rules := p.chainConfig.Rules(blockNumber, isMerge, timestamp); rules.HasBlockRewards {
blockRewards := p.chainConfig.Parlia.BlockRewards
if blockRewards != nil && blockRewards.Cmp(common.Big0) > 0 {
return blockRewards
Expand All @@ -1579,7 +1579,7 @@ func (p *Parlia) distributeIncoming(val common.Address, state *state.StateDB, he
state.SetBalance(consensus.SystemAddress, big.NewInt(0))
state.AddBalance(coinbase, balance)
rewards := big.NewInt(0).Abs(balance)
if rules := p.chainConfig.Rules(header.Number); rules.HasBlockRewards {
if rules := p.chainConfig.Rules(header.Number, false, header.Time); rules.HasBlockRewards {
blockRewards := p.chainConfig.Parlia.BlockRewards
// if we have enabled block rewards and rewards are greater than 0 then
if blockRewards != nil && blockRewards.Cmp(common.Big0) > 0 {
Expand All @@ -1592,7 +1592,7 @@ func (p *Parlia) distributeIncoming(val common.Address, state *state.StateDB, he
}
if balance.Cmp(common.Big0) > 0 {
doDistributeSysReward := !p.chainConfig.IsKepler(header.Number, header.Time) &&
state.GetBalance(common.HexToAddress(systemcontract.SystemRewardContract)).Cmp(maxSystemBalance) < 0
state.GetBalance(common.HexToAddress(systemcontract.SystemRewardContract)).Cmp(maxSystemBalance) < 0
if doDistributeSysReward {
var sysRewards = new(big.Int)
sysRewards = sysRewards.Rsh(balance, systemRewardPercent)
Expand Down
1 change: 0 additions & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package vm

import (
"errors"
"math/big"
"sync"
"sync/atomic"
Expand Down
2 changes: 1 addition & 1 deletion eth/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(context.Coinbase, balance)
}
blockRewards := posa.BlockRewards(block.Header().Number)
blockRewards := posa.BlockRewards(block.Header().Number, false, block.Time())
if blockRewards != nil {
statedb.AddBalance(context.Coinbase, blockRewards)
}
Expand Down
8 changes: 4 additions & 4 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(vmctx.Coinbase, balance)
}
blockRewards := posa.BlockRewards(block.Header().Number)
blockRewards := posa.BlockRewards(block.Header().Number, false, block.Time())
if blockRewards != nil {
statedb.AddBalance(vmctx.Coinbase, blockRewards)
}
Expand Down Expand Up @@ -709,7 +709,7 @@ txloop:
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(block.Header().Coinbase, balance)
}
blockRewards := posa.BlockRewards(block.Header().Number)
blockRewards := posa.BlockRewards(block.Header().Number, false, block.Time())
if blockRewards != nil {
statedb.AddBalance(block.Header().Coinbase, blockRewards)
}
Expand Down Expand Up @@ -830,7 +830,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(vmctx.Coinbase, balance)
}
blockRewards := posa.BlockRewards(block.Header().Number)
blockRewards := posa.BlockRewards(block.Header().Number, false, block.Time())
if blockRewards != nil {
statedb.AddBalance(vmctx.Coinbase, blockRewards)
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(vmctx.Coinbase, balance)
}
blockRewards := posa.BlockRewards(vmctx.BlockNumber)
blockRewards := posa.BlockRewards(vmctx.BlockNumber, vmctx.Random != nil, vmctx.Time)
if blockRewards != nil {
statedb.AddBalance(vmctx.Coinbase, blockRewards)
}
Expand Down
2 changes: 1 addition & 1 deletion genesis
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ func (s *BlockChainAPI) replay(ctx context.Context, block *types.Block, accounts
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
statedb.AddBalance(block.Header().Coinbase, balance)
}
blockRewards := posa.BlockRewards(block.Header().Number)
blockRewards := posa.BlockRewards(block.Header().Number, false, block.Time())
if blockRewards != nil {
statedb.AddBalance(context.Coinbase, blockRewards)
}
Expand Down
59 changes: 29 additions & 30 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ var (
DeployerProxyBlock: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
IsDevMode: true,
nil,
}

// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
Expand Down Expand Up @@ -266,20 +265,20 @@ type ChainConfig struct {
// even without having seen the TTD locally (safer long term).
TerminalTotalDifficultyPassed bool `json:"terminalTotalDifficultyPassed,omitempty"`

RamanujanBlock *big.Int `json:"ramanujanBlock,omitempty" toml:",omitempty"` // ramanujanBlock switch block (nil = no fork, 0 = already activated)
NielsBlock *big.Int `json:"nielsBlock,omitempty" toml:",omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty" toml:",omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
BrunoBlock *big.Int `json:"brunoBlock,omitempty" toml:",omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
RamanujanBlock *big.Int `json:"ramanujanBlock,omitempty" toml:",omitempty"` // ramanujanBlock switch block (nil = no fork, 0 = already activated)
NielsBlock *big.Int `json:"nielsBlock,omitempty" toml:",omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty" toml:",omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
BrunoBlock *big.Int `json:"brunoBlock,omitempty" toml:",omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
BlockRewardsBlock *big.Int `json:"blockRewardsBlock,omitempty" toml:",omitempty"`
EulerBlock *big.Int `json:"eulerBlock,omitempty" toml:",omitempty"` // eulerBlock switch block (nil = no fork, 0 = already activated)
GibbsBlock *big.Int `json:"gibbsBlock,omitempty" toml:",omitempty"` // gibbsBlock switch block (nil = no fork, 0 = already activated)
NanoBlock *big.Int `json:"nanoBlock,omitempty" toml:",omitempty"` // nanoBlock switch block (nil = no fork, 0 = already activated)
MoranBlock *big.Int `json:"moranBlock,omitempty" toml:",omitempty"` // moranBlock switch block (nil = no fork, 0 = already activated)
PlanckBlock *big.Int `json:"planckBlock,omitempty" toml:",omitempty"` // planckBlock switch block (nil = no fork, 0 = already activated)
LubanBlock *big.Int `json:"lubanBlock,omitempty" toml:",omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated)
PlatoBlock *big.Int `json:"platoBlock,omitempty" toml:",omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated)
HertzBlock *big.Int `json:"hertzBlock,omitempty" toml:",omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated)
HertzfixBlock *big.Int `json:"hertzfixBlock,omitempty" toml:",omitempty"` // hertzfixBlock switch block (nil = no fork, 0 = already activated)
EulerBlock *big.Int `json:"eulerBlock,omitempty" toml:",omitempty"` // eulerBlock switch block (nil = no fork, 0 = already activated)
GibbsBlock *big.Int `json:"gibbsBlock,omitempty" toml:",omitempty"` // gibbsBlock switch block (nil = no fork, 0 = already activated)
NanoBlock *big.Int `json:"nanoBlock,omitempty" toml:",omitempty"` // nanoBlock switch block (nil = no fork, 0 = already activated)
MoranBlock *big.Int `json:"moranBlock,omitempty" toml:",omitempty"` // moranBlock switch block (nil = no fork, 0 = already activated)
PlanckBlock *big.Int `json:"planckBlock,omitempty" toml:",omitempty"` // planckBlock switch block (nil = no fork, 0 = already activated)
LubanBlock *big.Int `json:"lubanBlock,omitempty" toml:",omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated)
PlatoBlock *big.Int `json:"platoBlock,omitempty" toml:",omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated)
HertzBlock *big.Int `json:"hertzBlock,omitempty" toml:",omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated)
HertzfixBlock *big.Int `json:"hertzfixBlock,omitempty" toml:",omitempty"` // hertzfixBlock switch block (nil = no fork, 0 = already activated)
// Various consensus engines
Clique *CliqueConfig `json:"clique,omitempty" toml:",omitempty"`
Parlia *ParliaConfig `json:"parlia,omitempty" toml:",omitempty"`
Expand Down Expand Up @@ -612,7 +611,7 @@ func (c *ChainConfig) HasDeployerProxy(num *big.Int) bool {
}

func (c *ChainConfig) IsBlockRewardsBlock(num *big.Int) bool {
return isForked(c.BlockRewardsBlock, num)
return isBlockForked(c.BlockRewardsBlock, num)
}

// CheckCompatible checks whether scheduled fork transitions have been imported
Expand Down Expand Up @@ -962,8 +961,8 @@ type Rules struct {
IsShanghai, IsKepler, IsCancun, IsPrague bool
IsVerkle bool
IsCatalyst bool
HasRuntimeUpgrade, HasDeployerProxy bool
HasBlockRewards bool
HasRuntimeUpgrade, HasDeployerProxy bool
HasBlockRewards bool
}

// Rules ensures c's ChainID is not nil.
Expand All @@ -973,16 +972,16 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
chainID = new(big.Int)
}
return Rules{
ChainID: new(big.Int).Set(chainID),
IsHomestead: c.IsHomestead(num),
IsEIP150: c.IsEIP150(num),
IsEIP155: c.IsEIP155(num),
IsEIP158: c.IsEIP158(num),
IsByzantium: c.IsByzantium(num),
IsConstantinople: c.IsConstantinople(num),
IsPetersburg: c.IsPetersburg(num),
IsIstanbul: c.IsIstanbul(num),
IsBerlin: c.IsBerlin(num),
ChainID: new(big.Int).Set(chainID),
IsHomestead: c.IsHomestead(num),
IsEIP150: c.IsEIP150(num),
IsEIP155: c.IsEIP155(num),
IsEIP158: c.IsEIP158(num),
IsByzantium: c.IsByzantium(num),
IsConstantinople: c.IsConstantinople(num),
IsPetersburg: c.IsPetersburg(num),
IsIstanbul: c.IsIstanbul(num),
IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num),
IsMerge: isMerge,
IsNano: c.IsNano(num),
Expand All @@ -997,8 +996,8 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsCancun: c.IsCancun(num, timestamp),
IsPrague: c.IsPrague(num, timestamp),
IsVerkle: c.IsVerkle(num, timestamp),
HasRuntimeUpgrade: c.HasRuntimeUpgrade(num),
HasDeployerProxy: c.HasDeployerProxy(num),
HasBlockRewards: c.IsBlockRewardsBlock(num),
HasRuntimeUpgrade: c.HasRuntimeUpgrade(num),
HasDeployerProxy: c.HasDeployerProxy(num),
HasBlockRewards: c.IsBlockRewardsBlock(num),
}
}

0 comments on commit fbfc5e0

Please sign in to comment.