Skip to content

Instantly share code, notes, and snippets.

@holiman
Last active October 21, 2022 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save holiman/427dde9faf552e2f01db27a8879ab331 to your computer and use it in GitHub Desktop.
Save holiman/427dde9faf552e2f01db27a8879ab331 to your computer and use it in GitHub Desktop.
Method pending uses
eth_call yes StateAndHeaderByNumberOrHash -> block from miner
eth.getBalance yes StateAndHeaderByNumber(ctx, blockNr) -> block from miner
eth.getCode yes StateAndHeaderByNumber(ctx, blockNr) -> block from miner
eth.estimateGas yes StateAndHeaderByNumberOrHash-> block from miner
eth.getStorageAt yes StateAndHeaderByNumber(ctx, blockNr) -> block from miner
eth.getTransactionFromBlock yes Uses to GetTransactionByBlockNumberAndIndex -> BlockByNumber -> b.eth.miner.PendingBlock()
debug_traceCall does not work, uses empty state, see ethereum/go-ethereum#24830
debug.traceBlockByNumber maybe? returns empty in dev-mode, which is to be expected ?
eth.getTransactionCount Somewhat Ok Uses the GetPoolNonce, so based on the pending queue rather than miner-block
Method latest pending
debug_traceTransaction does not take block does not take block
debug.traceBlock only accepts hash only accepts hash
debug.traceBlockByHash only accepts hash only accepts hash
debug.intermediateRoots only accepts hash only accepts hash
debug.printBlock only accepts positive ints only accepts positive ints
debug.standardTraceBadBlockToFile accepts hash accepts hash
debug.storageRangeAt only accepts hash only accepts hash
eth.getLogs doesn't accept "pending"/-1 doesn't accept "pending"/-1

Some testcases

// Send a tx first,to trigger at least one clique-sealed block, if in dev-mode

debug.traceCall({from: eth.accounts[0], to: eth.accounts[0], value:"0x1", gasPrice: "0xffffffff", gas: "0xffff"}, "latest")
debug.traceCall({from: eth.accounts[0], to: eth.accounts[0], value:"0x1", gasPrice: "0xffffffff", gas: "0xffff"}, "pending")

debug.traceBlockByNumber("latest")
debug.traceBlockByNumber("pending")

eth.call({from: eth.accounts[0],  input:"0x4360005260206000f3", value:"0x1", gasPrice: "0xffffffff", gas: "0xfffff"},"latest")
//"0x0000000000000000000000000000000000000000000000000000000000000001"
eth.call({from: eth.accounts[0],  input:"0x4360005260206000f3", value:"0x1", gasPrice: "0xffffffff", gas: "0xfffff"},"pending")
//"0x0000000000000000000000000000000000000000000000000000000000000002"


eth.estimateGas({from: eth.accounts[0],  input:"0x4360005260206000f3", value:"0x1", gasPrice: "0xffffffff", gas: "0xfffff"}, "latest")
eth.estimateGas({from: eth.accounts[0],  input:"0x4360005260206000f3", value:"0x1", gasPrice: "0xffffffff", gas: "0xfffff"}, "pending")

eth.getBalance(eth.accounts[0], "latest")
//1.15792089237316195423570985008687907853269984665640564039457583989538129639927e+77
eth.getBalance(eth.accounts[0], "pending")
//1.15792089237316195423570985008687907853269984665640564039457583989538129639927e+7

 eth.getTransactionFromBlock("latest")
 eth.getTransactionFromBlock("pending")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment