Parity

奇偶校驗節點:trace_rawTransaction 和 trace_replayTransaction rpc 呼叫的不同結果

  • October 19, 2018

通過呼叫這兩個 rpc 呼叫,我可以跟踪事務是否呼叫了更多消息呼叫。然而,當我嘗試這兩個 rpc 呼叫時,我在此事務中得到不同的結果。(https://etherscan.io/tx/0xebc237c2f49a4e0189a8aefae5d452beb9b99817b1b3bb09e74aa0dae53b45f8

來自{"method":"trace_rawTransaction","params":["0xf8642784b2d05e00832dc6c094a152bcaf9abe5b7e39c133480e6f3049570ead0e808026a02cc790bd1fb18d186e0f427ac330f7bb16075cae8b0a1e3b0496fda123175ee8a03ce2585c7c0aca79f53e83177e840e06674e63cc91242af9af89a8fef504ea6a",["trace"]],"id":1,"jsonrpc":"2.0"}

{"jsonrpc":"2.0","result":{"output":"0x","stateDiff":null,"trace":[{"action":{"callType":"call","from":"0x0232f3fb870334c2bc6de5c02d1a5c42ae7c06cd","gas":"0x2d74b8","input":"0x","to":"0xa152bcaf9abe5b7e39c133480e6f3049570ead0e","value":"0x0"},"result":{"gasUsed":"0x25ce2d","output":"0x"},"subtraces":21,"traceAddress":[],"type":"call"},{"action":{"from":"0xa152bcaf9abe5b7e39c133480e6f3049570ead0e","gas":"0x2c4305","init":"0x608060405234801561001057600080fd5b5060405173d1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b9081906000908181818181875af15050604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a038516935063a9059cbb9250329184916370a08231916024808201926020929091908290030181600087803b1580156100a757600080fd5b505af11580156100bb573d6000803e3d6000fd5b505050506040513d60208110156100d157600080fd5b5051604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561013957600080fd5b505af115801561014d573d6000803e3d6000fd5b505050506040513d602081101561016357600080fd5b5073175e8ca2a7ad4f205688a6896daa572733e0b6e19050ff00","value":"0x0"},"result":{"address":"0xee6e981fb5d7e658da30023d21aa77f67314b58e","code":"0x","gasUsed":"0x14f25"},"subtraces":4,"traceAddress":[0],"type":"create"},{"action":{"callType":"call","from":"0xee6e981fb5d7e658da30023d21aa77f67314b58e","gas":"0x2b8ef4","input":"0x","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0xf0f1","output":"0x"},"subtraces":0,"traceAddress":[0,0],"type":"call"},{"action":{"callType":"call","from":"0xee6e981fb5d7e658da30023d21aa77f67314b58e","gas":"0x2a9b78","input":"0x70a08231000000000000000000000000ee6e981fb5d7e658da30023d21aa77f67314b58e","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0x363","output":"0x0000000000000000000000000000000000000000000001fd01199b77b0d47398"},"subtraces":0,"traceAddress":[0,1],"type":"call"},{"action":{"callType":"call","from":"0xee6e981fb5d7e658da30023d21aa77f67314b58e","gas":"0x2a9199","input":"0xa9059cbb0000000000000000000000000232f3fb870334c2bc6de5c02d1a5c42ae7c06cd0000000000000000000000000000000000000000000001fd01199b77b0d47398","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0x36e0","output":"0x0000000000000000000000000000000000000000000000000000000000000001"},"subtraces":0,"traceAddress":[0,2],"type":"call"},{"action":{"address":"0xee6e981fb5d7e658da30023d21aa77f67314b58e","balance":"0x0","refundAddress":"0x175e8ca2a7ad4f205688a6896daa572733e0b6e1"},"result":null,"subtraces":0,"traceAddress":[0,3],"type":"suicide"} ... ],"vmTrace":null},"id":1}

來自 ‘{“method”:“trace_replayTransaction”,“params” 的響應:

$$ “0xebc237c2f49a4e0189a8aefae5d452beb9b99817b1b3bb09e74aa0dae53b45f8”,[“trace” $$],“id”:1,“jsonrpc”:“2.0”}’:

{"jsonrpc":"2.0","result":{"output":"0x","stateDiff":null,"trace":[{"action":{"callType":"call","from":"0x0232f3fb870334c2bc6de5c02d1a5c42ae7c06cd","gas":"0x2d74b8","input":"0x","to":"0xa152bcaf9abe5b7e39c133480e6f3049570ead0e","value":"0x0"},"result":{"gasUsed":"0x25ce2d","output":"0x"},"subtraces":21,"traceAddress":[],"type":"call"},{"action":{"from":"0xa152bcaf9abe5b7e39c133480e6f3049570ead0e","gas":"0x2c4305","init":"0x608060405234801561001057600080fd5b5060405173d1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b9081906000908181818181875af15050604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a038516935063a9059cbb9250329184916370a08231916024808201926020929091908290030181600087803b1580156100a757600080fd5b505af11580156100bb573d6000803e3d6000fd5b505050506040513d60208110156100d157600080fd5b5051604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561013957600080fd5b505af115801561014d573d6000803e3d6000fd5b505050506040513d602081101561016357600080fd5b5073175e8ca2a7ad4f205688a6896daa572733e0b6e19050ff00","value":"0x0"},"result":{"address":"0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d","code":"0x","gasUsed":"0x14f25"},"subtraces":4,"traceAddress":[0],"type":"create"},{"action":{"callType":"call","from":"0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d","gas":"0x2b8ef4","input":"0x","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0xf0f1","output":"0x"},"subtraces":0,"traceAddress":[0,0],"type":"call"},{"action":{"callType":"call","from":"0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d","gas":"0x2a9b78","input":"0x70a08231000000000000000000000000f1df9ae84c01ba555edcd54553cc08e5ba21eb2d","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0x363","output":"0x00000000000000000000000000000000000000000000020ab14c4bd560e4af37"},"subtraces":0,"traceAddress":[0,1],"type":"call"},{"action":{"callType":"call","from":"0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d","gas":"0x2a9199","input":"0xa9059cbb0000000000000000000000000232f3fb870334c2bc6de5c02d1a5c42ae7c06cd00000000000000000000000000000000000000000000020ab14c4bd560e4af37","to":"0xd1f1c5ff90fb6f3b0d57f5f6ad4aaf7400f4b39b","value":"0x0"},"result":{"gasUsed":"0x36e0","output":"0x0000000000000000000000000000000000000000000000000000000000000001"},"subtraces":0,"traceAddress":[0,2],"type":"call"},{"action":{"address":"0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d","balance":"0x0","refundAddress":"0x175e8ca2a7ad4f205688a6896daa572733e0b6e1"},"result":null,"subtraces":0,"traceAddress":[0,3],"type":"suicide"}],"vmTrace":null},"id":1}

為什麼我們得到兩個不同contract address的結果create actions?(一個契約地址是:0xee6e981fb5d7e658da30023d21aa77f67314b58e另一個是0xf1df9ae84c01ba555edcd54553cc08e5ba21eb2d:)

我試圖了解這兩個呼叫的差異,但在 wiki 上的解釋有限。有人可以幫我解釋這兩個電話嗎?

感謝您在高級的幫助!

誠然,這種行為有點奇怪,但在 wiki中有解釋,可以通過查看程式碼來驗證。

https://wiki.parity.io/JSONRPC-trace-module#the-ad-hoc-tracing-api

通過提供原始的、簽名的交易數據,就像使用 eth_sendRawTransaction(參見 trace_rawTransaction)或簡單地為先前探勘的交易提供交易雜湊(參見 trace_replayTransaction)

基本上,trace_replayTransaction正如您所注意到的,通過提供過去交易的交易散列,實際執行之前交易的呼叫。

相比之下,trace_rawTransaction(and trace_call,) 的行為就像您在提供的塊中執行交易一樣,但是對於您創建合約的案例,這可能並不意味著交易發生在塊中的相同索引處,就像它在之前的執行,導致不同的合約地址。

你可以在程式碼中看到:

https://github.com/paritytech/parity-ethereum/blob/1f18dbb17c5366af0cb324bf19ade483ed760266/rpc/src/v1/impls/traces.rs#L139

執行raw_transactionaclient.callreplay_transaction執行 aclient.replay

引用自:https://ethereum.stackexchange.com/questions/60734