Readme
To upgrade TG version - use exact git commit. For example:
go get -u github.com/ledgerwatch/turbo-geth@213cf2cbec5792c9b23ab3c3ffa7f1b662d4188e
Run (this assumes turbo-geth is running on the same machine with option --private.api.addr 127.0.0.1:9090
):
go run . --private.api.addr 127.0.0.1:9090 --http.api example
alternatively
make
./project-1 --private.api.addr 127.0.0.1:9090 --http.api example
Docs: https://github.com/ledgerwatch/turbo-geth/blob/master/cmd/rpcdaemon/Readme.md
The custom method is called example_localFork
.
The input consists of 3 paramters (params
):
- Block number (or "latest" to use the latest available block) after which the execution will be applied
- Array of unsigned transactions. Each transaction has fields
from
,to
,gas
(hex number in quotes),value
(in wei, hex number in quotes),nonce
(hex value in quotes),input
(hex value in quotes). The fieldto
can be omitted, which means it is contract-creating transaction. The fieldnonce
can be ommitted, in which case the correctness of the nonce is not checked. - Array of queries (the same input as for
eth_call
). A query has the same fields, except fornonce
.
The output is the object with two fields txResults
, and queryResults
:
- The field
txResults
contains an array, with the same number of elements as the second input (transactions) has. Each element in thetxResults
corresponds to the transaction in the input. Each element has fieldsUsedGas
,Err
, andReturnData
. FieldsErr
andReturnData
can havenull
values. - The field
queryResults
contains an array, with the same number of elements as the second input (transactions) has. Each element in thetxResults
corresponds to the transaction in the input. Each element has fieldsUsedGas
,Err
, andReturnData
. FieldsErr
andReturnData
can havenull
values. - The field
blockNumber
returns a number equal to the block number at which the transactions and queries were executed.
Input
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"example_localFork", "params": ["latest", [
{"from": "0x0000000000000000000000000000000000000000", "gas": "0x100000", "gasPrice": "0x1000", "value": "0x34000", "nonce": "0x0", "input": ""},
{"from": "0x0000000000000000000000000000000000000000", "gas": "0x100000", "gasPrice": "0x1000", "value": "0x34000", "nonce": "0x1", "input": ""}
], [
{"from": "0x0000000000000000000000000000000000000000", "gas": "0x100000", "gasPrice": "0x1000", "value": "0x34000", "input": ""},
{"from": "0x0000000000000000000000000000000000000000", "gas": "0x100000", "gasPrice": "0x1000", "value": "0x34000", "input": ""}
]], "id":1}' localhost:8545
Output
{"jsonrpc":"2.0","id":1,"result":{"txResults":[{"UsedGas":53000,"Err":null,"ReturnData":null},{"UsedGas":53000,"Err":null,"ReturnData":null}],"queryResults":[{"UsedGas":53000,"Err":null,"ReturnData":null},{"UsedGas":53000,"Err":null,"ReturnData":null}]}}