stacks-blockchain-api icon indicating copy to clipboard operation
stacks-blockchain-api copied to clipboard

Rosetta API validation with rosetta-cli

Open fdmirza opened this issue 5 years ago • 10 comments

Is your feature request related to a problem? Please describe. We are working on implementation of rosetta-apis. For validation of req/res, we are using rosetta-cli. When I start the validation of data API with check:data command, I need to make some transactions (send_token, deploy_contract etc) for the rosetta-cli to confirm the responses and reconciliation of account balances. For making the transactions, I am using commands from cli-blockstack, and executing them using child_process in my test-injections. Is it possible to use the code functions from cli-blockstack directly in this project to make transaction or it has to be done via CLI commands executions for now?

gist: https://gist.github.com/fdmirza/bc8bb206a3c1540a154ece230c5cbfb0

fdmirza avatar Aug 26 '20 11:08 fdmirza

Yes, you should be able to write tests within this repo that use similar code to those in cli-blockstack js commands from that script. There are already similar usages with fetch and the stacks-transactions.js lib to interact with the core node.

zone117x avatar Aug 26 '20 22:08 zone117x

@fdmirza I setup a test suite for rosetta in this PR https://github.com/fariedt/stacks-blockchain-api/pull/2, and left a related comment here https://github.com/blockstack/stacks-blockchain-api/pull/221#issuecomment-685775942.

I think the rosetta-cli should probably be ran within docker like the other services. Let me know if you need any help configuring that.

zone117x avatar Sep 02 '20 14:09 zone117x

Some additional guidance on how I think the rosetta-cli should be used for testing:

Now that latest Rosetta PR includes a jest test suite for end-to-end rosetta testing, I think rosetta-cli should be ran either A) within jest, or B) as a new package.json script. E.g. npm run test:rosetta-cli.

The test should be runnable locally and not operating system dependent. For example, it shouldn't require linux or the golang toolchain. I think a new dockerfile might be the best approach.

zone117x avatar Sep 08 '20 14:09 zone117x

@zone117x Created a new dockerfile and running rosetta-cli within container. I am having trouble is figuring out the end conditions. Rosetta-cli config has json field for end-conditions where we can specify index (block-height upto which we want validation), tip (when the tip is reached, specify tip_delay), and reconciliation (float takes 0.0 to 1.0). Please guide me what makes more sense to you that what it should have as ending conditions. Also, for my test transactions I do some STX transfer transactions, contract deploy and call contract functions in my ts test file. I notice that some (1 or 2) of the transactions fails during the process due to BadNonce and it happens at random in no particular order. I tried adding some delays in the transactions but that didn't help. Any thoughts on it? Thanks

fdmirza avatar Sep 10 '20 22:09 fdmirza

Also, for my test transactions I do some STX transfer transactions, contract deploy and call contract functions in my ts test file. I notice that some (1 or 2) of the transactions fails during the process due to BadNonce and it happens at random in no particular order. I tried adding some delays in the transactions but that didn't help. Any thoughts on it? Thanks

Await for the next block to allow nonce to increment. For example like this: https://github.com/blockstack/stacks-blockchain-api/blob/2afc27c43e53b20913b29f7dc99ae758a5d756de/src/tests-rosetta/api.ts#L138-L140

Please guide me what makes more sense to you that what it should have as ending conditions.

Are there examples of good rosetta end-conditions from bitcoin and ethereum implementations?

zone117x avatar Sep 11 '20 11:09 zone117x

@zone117x In examples of ethereum and bitcoin it uses "end_conditions": { "reconciliation_coverage": 0.95 }

https://github.com/coinbase/rosetta-cli/blob/master/examples/configuration/ethereum.json#L175

fdmirza avatar Sep 11 '20 11:09 fdmirza

Can we do something similar for our end-conditions?

zone117x avatar Sep 11 '20 11:09 zone117x

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 16 '21 23:03 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 14 '21 01:09 stale[bot]

Related to rosetta maintenance work, cc @rafaelcr

zone117x avatar Sep 14 '21 12:09 zone117x

Closing as not under maintenance.

smcclellan avatar Jul 21 '23 15:07 smcclellan