Skip to content

Commit

Permalink
Merge pull request METADIUM#43 from cp-yoonjin/dev_feeDelegation
Browse files Browse the repository at this point in the history
core,light,params,wemix/scripts: Configuration settings for Applepie …
  • Loading branch information
wm-jsong1230 authored May 2, 2023
2 parents b2d30ac + 136473a commit 19f4521
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (st *StateTransition) to() common.Address {
func (st *StateTransition) buyGas() error {
// fee delegation
if st.msg.FeePayer() != nil {
if !st.evm.ChainConfig().IsFeeDelegation(st.evm.Context.BlockNumber) {
if !st.evm.ChainConfig().IsApplepie(st.evm.Context.BlockNumber) {
return fmt.Errorf("%w: fee delegation type not supported", ErrTxTypeNotSupported)
}
FDmgval := new(big.Int).SetUint64(st.msg.Gas())
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.eip2718 = pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.IsLondon(next)
// fee delegation
pool.feedelegation = pool.chainconfig.IsFeeDelegation(next)
pool.feedelegation = pool.chainconfig.IsApplepie(next)
}

// promoteExecutables moves transactions that have become processable from the
Expand Down
2 changes: 1 addition & 1 deletion light/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (pool *TxPool) setNewHead(head *types.Header) {
pool.istanbul = pool.config.IsIstanbul(next)
pool.eip2718 = pool.config.IsBerlin(next)
// fee delegation
pool.feedelegation = pool.config.IsFeeDelegation(next)
pool.feedelegation = pool.config.IsApplepie(next)
}

// Stop stops the light transaction pool
Expand Down
25 changes: 13 additions & 12 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
PangyoBlock: big.NewInt(10_000_000),
ApplepieBlock: big.NewInt(26_240_268),
Ethash: new(EthashConfig),
}

Expand Down Expand Up @@ -301,16 +302,16 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil}
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil}

// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}

TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, new(EthashConfig), nil}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil}
TestRules = TestChainConfig.Rules(new(big.Int), false)
)

Expand Down Expand Up @@ -392,6 +393,7 @@ type ChainConfig struct {
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
MergeForkBlock *big.Int `json:"mergeForkBlock,omitempty"` // EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings)
PangyoBlock *big.Int `json:"pangyoBlock,omitempty"` // Pangyo switch block (nil = no fork, 0 = already on pangyo)
ApplepieBlock *big.Int `json:"applepieBlock,omitempty"` // Applepie switch block (nil = no fork, 0 = already on applepie)

// TerminalTotalDifficulty is the amount of total difficulty reached by
// the network that triggers the consensus upgrade.
Expand Down Expand Up @@ -432,7 +434,7 @@ func (c *ChainConfig) String() string {
default:
engine = "unknown"
}
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, MergeFork: %v, Terminal TD: %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, MergeFork: %v, PangyoFork: %v, ApplepieFork: %v, Terminal TD: %v, Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
Expand All @@ -449,6 +451,8 @@ func (c *ChainConfig) String() string {
c.LondonBlock,
c.ArrowGlacierBlock,
c.MergeForkBlock,
c.PangyoBlock,
c.ApplepieBlock,
c.TerminalTotalDifficulty,
engine,
)
Expand Down Expand Up @@ -522,13 +526,9 @@ func (c *ChainConfig) IsPangyo(num *big.Int) bool {
}

// fee delegation
// IsFeeDelegation returns whether num is either equal to the fee delegation fork block or greater.
func (c *ChainConfig) IsFeeDelegation(num *big.Int) bool {
// TBD
// Test code
//FeeDelegateBlock := big.NewInt(277000)
//return isForked(FeeDelegateBlock, num)
return false
// IsApplepie returns whether num is either equal to the Applepie fork block or greater.
func (c *ChainConfig) IsApplepie(num *big.Int) bool {
return isForked(c.ApplepieBlock, num)
}

// IsArrowGlacier returns whether num is either equal to the Arrow Glacier (EIP-4345) fork block or greater.
Expand Down Expand Up @@ -735,7 +735,7 @@ type Rules struct {
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
IsBerlin, IsLondon bool
IsMerge bool
IsPangyo bool
IsPangyo, IsApplepie bool
}

// Rules ensures c's ChainID is not nil.
Expand All @@ -758,5 +758,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
IsLondon: c.IsLondon(num),
IsMerge: isMerge,
IsPangyo: c.IsPangyo(num),
IsApplepie: c.IsApplepie(num),
}
}
3 changes: 2 additions & 1 deletion wemix/scripts/genesis-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"istanbulBlock": 0,
"londonBlock": 0,
"muirGlacierBlock": 0,
"pangyoBlock": 0
"pangyoBlock": 0,
"applepieBlock": 0
}
}

0 comments on commit 19f4521

Please sign in to comment.