diff options
author | Martin Holst Swende <martin@swende.se> | 2019-01-24 18:36:30 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2019-01-30 00:49:27 +0800 |
commit | c7664b06361663e2027e74574804f3210542f19f (patch) | |
tree | ac1f0dc6fd116b4cbd9385b5f3899dd07a14a477 /core | |
parent | 9dc5d1a915ac0e0bd8429d6ac41df50eec91de5f (diff) | |
download | dexon-c7664b06361663e2027e74574804f3210542f19f.tar dexon-c7664b06361663e2027e74574804f3210542f19f.tar.gz dexon-c7664b06361663e2027e74574804f3210542f19f.tar.bz2 dexon-c7664b06361663e2027e74574804f3210542f19f.tar.lz dexon-c7664b06361663e2027e74574804f3210542f19f.tar.xz dexon-c7664b06361663e2027e74574804f3210542f19f.tar.zst dexon-c7664b06361663e2027e74574804f3210542f19f.zip |
core, cmd/puppeth: implement constantinople fix, disable EIP-1283 (#18486)
This PR adds a new fork which disables EIP-1283. Internally it's called Petersburg,
but the genesis/config field is ConstantinopleFix.
The block numbers are:
7280000 for Constantinople on Mainnet
7280000 for ConstantinopleFix on Mainnet
4939394 for ConstantinopleFix on Ropsten
9999999 for ConstantinopleFix on Rinkeby (real number decided later)
This PR also defaults to using the same ConstantinopleFix number as whatever
Constantinople is set to. That is, it will default to mainnet behaviour if ConstantinopleFix
is not set.This means that for private networks which have already transitioned
to Constantinople, this PR will break the network unless ConstantinopleFix is
explicitly set!
Diffstat (limited to 'core')
-rw-r--r-- | core/genesis.go | 1 | ||||
-rw-r--r-- | core/vm/gas_table.go | 4 | ||||
-rw-r--r-- | core/vm/logger_json.go | 6 |
3 files changed, 9 insertions, 2 deletions
diff --git a/core/genesis.go b/core/genesis.go index c96cb17a3..62cde87b5 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -183,6 +183,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, constant newcfg := genesis.configOrDefault(stored) if constantinopleOverride != nil { newcfg.ConstantinopleBlock = constantinopleOverride + newcfg.PetersburgBlock = constantinopleOverride } storedcfg := rawdb.ReadChainConfig(db, stored) if storedcfg == nil { diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index df79f86ec..9203e10a7 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -121,7 +121,9 @@ func gasSStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m current = evm.StateDB.GetState(contract.Address(), common.BigToHash(x)) ) // The legacy gas metering only takes into consideration the current state - if !evm.chainRules.IsConstantinople { + // Legacy rules should be applied if we are in Petersburg (removal of EIP-1283) + // OR Constantinople is not active + if evm.chainRules.IsPetersburg || !evm.chainRules.IsConstantinople { // This checks for 3 scenario's and calculates gas accordingly: // // 1. From a zero-value address to a non-zero value (NEW VALUE) diff --git a/core/vm/logger_json.go b/core/vm/logger_json.go index ac3c40759..ff379a4ef 100644 --- a/core/vm/logger_json.go +++ b/core/vm/logger_json.go @@ -34,7 +34,11 @@ type JSONLogger struct { // NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects // into the provided stream. func NewJSONLogger(cfg *LogConfig, writer io.Writer) *JSONLogger { - return &JSONLogger{json.NewEncoder(writer), cfg} + l := &JSONLogger{json.NewEncoder(writer), cfg} + if l.cfg == nil { + l.cfg = &LogConfig{} + } + return l } func (l *JSONLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error { |