Go-Ethereum

奇偶校驗跟踪中的“type”和“callType”有什麼區別?

  • December 7, 2018

對於奇偶校驗節點,獲取事務跟踪的響應包含"callType""type"都是"call". 但是對於 geth 節點,我們只得到'type':'Call'. "callType"所以我很困惑,和有什麼區別"type"

https://etherscan.io/vmtrace?txhash=0x626590b434e06b79fdd2187b28a55569f6c0636c6806808beb6ce2c743e88188&type=parity#raw

...
"action": {
 "callType": "call",
 "from": "0x8871759b2530fee82cd1b31c534252a1db707b0b",
 "gas": "0x25ce48",
 "input": "0x3dea52fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000077e772392b600000000000000000000000000000000000000000000000000000000000000000001",
 "to": "0x94c0d029a7b64bf443e89c5006089364c0d60d61",
 "value": "0x0"
},
"blockHash": "0xbe847be2bceb74e660daf96b3f0669d58f59dc9101715689a00ef864a5408f43",
"blockNumber": 6000000,
"result": {
 "gasUsed": "0x2532ed",
 "output": "0x"
},
"subtraces": 1,
"traceAddress": [],
"transactionHash": "0x626590b434e06b79fdd2187b28a55569f6c0636c6806808beb6ce2c743e88188",
"transactionPosition": 45,
"type": "call"}, 

但是對於geth節點,我得到了:

 ...
 'result': {'type': 'CALL',
 'from': '0x8871759b2530fee82cd1b31c534252a1db707b0b',
 'to': '0x94c0d029a7b64bf443e89c5006089364c0d60d61',
 'value': '0x0',
 'gas': '0x25ce48',
 'gasUsed': '0x2532ed',
 'input': 
'0x3dea52fc00000000000000000000000000000000000000000000000000000000000000 
0000000000000000000000000000000000000000000000000000000000000003e800000000 
0000000000000000000000000000000000000000077e772392b600000000000000000000000000000000000000000000000000000000000000000001',
 'output': '0x',
 'time': '10.824367485s',
 ...

為了得到這個問題的答案,我們可以查看Parity-Ethereum 的原始碼模組的文件trace

源碼中有兩個不同的定義:

行動

/// Action
#[derive(Debug)]
pub enum Action {
   /// Call
   Call(Call),
   /// Create
   Create(Create),
   /// Suicide
   Suicide(Suicide),
   /// Reward
   Reward(Reward),
}

呼叫類型

/// Call type.
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum CallType {
   /// None
   None,
   /// Call
   Call,
   /// Call code
   CallCode,
   /// Delegate call
   DelegateCall,
   /// Static call
   StaticCall,
}

所以在這裡我們可以看到每條trace都有一個Actiontype在JSON中表示為),如果Action是a Call,那麼它可以有一個CallType(表示為calltype)。

這些通常都由Ethereum OpCodes表示:

來電

0xf1    CALL    Message-call into an account    -   Complicated
0xf2    CALLCODE    Message-call into this account with alternative account's code  -   Complicated
0xf4    DELEGATECALL    Message-call into this account with an alternative account's code, but persisting into this account with an alternative account's code  -   Complicated
0xfa    STATICCALL  Similar to CALL, but does not modify state  -   40

其他

0xf0    CREATE  Create a new account with associated code   -   32000
0xff    SELFDESTRUCT    Halt execution and register account for later deletion  -   5000*

不太確定Reward,不過這裡建議是給大叔和挖礦獎勵的。

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