Compare commits

...

4 Commits

Author SHA1 Message Date
Delweng bc0b7d0b38
Merge 8f7f97100f into ab4a1cc01f 2024-11-25 17:52:59 +08:00
Martin HS ab4a1cc01f
eth/tracers/logger: fix json-logger output missing (#30804)
Fixes a flaw introduced in
https://github.com/ethereum/go-ethereum/pull/29795 , discovered while
reviewing https://github.com/ethereum/go-ethereum/pull/30633 .
2024-11-25 10:07:50 +01:00
jsvisa 8f7f97100f eth/tracers: add test cases
Signed-off-by: jsvisa <delweng@gmail.com>
2024-11-22 10:52:57 +08:00
jsvisa 1f21652e28 eth/tracers: including the cleared storage slot in post state
Signed-off-by: jsvisa <delweng@gmail.com>
2024-11-22 10:48:57 +08:00
3 changed files with 109 additions and 12 deletions

View File

@ -0,0 +1,106 @@
{
"genesis": {
"baseFeePerGas": "7150891",
"blobGasUsed": "0",
"difficulty": "0",
"excessBlobGas": "0",
"extraData": "0xd983010e0c846765746888676f312e32322e328664617277696e",
"gasLimit": "1075412155",
"hash": "0xf4afd2ec49e5bf9a2355e07eb46176deb9ed4613228c01d7e575d755e4e3883e",
"miner": "0x0000000000000000000000000000000000000000",
"mixHash": "0x6608d895d3dec010cd82373c13e3a0b3cb1ce876337235b675aa296a8404baef",
"nonce": "0x0000000000000000",
"number": "37",
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"stateRoot": "0x1b9c695326ef3297c2527be62f814754f9efc799da8f77b621a63475dc75cb50",
"timestamp": "1732197354",
"withdrawals": [],
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"alloc": {
"0x0000000000000000000000000000000000000000": {
"balance": "0x184953ca292"
},
"0x1401173c73e1d8710e215cf5cdd02dc3d95bbdcc": {
"balance": "0x0",
"code": "0x608060405234801561000f575f80fd5b5060043610610034575f3560e01c8063d492613c14610038578063d61f5f421461004d575b5f80fd5b61004b61004636600461011d565b610093565b005b6040805180820182525f80825260209182018190528251808401909352548252600154908201526040805182518152602092830151928101929092520160405180910390f35b805f036100e65760405162461bcd60e51b815260206004820152601a60248201527f44656e6f6d696e61746f722063616e6e6f74206265207a65726f000000000000604482015260640160405180910390fd5b5f8281556040516bffffffffffffffffffffffff193360601b16602082015260340160408051601f19818403019052525060015550565b5f806040838503121561012e575f80fd5b5050803592602090910135915056fea2646970667358221220e84294f1de6e2dfe6b94d7fe095bb1b54f97d31d4c4a9ebfe9372b6cfa25204164736f6c63430008190033",
"nonce": "1",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0xb412fa0861bb1532171e2f7e6d88df75e8bb79d4ba10674f506b1d13a2d973b0",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000036"
}
},
"0xf077b491b355e64048ce21e3a6fc4751eeea77fa": {
"balance": "0x1a0555e5bd1a3a0a2",
"nonce": "3"
}
},
"config": {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"shanghaiTime": 0,
"cancunTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"depositContractAddress": "0x0000000000000000000000000000000000000000"
}
},
"context": {
"number": "38",
"difficulty": "0",
"timestamp": "1732197355",
"gasLimit": "1074361949",
"miner": "0x0000000000000000000000000000000000000000",
"baseFeePerGas": "6257083"
},
"input": "0xf8a903838e8236829301941401173c73e1d8710e215cf5cdd02dc3d95bbdcc80b844d492613c0000000000000000000000000000000000000000000000000000000000000000f7d9c0469c411e6b7d7863011ce7f3f258685e4ce99f5467f28c3598787722b5820a96a0eda00e7985f3c000aa403b0ff965afc30a250b6f5fd8ab6373f83eb9dd2e8a5aa07d7fb1ef7f72f971d623bbef974b4f34c7734dc429987a6aef866f95dd9e32f4",
"result": {
"post": {
"0x0000000000000000000000000000000000000000": {
"balance": "0x19823243de7"
},
"0x1401173c73e1d8710e215cf5cdd02dc3d95bbdcc": {
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0xf7d9c0469c411e6b7d7863011ce7f3f258685e4ce99f5467f28c3598787722b5"
}
},
"0xf077b491b355e64048ce21e3a6fc4751eeea77fa": {
"balance": "0x1a0555e2091eecf38",
"nonce": 4
}
},
"pre": {
"0x0000000000000000000000000000000000000000": {
"balance": "0x184953ca292"
},
"0x1401173c73e1d8710e215cf5cdd02dc3d95bbdcc": {
"balance": "0x0",
"code": "0x608060405234801561000f575f80fd5b5060043610610034575f3560e01c8063d492613c14610038578063d61f5f421461004d575b5f80fd5b61004b61004636600461011d565b610093565b005b6040805180820182525f80825260209182018190528251808401909352548252600154908201526040805182518152602092830151928101929092520160405180910390f35b805f036100e65760405162461bcd60e51b815260206004820152601a60248201527f44656e6f6d696e61746f722063616e6e6f74206265207a65726f000000000000604482015260640160405180910390fd5b5f8281556040516bffffffffffffffffffffffff193360601b16602082015260340160408051601f19818403019052525060015550565b5f806040838503121561012e575f80fd5b5050803592602090910135915056fea2646970667358221220e84294f1de6e2dfe6b94d7fe095bb1b54f97d31d4c4a9ebfe9372b6cfa25204164736f6c63430008190033",
"nonce": 1,
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0xb412fa0861bb1532171e2f7e6d88df75e8bb79d4ba10674f506b1d13a2d973b0",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000036"
}
},
"0xf077b491b355e64048ce21e3a6fc4751eeea77fa": {
"balance": "0x1a0555e5bd1a3a0a2",
"nonce": 3
}
}
},
"tracerConfig": {
"diffMode": true
}
}

View File

@ -71,7 +71,7 @@ func NewJSONLogger(cfg *Config, writer io.Writer) *tracing.Hooks {
l.hooks = &tracing.Hooks{
OnTxStart: l.OnTxStart,
OnSystemCallStart: l.onSystemCallStart,
OnExit: l.OnEnd,
OnExit: l.OnExit,
OnOpcode: l.OnOpcode,
OnFault: l.OnFault,
}
@ -152,13 +152,6 @@ func (l *jsonLogger) OnEnter(depth int, typ byte, from common.Address, to common
l.encoder.Encode(frame)
}
func (l *jsonLogger) OnEnd(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
if depth > 0 {
return
}
l.OnExit(depth, output, gasUsed, err, false)
}
func (l *jsonLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
type endLog struct {
Output string `json:"output"`

View File

@ -238,16 +238,14 @@ func (t *prestateTracer) processDiffState() {
newVal := t.env.StateDB.GetState(addr, key)
if val == newVal {
// Omit unchanged slots
// omit unchanged slots
delete(t.pre[addr].Storage, key)
} else {
modified = true
if newVal != (common.Hash{}) {
postAccount.Storage[key] = newVal
}
}
}
}
if modified {
t.post[addr] = postAccount