-
Notifications
You must be signed in to change notification settings - Fork 175
Specify blockchain testing methods in RPC #4
Comments
Similarities:
|
Testeth filling process (for "state tests"):
|
Some proposals from the call with @karalabe @winsvega @pirapira @cdetrio:
|
Current work in progress changes from @winsvega (ethereum/aleth#4859):
Also a more detailed list for all the methods porposed by @winsvega: https://github.com/ethereum/retesteth/issues |
the method formats are not final. |
We'd like to propose the following spec which I believe is a superset of all if not most of the functionality exposed by the endpoints so far discussed in this issue. Use cases which are explicitly intended to be supported.
Existing JSON-RPC endpointsThe Anything like normal transaction sending, reading account balances or storage can and should still be done over the traditional endpoints. Endpoints
|
@axic @winsvega we've been discussing the above interface with @pipermerriam yesterday. This spec doesn't allow concurrent chains and does overwrite the current chain of the node (so it requires a custom flag to start). The benefit however is that it reuses the same RPC interface as everything else uses. That might be a good idea long term since we would have constant regression tests against the RPC, opposed to testing via an isolated API. I'd still like to retain some ability to run potentially multiple chains in the same binary. Perhaps we could add some form of |
Speaking of different chains. Another way is to start two instances of a client with different configs and ask one client to provide a block then import it into another. I am currently fixing existing state tests and developing a minimum set of rpc methods required to fill a state test. the state test format will be slightly changed. some fields from env section might not be needed. after this I plan to rework blockchain test filling through RPC. |
The issue with starting instances is the long boot time. Maybe it's "just" 2-3 seconds, but if you want to run repeating tests, those will add up. Would be imho nicer not to have to spin up entire processes all the time. The only two options I see it is:
A further problem with starting multiple processes is that then you either start a new process for each test to make it clean (but that's what hive does already, so there's no point); or you make some chain run in the host process and start secondary chains in new processes, but that will just be a sync/setup nightmare. I think we need to handle all test chains uniformly, so either all in the same process, or all in separate processes. My fav for now is launching RPC endpoints. |
I was thinking to start different RPC. so multiple clients with multiple RPC sockets at the same time running tests in paralel. A setChainParams called once per test. if the config is not changed then rewindBlock method is used to disable transactions. There should be options to optimize it. like use memoryDB for chain. starting the chain faster. We have hive, but we don't have testeth anymore. |
In Parity this isn't really how we do testing at all, which is why we don't have any test RPCs what-so-ever yet. I think the main worry from us is exposing test-stuff to the mainnet, so we'd probably try to hide these behind a compiler-flag so the default build doesn't include it at all. The question then beyond that is just what we can do without significantly changing the codebase. We don't really want to code in a backdoor to skip block validation unless we can be 100% sure it can be excluded or at least isolated in such a way that we can guarantee that it can't be exploited. Asked @tomusdrw about this and his off-the-top-of-his-head response was:
With the additional comment that This is all sort of speculation though until we actually try to do it. |
(cc @benjamincburns @seesemichaelj: we should follow along here for Ganache) |
With the availability of various test tools, different methods for accomplishing the same testing features were implemented.
cpp-ethereum (complete list):
test_setChainParams(genesis)
- resets the blockchain to the provided genesistest_mineBlocks(n)
- minen
blockstest_modifyTimestamp(time)
- change timestamptest_addBlock(block)
test_rewindToBlock(number)
- revert to the block numbergo-ethereum (complete list and probably outdated here):
admin_importChain(path-to-file)
- Imports the blockchain from a marshalled binary format. Note that the blockchain is reset (to genesis) before the imported blocks are inserted to the chain.admin_exportChain(path-to-file)
- Exports the blockchain to the given file in binary format.admin_sleepBlocks(n)
- Sleeps for n blocks.debug_setHead(number)
- Sets the current head of the blockchain to the block referred to by blockNumber.It has a lot more under
debug
.parity:
?
testrpc:
evm_snapshot
: Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created.evm_revert
: Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. If no snapshot id is passed it will revert to the latest snapshot. Returns true.evm_increaseTime
: Jump forward in time. Takes one parameter, which is the amount of time to increase in seconds. Returns the total time adjustment, in seconds.evm_mine
: Force a block to be mined. Takes no parameters. Mines a block independent of whether or not mining is started or stopped.It would be nice defining a common set implemented by the clients.
The text was updated successfully, but these errors were encountered: