Skip to content

Commit 8dd3397

Browse files
holimandshulyak
authored andcommitted
core, cmd/puppeth: implement constantinople fix, disable EIP-1283 (ethereum#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!
1 parent fbf6423 commit 8dd3397

File tree

11 files changed

+134
-66
lines changed

11 files changed

+134
-66
lines changed

cmd/puppeth/genesis.go

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,29 @@ type parityChainSpec struct {
223223
} `json:"engine"`
224224

225225
Params struct {
226-
AccountStartNonce hexutil.Uint64 `json:"accountStartNonce"`
227-
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
228-
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
229-
GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"`
230-
NetworkID hexutil.Uint64 `json:"networkID"`
231-
ChainID hexutil.Uint64 `json:"chainID"`
232-
MaxCodeSize hexutil.Uint64 `json:"maxCodeSize"`
233-
MaxCodeSizeTransition hexutil.Uint64 `json:"maxCodeSizeTransition"`
234-
EIP98Transition hexutil.Uint64 `json:"eip98Transition"`
235-
EIP150Transition hexutil.Uint64 `json:"eip150Transition"`
236-
EIP160Transition hexutil.Uint64 `json:"eip160Transition"`
237-
EIP161abcTransition hexutil.Uint64 `json:"eip161abcTransition"`
238-
EIP161dTransition hexutil.Uint64 `json:"eip161dTransition"`
239-
EIP155Transition hexutil.Uint64 `json:"eip155Transition"`
240-
EIP140Transition hexutil.Uint64 `json:"eip140Transition"`
241-
EIP211Transition hexutil.Uint64 `json:"eip211Transition"`
242-
EIP214Transition hexutil.Uint64 `json:"eip214Transition"`
243-
EIP658Transition hexutil.Uint64 `json:"eip658Transition"`
244-
EIP145Transition hexutil.Uint64 `json:"eip145Transition"`
245-
EIP1014Transition hexutil.Uint64 `json:"eip1014Transition"`
246-
EIP1052Transition hexutil.Uint64 `json:"eip1052Transition"`
247-
EIP1283Transition hexutil.Uint64 `json:"eip1283Transition"`
226+
AccountStartNonce hexutil.Uint64 `json:"accountStartNonce"`
227+
MaximumExtraDataSize hexutil.Uint64 `json:"maximumExtraDataSize"`
228+
MinGasLimit hexutil.Uint64 `json:"minGasLimit"`
229+
GasLimitBoundDivisor math2.HexOrDecimal64 `json:"gasLimitBoundDivisor"`
230+
NetworkID hexutil.Uint64 `json:"networkID"`
231+
ChainID hexutil.Uint64 `json:"chainID"`
232+
MaxCodeSize hexutil.Uint64 `json:"maxCodeSize"`
233+
MaxCodeSizeTransition hexutil.Uint64 `json:"maxCodeSizeTransition"`
234+
EIP98Transition hexutil.Uint64 `json:"eip98Transition"`
235+
EIP150Transition hexutil.Uint64 `json:"eip150Transition"`
236+
EIP160Transition hexutil.Uint64 `json:"eip160Transition"`
237+
EIP161abcTransition hexutil.Uint64 `json:"eip161abcTransition"`
238+
EIP161dTransition hexutil.Uint64 `json:"eip161dTransition"`
239+
EIP155Transition hexutil.Uint64 `json:"eip155Transition"`
240+
EIP140Transition hexutil.Uint64 `json:"eip140Transition"`
241+
EIP211Transition hexutil.Uint64 `json:"eip211Transition"`
242+
EIP214Transition hexutil.Uint64 `json:"eip214Transition"`
243+
EIP658Transition hexutil.Uint64 `json:"eip658Transition"`
244+
EIP145Transition hexutil.Uint64 `json:"eip145Transition"`
245+
EIP1014Transition hexutil.Uint64 `json:"eip1014Transition"`
246+
EIP1052Transition hexutil.Uint64 `json:"eip1052Transition"`
247+
EIP1283Transition hexutil.Uint64 `json:"eip1283Transition"`
248+
EIP1283DisableTransition hexutil.Uint64 `json:"eip1283DisableTransition"`
248249
} `json:"params"`
249250

250251
Genesis struct {
@@ -347,6 +348,11 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
347348
if num := genesis.Config.ConstantinopleBlock; num != nil {
348349
spec.setConstantinople(num)
349350
}
351+
// ConstantinopleFix (remove eip-1283)
352+
if num := genesis.Config.PetersburgBlock; num != nil {
353+
spec.setConstantinopleFix(num)
354+
}
355+
350356
spec.Params.MaximumExtraDataSize = (hexutil.Uint64)(params.MaximumExtraDataSize)
351357
spec.Params.MinGasLimit = (hexutil.Uint64)(params.MinGasLimit)
352358
spec.Params.GasLimitBoundDivisor = (math2.HexOrDecimal64)(params.GasLimitBoundDivisor)
@@ -441,6 +447,10 @@ func (spec *parityChainSpec) setConstantinople(num *big.Int) {
441447
spec.Params.EIP1283Transition = n
442448
}
443449

450+
func (spec *parityChainSpec) setConstantinopleFix(num *big.Int) {
451+
spec.Params.EIP1283DisableTransition = hexutil.Uint64(num.Uint64())
452+
}
453+
444454
// pyEthereumGenesisSpec represents the genesis specification format used by the
445455
// Python Ethereum implementation.
446456
type pyEthereumGenesisSpec struct {

cmd/puppeth/module_dashboard.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -608,30 +608,31 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
608608
bootPython[i] = "'" + boot + "'"
609609
}
610610
template.Must(template.New("").Parse(dashboardContent)).Execute(indexfile, map[string]interface{}{
611-
"Network": network,
612-
"NetworkID": conf.Genesis.Config.ChainID,
613-
"NetworkTitle": strings.Title(network),
614-
"EthstatsPage": config.ethstats,
615-
"ExplorerPage": config.explorer,
616-
"WalletPage": config.wallet,
617-
"FaucetPage": config.faucet,
618-
"GethGenesis": network + ".json",
619-
"Bootnodes": conf.bootnodes,
620-
"BootnodesFlat": strings.Join(conf.bootnodes, ","),
621-
"Ethstats": statsLogin,
622-
"Ethash": conf.Genesis.Config.Ethash != nil,
623-
"CppGenesis": network + "-cpp.json",
624-
"CppBootnodes": strings.Join(bootCpp, " "),
625-
"HarmonyGenesis": network + "-harmony.json",
626-
"HarmonyBootnodes": strings.Join(bootHarmony, " "),
627-
"ParityGenesis": network + "-parity.json",
628-
"PythonGenesis": network + "-python.json",
629-
"PythonBootnodes": strings.Join(bootPython, ","),
630-
"Homestead": conf.Genesis.Config.HomesteadBlock,
631-
"Tangerine": conf.Genesis.Config.EIP150Block,
632-
"Spurious": conf.Genesis.Config.EIP155Block,
633-
"Byzantium": conf.Genesis.Config.ByzantiumBlock,
634-
"Constantinople": conf.Genesis.Config.ConstantinopleBlock,
611+
"Network": network,
612+
"NetworkID": conf.Genesis.Config.ChainID,
613+
"NetworkTitle": strings.Title(network),
614+
"EthstatsPage": config.ethstats,
615+
"ExplorerPage": config.explorer,
616+
"WalletPage": config.wallet,
617+
"FaucetPage": config.faucet,
618+
"GethGenesis": network + ".json",
619+
"Bootnodes": conf.bootnodes,
620+
"BootnodesFlat": strings.Join(conf.bootnodes, ","),
621+
"Ethstats": statsLogin,
622+
"Ethash": conf.Genesis.Config.Ethash != nil,
623+
"CppGenesis": network + "-cpp.json",
624+
"CppBootnodes": strings.Join(bootCpp, " "),
625+
"HarmonyGenesis": network + "-harmony.json",
626+
"HarmonyBootnodes": strings.Join(bootHarmony, " "),
627+
"ParityGenesis": network + "-parity.json",
628+
"PythonGenesis": network + "-python.json",
629+
"PythonBootnodes": strings.Join(bootPython, ","),
630+
"Homestead": conf.Genesis.Config.HomesteadBlock,
631+
"Tangerine": conf.Genesis.Config.EIP150Block,
632+
"Spurious": conf.Genesis.Config.EIP155Block,
633+
"Byzantium": conf.Genesis.Config.ByzantiumBlock,
634+
"Constantinople": conf.Genesis.Config.ConstantinopleBlock,
635+
"ConstantinopleFix": conf.Genesis.Config.PetersburgBlock,
635636
})
636637
files[filepath.Join(workdir, "index.html")] = indexfile.Bytes()
637638

cmd/puppeth/wizard_genesis.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ func (w *wizard) manageGenesis() {
223223
fmt.Printf("Which block should Constantinople come into effect? (default = %v)\n", w.conf.Genesis.Config.ConstantinopleBlock)
224224
w.conf.Genesis.Config.ConstantinopleBlock = w.readDefaultBigInt(w.conf.Genesis.Config.ConstantinopleBlock)
225225

226+
fmt.Println()
227+
fmt.Printf("Which block should Constantinople-Fix (remove EIP-1283) come into effect? (default = %v)\n", w.conf.Genesis.Config.ConstantinopleBlock)
228+
w.conf.Genesis.Config.PetersburgBlock = w.readDefaultBigInt(w.conf.Genesis.Config.ConstantinopleBlock)
229+
226230
out, _ := json.MarshalIndent(w.conf.Genesis.Config, "", " ")
227231
fmt.Printf("Chain configuration updated:\n\n%s\n", out)
228232

core/genesis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, constant
183183
newcfg := genesis.configOrDefault(stored)
184184
if constantinopleOverride != nil {
185185
newcfg.ConstantinopleBlock = constantinopleOverride
186+
newcfg.PetersburgBlock = constantinopleOverride
186187
}
187188
storedcfg := rawdb.ReadChainConfig(db, stored)
188189
if storedcfg == nil {

core/vm/gas_table.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ func gasSStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m
121121
current = evm.StateDB.GetState(contract.Address(), common.BigToHash(x))
122122
)
123123
// The legacy gas metering only takes into consideration the current state
124-
if !evm.chainRules.IsConstantinople {
124+
// Legacy rules should be applied if we are in Petersburg (removal of EIP-1283)
125+
// OR Constantinople is not active
126+
if evm.chainRules.IsPetersburg || !evm.chainRules.IsConstantinople {
125127
// This checks for 3 scenario's and calculates gas accordingly:
126128
//
127129
// 1. From a zero-value address to a non-zero value (NEW VALUE)

core/vm/logger_json.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ type JSONLogger struct {
3434
// NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects
3535
// into the provided stream.
3636
func NewJSONLogger(cfg *LogConfig, writer io.Writer) *JSONLogger {
37-
return &JSONLogger{json.NewEncoder(writer), cfg}
37+
l := &JSONLogger{json.NewEncoder(writer), cfg}
38+
if l.cfg == nil {
39+
l.cfg = &LogConfig{}
40+
}
41+
return l
3842
}
3943

4044
func (l *JSONLogger) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {

params/config.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ var (
4242
EIP155Block: big.NewInt(2675000),
4343
EIP158Block: big.NewInt(2675000),
4444
ByzantiumBlock: big.NewInt(4370000),
45-
ConstantinopleBlock: nil,
45+
ConstantinopleBlock: big.NewInt(7280000),
46+
PetersburgBlock: big.NewInt(7280000),
4647
Ethash: new(EthashConfig),
4748
}
4849

@@ -67,6 +68,7 @@ var (
6768
EIP158Block: big.NewInt(10),
6869
ByzantiumBlock: big.NewInt(1700000),
6970
ConstantinopleBlock: big.NewInt(4230000),
71+
PetersburgBlock: big.NewInt(4939394),
7072
Ethash: new(EthashConfig),
7173
}
7274

@@ -91,6 +93,7 @@ var (
9193
EIP158Block: big.NewInt(3),
9294
ByzantiumBlock: big.NewInt(1035301),
9395
ConstantinopleBlock: big.NewInt(3660663),
96+
PetersburgBlock: big.NewInt(9999999), //TODO! Insert Rinkeby block number
9497
Clique: &CliqueConfig{
9598
Period: 15,
9699
Epoch: 30000,
@@ -111,16 +114,16 @@ var (
111114
//
112115
// This configuration is intentionally not using keyed fields to force anyone
113116
// adding flags to the config to also have to set these fields.
114-
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), nil, new(EthashConfig), nil}
117+
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), nil, new(EthashConfig), nil}
115118

116119
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
117120
// and accepted by the Ethereum core developers into the Clique consensus.
118121
//
119122
// This configuration is intentionally not using keyed fields to force anyone
120123
// adding flags to the config to also have to set these fields.
121-
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), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
124+
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), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
122125

123-
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), nil, new(EthashConfig), nil}
126+
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), nil, new(EthashConfig), nil}
124127
TestRules = TestChainConfig.Rules(new(big.Int))
125128
)
126129

