Skip to content

Commit d16cb17

Browse files
author
eric
committed
1.dev and self-test the requirement of new economic system
2. fix bug that get gasPrice from contract
1 parent 283c5ff commit d16cb17

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

core/vm/evm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
516516

517517
// Check whether the max code size has been exceeded, assign err if the case.
518518
maxCodeSize := params.MaxCodeSize
519-
if evm.chainRules.IsEIP3860 {
519+
if evm.chainRules.IsContract48kBlock {
520520
maxCodeSize = params.MaxCodeSize * 2
521521
}
522522
if err == nil && evm.chainRules.IsEIP158 && len(ret) > maxCodeSize {

eth/api_backend.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,16 @@ func (b *EthAPIBackend) Downloader() *downloader.Downloader {
277277

278278
func (b *EthAPIBackend) SuggestPrice(ctx context.Context) (*big.Int, error) {
279279
//Fncy2 Update
280-
//return b.gpo.SuggestPrice(ctx)
281-
return b.eth.TxPool().GasPriceWithoutLock(), nil
280+
if b.ChainConfig().IsFncy2(b.Chain().CurrentBlock().Header().Number) {
281+
suggestPrice, err := b.gpo.SuggestPrice(ctx)
282+
if err != nil {
283+
gasprice := b.eth.TxPool().GasPriceWithoutLock()
284+
if suggestPrice.Cmp(gasprice) < 0 {
285+
return gasprice, nil
286+
}
287+
}
288+
}
289+
return b.gpo.SuggestPrice(ctx)
282290
}
283291

284292
func (b *EthAPIBackend) Chain() *core.BlockChain {

params/config.go

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ var (
4646
big.NewInt(0),
4747
big.NewInt(0),
4848
big.NewInt(0),
49-
big.NewInt(0),
5049
nil, nil, nil, nil,
5150
big.NewInt(0),
5251
big.NewInt(0),
5352
big.NewInt(0),
5453
big.NewInt(0),
5554
big.NewInt(0),
55+
big.NewInt(0),
5656
nil,
5757
nil,
5858
nil,
@@ -77,14 +77,14 @@ var (
7777
big.NewInt(0),
7878
big.NewInt(0),
7979
big.NewInt(0),
80-
big.NewInt(0),
8180
nil, nil, nil, nil,
8281
big.NewInt(0),
8382
big.NewInt(0),
8483
big.NewInt(0),
8584
big.NewInt(0),
8685
big.NewInt(0),
87-
nil,
86+
big.NewInt(0),
87+
big.NewInt(0),
8888
&CliqueConfig{Period: 0, Epoch: 30000},
8989
nil,
9090
}
@@ -103,13 +103,13 @@ var (
103103
big.NewInt(0),
104104
big.NewInt(0),
105105
big.NewInt(0),
106-
big.NewInt(0),
107106
nil, nil, nil, nil,
108107
big.NewInt(0),
109108
big.NewInt(0),
110109
big.NewInt(0),
111110
big.NewInt(0),
112111
big.NewInt(0),
112+
big.NewInt(0),
113113
nil,
114114
nil, nil,
115115
}
@@ -179,7 +179,6 @@ type ChainConfig struct {
179179

180180
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
181181
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
182-
EIP3860Block *big.Int `json:"eip3860Block,omitempty"` // EIP3860 HF block
183182
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
184183
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
185184
PetersburgBlock *big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)
@@ -198,9 +197,9 @@ type ChainConfig struct {
198197
NielsBlock *big.Int `json:"nielsBlock,omitempty" toml:",omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
199198
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty" toml:",omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
200199
BrunoBlock *big.Int `json:"brunoBlock,omitempty" toml:",omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
201-
Fncy2Block *big.Int `json:"fncy2Block,omitempty" toml:",omitempty"` // fncy2Block switch block (nil = no fork, 0 = already activated)
202200
BlockRewardsBlock *big.Int `json:"blockRewardsBlock,omitempty" toml:",omitempty"`
203-
201+
Contract48kBlock *big.Int `json:"contract48kBlock,omitempty" toml:",omitempty"` // contract48kBlock switch block (nil = no fork, 0 = already activated)
202+
Fncy2Block *big.Int `json:"fncy2Block,omitempty" toml:",omitempty"` // fncy2Block switch block (nil = no fork, 0 = already activated)
204203
// Various consensus engines
205204
Clique *CliqueConfig `json:"clique,omitempty" toml:",omitempty"`
206205
Parlia *ParliaConfig `json:"parlia,omitempty" toml:",omitempty"`
@@ -282,8 +281,8 @@ func (c *ChainConfig) IsEIP158(num *big.Int) bool {
282281
return isForked(c.EIP158Block, num)
283282
}
284283

285-
func (c *ChainConfig) IsEIP3860(num *big.Int) bool {
286-
return isForked(c.EIP3860Block, num)
284+
func (c *ChainConfig) IsContract48kBlock(num *big.Int) bool {
285+
return isForked(c.Contract48kBlock, num)
287286
}
288287
func (c *ChainConfig) IsFncy2(num *big.Int) bool {
289288
return isForked(c.Fncy2Block, num)
@@ -553,12 +552,12 @@ func (err *ConfigCompatError) Error() string {
553552
// Rules is a one time interface meaning that it shouldn't be used in between transition
554553
// phases.
555554
type Rules struct {
556-
ChainID *big.Int
557-
IsHomestead, IsEIP150, IsEIP155, IsEIP158, IsEIP3860 bool
558-
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
559-
IsBerlin, IsCatalyst bool
560-
HasRuntimeUpgrade, HasDeployerProxy bool
561-
HasBlockRewards bool
555+
ChainID *big.Int
556+
IsHomestead, IsEIP150, IsEIP155, IsEIP158, IsContract48kBlock bool
557+
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
558+
IsBerlin, IsCatalyst bool
559+
HasRuntimeUpgrade, HasDeployerProxy bool
560+
HasBlockRewards bool
562561
}
563562

564563
// Rules ensures c's ChainID is not nil.
@@ -568,20 +567,20 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
568567
chainID = new(big.Int)
569568
}
570569
return Rules{
571-
ChainID: new(big.Int).Set(chainID),
572-
IsHomestead: c.IsHomestead(num),
573-
IsEIP150: c.IsEIP150(num),
574-
IsEIP155: c.IsEIP155(num),
575-
IsEIP158: c.IsEIP158(num),
576-
IsEIP3860: c.IsEIP3860(num),
577-
IsByzantium: c.IsByzantium(num),
578-
IsConstantinople: c.IsConstantinople(num),
579-
IsPetersburg: c.IsPetersburg(num),
580-
IsIstanbul: c.IsIstanbul(num),
581-
IsBerlin: c.IsBerlin(num),
582-
IsCatalyst: c.IsCatalyst(num),
583-
HasRuntimeUpgrade: c.HasRuntimeUpgrade(num),
584-
HasDeployerProxy: c.HasDeployerProxy(num),
585-
HasBlockRewards: c.IsBlockRewardsBlock(num),
570+
ChainID: new(big.Int).Set(chainID),
571+
IsHomestead: c.IsHomestead(num),
572+
IsEIP150: c.IsEIP150(num),
573+
IsEIP155: c.IsEIP155(num),
574+
IsEIP158: c.IsEIP158(num),
575+
IsContract48kBlock: c.IsContract48kBlock(num),
576+
IsByzantium: c.IsByzantium(num),
577+
IsConstantinople: c.IsConstantinople(num),
578+
IsPetersburg: c.IsPetersburg(num),
579+
IsIstanbul: c.IsIstanbul(num),
580+
IsBerlin: c.IsBerlin(num),
581+
IsCatalyst: c.IsCatalyst(num),
582+
HasRuntimeUpgrade: c.HasRuntimeUpgrade(num),
583+
HasDeployerProxy: c.HasDeployerProxy(num),
584+
HasBlockRewards: c.IsBlockRewardsBlock(num),
586585
}
587586
}

0 commit comments

Comments
 (0)