@@ -158,6 +161,7 @@ type ChainConfig struct {
158161

159162
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
160163
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
164+
PetersburgBlock *big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)
161165
EWASMBlock *big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
162166

163167
// Various consensus engines
@@ -195,7 +199,7 @@ func (c *ChainConfig) String() string {
195199
default:
196200
engine = "unknown"
197201
}
198-
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}",
202+
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v ConstantinopleFix: %v Engine: %v}",
199203
c.ChainID,
200204
c.HomesteadBlock,
201205
c.DAOForkBlock,
@@ -205,6 +209,7 @@ func (c *ChainConfig) String() string {
205209
c.EIP158Block,
206210
c.ByzantiumBlock,
207211
c.ConstantinopleBlock,
212+
c.PetersburgBlock,
208213
engine,
209214
)
210215
}
@@ -244,6 +249,13 @@ func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
244249
return isForked(c.ConstantinopleBlock, num)
245250
}
246251

252+
// IsPetersburg returns whether num is either
253+
// - equal to or greater than the PetersburgBlock fork block,
254+
// - OR is nil, and Constantinople is active
255+
func (c *ChainConfig) IsPetersburg(num *big.Int) bool {
256+
return isForked(c.PetersburgBlock, num) || c.PetersburgBlock == nil && isForked(c.ConstantinopleBlock, num)
257+
}
258+
247259
// IsEWASM returns whether num represents a block number after the EWASM fork
248260
func (c *ChainConfig) IsEWASM(num *big.Int) bool {
249261
return isForked(c.EWASMBlock, num)
@@ -314,6 +326,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
314326
if isForkIncompatible(c.ConstantinopleBlock, newcfg.ConstantinopleBlock, head) {
315327
return newCompatError("Constantinople fork block", c.ConstantinopleBlock, newcfg.ConstantinopleBlock)
316328
}
329+
if isForkIncompatible(c.PetersburgBlock, newcfg.PetersburgBlock, head) {
330+
return newCompatError("ConstantinopleFix fork block", c.PetersburgBlock, newcfg.PetersburgBlock)
331+
}
317332
if isForkIncompatible(c.EWASMBlock, newcfg.EWASMBlock, head) {
318333
return newCompatError("ewasm fork block", c.EWASMBlock, newcfg.EWASMBlock)
319334
}
@@ -381,9 +396,9 @@ func (err *ConfigCompatError) Error() string {
381396
// Rules is a one time interface meaning that it shouldn't be used in between transition
382397
// phases.
383398
type Rules struct {
384-
ChainID *big.Int
385-
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
386-
IsByzantium, IsConstantinople bool
399+
ChainID *big.Int
400+
IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool
401+
IsByzantium, IsConstantinople, IsPetersburg bool
387402
}
388403

389404
// Rules ensures c's ChainID is not nil.
@@ -400,5 +415,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
400415
IsEIP158: c.IsEIP158(num),
401416
IsByzantium: c.IsByzantium(num),
402417
IsConstantinople: c.IsConstantinople(num),
418+
IsPetersburg: c.IsPetersburg(num),
403419
}
404420
}

tests/init.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ var Forks = map[string]*params.ChainConfig{
6262
DAOForkBlock: big.NewInt(0),
6363
ByzantiumBlock: big.NewInt(0),
6464
ConstantinopleBlock: big.NewInt(0),
65+
PetersburgBlock: big.NewInt(10000000),
66+
},
67+
"ConstantinopleFix": {
68+
ChainID: big.NewInt(1),
69+
HomesteadBlock: big.NewInt(0),
70+
EIP150Block: big.NewInt(0),
71+
EIP155Block: big.NewInt(0),
72+
EIP158Block: big.NewInt(0),
73+
DAOForkBlock: big.NewInt(0),
74+
ByzantiumBlock: big.NewInt(0),
75+
ConstantinopleBlock: big.NewInt(0),
76+
PetersburgBlock: big.NewInt(0),
6577
},
6678
"FrontierToHomesteadAt5": {
6779
ChainID: big.NewInt(1),

tests/rlp_test_util.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,22 @@ type RLPTest struct {
4242
Out string
4343
}
4444

45+
// FromHex returns the bytes represented by the hexadecimal string s.
46+
// s may be prefixed with "0x".
47+
// This is copy-pasted from bytes.go, which does not return the error
48+
func FromHex(s string) ([]byte, error) {
49+
if len(s) > 1 && (s[0:2] == "0x" || s[0:2] == "0X") {
50+
s = s[2:]
51+
}
52+
if len(s)%2 == 1 {
53+
s = "0" + s
54+
}
55+
return hex.DecodeString(s)
56+
}
57+
4558
// Run executes the test.
4659
func (t *RLPTest) Run() error {
47-
outb, err := hex.DecodeString(t.Out)
60+
outb, err := FromHex(t.Out)
4861
if err != nil {
4962
return fmt.Errorf("invalid hex in Out")
5063
}

tests/state_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package tests
1818

1919
import (
20+
"bufio"
2021
"bytes"
2122
"flag"
2223
"fmt"
@@ -45,9 +46,12 @@ func TestState(t *testing.T) {
4546
st.skipLoad(`^stTransactionTest/OverflowGasRequire\.json`) // gasLimit > 256 bits
4647
st.skipLoad(`^stTransactionTest/zeroSigTransa[^/]*\.json`) // EIP-86 is not supported yet
4748
// Expected failures:
48-
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/EIP158`, "bug in test")
49-
st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/Byzantium`, "bug in test")
50-
st.fails(`^stRevertTest/RevertPrecompiledTouch.json/Constantinople`, "bug in test")
49+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/Byzantium/0`, "bug in test")
50+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/Byzantium/3`, "bug in test")
51+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/Constantinople/0`, "bug in test")
52+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/Constantinople/3`, "bug in test")
53+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/0`, "bug in test")
54+
st.fails(`^stRevertTest/RevertPrecompiledTouch(_storage)?\.json/ConstantinopleFix/3`, "bug in test")
5155

5256
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
5357
for _, subtest := range test.Subtests() {
@@ -86,18 +90,19 @@ func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
8690
t.Log("gas limit too high for EVM trace")
8791
return
8892
}
89-
tracer := vm.NewStructLogger(nil)
93+
buf := new(bytes.Buffer)
94+
w := bufio.NewWriter(buf)
95+
tracer := vm.NewJSONLogger(&vm.LogConfig{DisableMemory: true}, w)
9096
err2 := test(vm.Config{Debug: true, Tracer: tracer})
9197
if !reflect.DeepEqual(err, err2) {
9298
t.Errorf("different error for second run: %v", err2)
9399
}
94-
buf := new(bytes.Buffer)
95-
vm.WriteTrace(buf, tracer.StructLogs())
100+
w.Flush()
96101
if buf.Len() == 0 {
97102
t.Log("no EVM operation logs generated")
98103
} else {
99104
t.Log("EVM operation log:\n" + buf.String())
100105
}
101-
t.Logf("EVM output: 0x%x", tracer.Output())
102-
t.Logf("EVM error: %v", tracer.Error())
106+
//t.Logf("EVM output: 0x%x", tracer.Output())
107+
//t.Logf("EVM error: %v", tracer.Error())
103108
}

0 commit comments

Comments
 (0)