diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 217d1ede..23a0341a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,52 +2,87 @@ ## Code of Conduct -All interactions with this project follow our [Code of Conduct][code-of-conduct]. -By participating, you are expected to honor this code. Violators can be banned -from further participation in this project, or potentially all Coinbase projects. +All interactions with this project follow our [Code of Conduct](https://github.com/coinbase/code-of-conduct). By participating, you are expected to honor this code. Violators can be banned from further participation in this project, or potentially all Coinbase projects. -[code-of-conduct]: https://github.com/coinbase/code-of-conduct +## How to Contribute -## Bug Reports +You can contribute to this repository by asking questions, providing feedback, and reporting issues. -* Ensure your issue [has not already been reported][1]. It may already be fixed! -* Include the steps you carried out to produce the problem. -* Include the behavior you observed along with the behavior you expected, and - why you expected it. -* Include any relevant stack traces or debugging output. +### Asking Questions -## Feature Requests +Submit your questions via the [Rosetta Community boards][13]. -We welcome feedback with or without pull requests. If you have an idea for how -to improve the project, great! All we ask is that you take the time to write a -clear and concise explanation of what need you are trying to solve. If you have -thoughts on _how_ it can be solved, include those too! +### Providing Feedback + +You can also use the [Rosetta Community boards][13] to provide feedback. + +### Reporting Issues + +You can report issues by submitting bug reports, feature requests, or pull requests via GitHub. You **must** submit [security issues](#security-issues) and [support requests](#support-requests) through the links provided. + +#### Bug Reports + +Before filing a bug report, ensure that your issue [has not already been reported][1]. It may already be fixed! + +If your bug hasn’t been fixed, follow these steps to file a bug report: + +1. [Open an issue in GitHub][10]. +2. Add a title for your bug report. It should briefly describe the problem. +3. Follow the template that appears in the Write text box. This is the best way to describe the bug. +4. Click _Submit new issue_ to finish filing the bug report. + +#### Feature Requests + +We welcome feedback with or without pull requests. If you have an idea for how to improve the project, great! All we ask is that you take the time to write a clear and concise explanation of the need you are trying to solve. If you have thoughts on _how_ it can be solved, include those too! + +To submit a feature request, follow these steps: + +1. [Open an issue in GitHub][10]. +2. Add a title for your feature request. It should briefly describe your requested feature. +3. Follow the template that appears in the Write text box. This is the best way to explain your request. Be clear and concise in your responses. +4. Click _Submit new issue_ to submit the feature request. The best way to see a feature added, however, is to submit a pull request. -## Pull Requests +#### Pull Requests + +Before creating your pull request, it's usually worth asking whether the code you're planning on writing will be considered for merging. You can do this by [opening an issue][1] and asking. It may also help give the maintainers context for when the time comes to review your code. -* Before creating your pull request, it's usually worth asking if the code - you're planning on writing will actually be considered for merging. You can - do this by [opening an issue][1] and asking. It may also help give the - maintainers context for when the time comes to review your code. +Ensure that your [commit messages are well-written][2]. This can double as your pull request message, so it pays to take the time to write a clear message. -* Ensure your [commit messages are well-written][2]. This can double as your - pull request message, so it pays to take the time to write a clear message. +Additionally, make sure that you have written unit tests for your changes. If you're unsure as to what to test, don't hesitate to [open an issue][1] and ask! -* Add tests for your feature. You should be able to look at other tests for - examples. If you're unsure, don't hesitate to [open an issue][1] and ask! +To submit your pull request, follow these steps: -* Submit your pull request! +1. Follow these instructions on how to [open a pull request in GitHub][11]. +2. Click _Create pull request_ to submit your pull request. -## Support Requests +Once you submit your pull request, a reviewer will revise it, and either approve it or offer suggestions. -For security reasons, any communication referencing support tickets for Coinbase -products will be ignored. The request will have its content redacted and will -be locked to prevent further discussion. +#### Security Issues + +You can send a report through Coinbase's [H1 program][12]. Check out the [Security][14] tab for more information. + +#### Support Requests All support requests must be made via [our support team][3]. +**For security reasons, any communication referencing support tickets for Coinbase products will be ignored.** The request will have its content redacted and will be locked to prevent further discussion. + +© 2022 Coinbase + + [1]: https://github.com/coinbase/rosetta-cli/issues [2]: https://chris.beams.io/posts/git-commit/#seven-rules [3]: https://support.coinbase.com/customer/en/portal/articles/2288496-how-can-i-contact-coinbase-support- + +[5]: https://github.com/coinbase/rosetta-cli/issues/new/choose +[6]: https://github.com/coinbase/rosetta-cli/issues/new?assignees=&labels=bug&template=bug_report.md&title= +[7]: https://github.com/coinbase/rosetta-cli/issues/new?assignees=&labels=enhancement&template=feature_request.md&title= +[8]: https://github.com/coinbase/rosetta-cli/pulls +[9]: https://github.com/coinbase/rosetta-cli/compare +[10]: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request#creating-an-issue +[11]: https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request#creating-a-pull-request +[12]: https://hackerone.com/coinbase +[13]: https://community.rosetta-api.org +[14]: https://github.com/coinbase/rosetta-cli/security diff --git a/README.md b/README.md index 20bb7f5e..c3add1ef 100644 --- a/README.md +++ b/README.md @@ -16,569 +16,75 @@ CLI to validate the correctness of Rosetta API implementations

-## Overview -The `rosetta-cli` is used by developers to test the correctness of their Rosetta -API implementations. The CLI also provides the ability to look up block contents -and account balances. +The `rosetta-cli` tool is used by developers to test the correctness of their Rosetta API implementations. The CLI also provides the ability to look up block contents and account balances. -## Documentation -Before diving into the CLI, we recommend taking a look at the Rosetta API Docs: - -* [Overview](https://www.rosetta-api.org/docs/welcome.html) -* [Data API](https://www.rosetta-api.org/docs/data_api_introduction.html) -* [Construction API](https://www.rosetta-api.org/docs/construction_api_introduction.html) +## Installation -## Install To download a binary for the latest release, run: ``` curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s ``` -The binary will be installed inside the `./bin` directory (relative to where the install command was run). +The binary will be installed inside the `./bin` directory (relative to the directory where you ran the installation command). _Downloading binaries from the Github UI will cause permission errors on Mac._ -### Installing in Custom Location +### Installing in a Custom Location To download the binary into a specific directory, run: ``` curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s -- -b ``` -## Usage -``` -CLI for the Rosetta API - -Usage: - rosetta-cli [command] - -Available Commands: - check:construction Check the correctness of a Rosetta Construction API Implementation - check:data Check the correctness of a Rosetta Data API Implementation - configuration:create Create a default configuration file at the provided path - configuration:validate Ensure a configuration file at the provided path is formatted correctly - help Help about any command - utils:asserter-configuration Generate a static configuration file for the Asserter - utils:train-zstd Generate a zstd dictionary for enhanced compression performance - version Print rosetta-cli version - view:balance View an account balance - view:block View a block - view:networks View all network statuses - -Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - -h, --help help for rosetta-cli - --mem-profile string Save the pprof mem profile in the specified file - -Use "rosetta-cli [command] --help" for more information about a command. -``` - -### Configuration -All `rosetta-cli` parameters are populated from a configuration file (`--configuration-file`) -provided at runtime. If a configuration file is not provided, the default -configuration is used. This default configuration can be viewed -[here](examples/configuration/default.json). Note, there is no default -configuration for running `check:construction` as this is very network-specific. -You can view a full list of all configuration options [here](https://pkg.go.dev/github.com/coinbase/rosetta-cli/configuration). - -In the `examples/configuration` directory, you can find examples configuration -files for running tests against a Bitcoin Rosetta implementation -([config](https://github.com/coinbase/rosetta-bitcoin/tree/master/rosetta-cli-conf)) and an Ethereum Rosetta -implementation ([config](https://github.com/coinbase/rosetta-ethereum/tree/master/rosetta-cli-conf)). - -#### Using environment variables - -It's possible to set the configuration file path using an environment variable instead -of using a CLI flag. See an example below: - -```bash -ROSETTA_CONFIGURATION_FILE=/path/to/cli/config rosetta -``` - -CLI flags take precedence over environment variables. - -#### Writing check:construction Tests -The new Construction API testing framework (first released in `rosetta-cli@v0.5.0`) uses -a new design pattern to allow for complex transaction construction orchestration. -You can read more about the design goals [here](https://community.rosetta-api.org/t/feedback-request-automated-construction-api-testing-improvements/146). - -Most teams write their Construction API tests using the -[Rosetta Constructor DSL](https://github.com/coinbase/rosetta-sdk-go/tree/master/constructor/dsl). -We have examples of a DSL files written for [UTXO-based chains](https://github.com/coinbase/rosetta-bitcoin/blob/master/rosetta-cli-conf/testnet/bitcoin.ros) -and [account-based chains](https://github.com/coinbase/rosetta-ethereum/blob/master/rosetta-cli-conf/testnet/ethereum.ros). - -##### Terminology -When first learning about a new topic, it is often useful to understand the -hierarchy of concerns. In the automated Construction API tester, this -"hierarchy" is as follows: -```text -Workflows -> Jobs - Scenarios - Actions -``` - -`Workflows` contain collections of `Scenarios` to execute. `Scenarios` are -executed atomically in database transactions (rolled back if execution fails) -and culminate in an optional broadcast. This means that a single `Workflow` -could contain multiple broadcasts (which can be useful for orchestrating -staking-related transactions that affect a single account). - -To perform a `Workflow`, we create a `Job`. This `Job` has a unique identifier -and stores state for all `Scenarios` in the `Workflow`. State is shared across -an entire `Job` so `Actions` in a `Scenario` can access the output of `Actions` -in other `Scenarios`. The syntax for accessing this shared state can be found -[here](https://github.com/tidwall/gjson/blob/master/SYNTAX.md). - -`Actions` are discrete operations that can be performed in the context of a -`Scenario`. A full list of all `Actions` that can be performed can be found -[here](https://pkg.go.dev/github.com/coinbase/rosetta-sdk-go/constructor/job#ActionType). - -If you have suggestions for more actions, please -[open an issue in `rosetta-sdk-go`](https://github.com/coinbase/rosetta-sdk-go/issues)! - -##### Workflows -To use the automated Construction API tester (without prefunded accounts), -you must implement 2 required `Workflows`: -* `create_account` -* `request_funds` - -_If you don't implement these 2 `Workflows`, processing could stall._ - -Please note that `create_account` can contain a transaction broadcast if -on-chain origination is required for new accounts on your blockchain. - -If you plan to run the automated Construction API tester in CI, you may wish to -provide [`prefunded accounts`](https://pkg.go.dev/github.com/coinbase/rosetta-cli/configuration#ConstructionConfiguration) -when running the tester (otherwise you would need to manually fund generated -accounts). - -Optionally, you can also provide a `return_funds` workflow that will be invoked -when exiting `check:construction`. This can be useful in CI when you want to return -all funds to a single accout or faucet (instead of black-holing them in all the addresses -created during testing). - -##### Broadcast Invocation -If you'd like to broadcast a transaction at the end of a `Scenario`, -you must populate the following fields: -* `.network` -* `.operations` -* `.confirmation_depth` (allows for stake-related transactions to complete before marking as a success) - -Optionally, you can populate the following field: -* `.preprocess_metadata` - -Once a transaction is confirmed on-chain (after the provided -`.confirmation_depth`, it is stored by the tester at -`.transaction` for access by other `Scenarios` in the same `Job`. - -##### Dry Runs -In UTXO-based blockchains, it may be necessary to amend the `operations` stored -in `.operations` based on the `suggested_fee` returned in -`/construction/metadata`. The automated Construction API tester supports -running a "dry run" of a transaction broadcast if you set the follow field: -* `.dry_run = true` - -The suggested fee will then be stored as `.suggested_fee` for use by -other `Scenarios` in the same `Job`. You can find an example of this in the -Bitcoin [config](examples/configuration/bitcoin.json). - -*If this field is not populated or set to `false`, the transaction -will be constructed, signed, and broadcast.* - -#### End Conditions -When running the `rosetta-cli` in a CI job, it is usually desired to exit -when certain conditions are met (or before then with an exit code of 1). We -provide this functionality through the use of "end conditions" which can be -specified in your configuration file. - -##### check:data -A full list of `check:data` end conditions can be found [here](https://pkg.go.dev/github.com/coinbase/rosetta-cli/configuration#DataEndConditions). -If any end condition is satisifed, we will exit and output the -results in `results_output_file` (if it is populated). - -##### check:construction -The `check:construction` end condition is a map of -workflow:count that indicates how many of each workflow -should be performed before `check:construction` should stop. -For example, `{"create_account": 5}` indicates that 5 `create_account` -workflows should be performed before stopping. - -Unlike `check:data`, all `check:construction` end conditions -must be satisifed before the `rosetta-cli` will exit. - -#### Disable Complex Checks -If you are just getting started with your implementation, you may want -to disable balance tracking (did any address balance go below zero?) and -reconciliation (does the balance I calculated match the balance returned -by the `/account/balance` endpoint?). Take a look at the -[simple configuration](examples/configuration/simple.json) for an example of -how to do this. - -#### Status Codes -If there are no issues found while running `check`, it will exit with a `0` status code. -If there are any issues, it will exit with a `1` status code. It can be useful -to run this command as an integration test for any changes to your implementation. - -### Commands -#### version -``` -Print rosetta-cli version - -Usage: - rosetta-cli version [flags] - -Flags: - -h, --help help for version - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` - -#### check:data -``` -Check all server responses are properly constructed, that -there are no duplicate blocks and transactions, that blocks can be processed -from genesis to the current block (re-orgs handled automatically), and that -computed balance changes are equal to balance changes reported by the node. - -When re-running this command, it will start where it left off if you specify -some data directory. Otherwise, it will create a new temporary directory and start -again from the genesis block. If you want to discard some number of blocks -populate the start_index filed in the configuration file with some block index. -Starting from a given index can be useful to debug a small range of blocks for -issues but it is highly recommended you sync from start to finish to ensure -all correctness checks are performed. - -By default, account balances are looked up at specific heights (instead of -only at the current block). If your node does not support this functionality, -you can disable historical balance lookups in your configuration file. This will -make reconciliation much less efficient but it will still work. - -If check fails due to an INACTIVE reconciliation error (balance changed without -any corresponding operation), the cli will automatically try to find the block -missing an operation. If historical balance disabled is true, this automatic -debugging tool does not work. - -To debug an INACTIVE account reconciliation error without historical balance lookup, -set the interesting accounts to the path of a JSON file containing -accounts that will be actively checked for balance changes at each block. This -will return an error at the block where a balance change occurred with no -corresponding operations. - -If your blockchain has a genesis allocation of funds and you set -historical balance disabled to true, you must provide an -absolute path to a JSON file containing initial balances with the -bootstrap balance config. You can look at the examples folder for an example -of what one of these files looks like. - -Usage: - rosetta-cli check:data [flags] - -Flags: - -h, --help help for check:data - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` - -#### check:construction -``` -The check:construction command runs an automated test of a -Construction API implementation by creating and broadcasting transactions -on a blockchain. In short, this tool generates new addresses, requests -funds, constructs transactions, signs transactions, broadcasts transactions, -and confirms transactions land on-chain. At each phase, a series of tests -are run to ensure that intermediate representations are correct (i.e. does -an unsigned transaction return a superset of operations provided during -construction?). - -Check out the https://github.com/coinbase/rosetta-cli/tree/master/examples -directory for examples of how to configure this test for Bitcoin and -Ethereum. - -Right now, this tool only supports transfer testing (for both account-based -and UTXO-based blockchains). However, we plan to add support for testing -arbitrary scenarios (i.e. staking, governance). - -Usage: - rosetta-cli check:construction [flags] - -Flags: - -h, --help help for check:construction - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` - -#### configuration:create -``` -Create a default configuration file at the provided path - -Usage: - rosetta-cli configuration:create [flags] - -Flags: - -h, --help help for configuration:create - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. +## Updates and Releases - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` - -#### configuration:validate -``` -Validate the correctness of a configuration file at the provided path +We recommend that you continually update your installation to the latest release as soon as possible. The latest release notes are available in our [Community](https://community.rosetta-api.org) board under the [Release](https://community.rosetta-api.org/c/releases/13) category. -Usage: - rosetta-cli configuration:validate [flags] +You can also view releases and change log information in the [Releases](https://github.com/coinbase/rosetta-cli/releases) section of this repository. -Flags: - -h, --help help for configuration:validate - -Global Flags: - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. +## Documentation - Any fields not populated in the configuration file will be populated with - default values. -``` +You can find the Rosetta API documentation at [rosetta-api.org](https://www.rosetta-api.org/docs/welcome.html) -#### view:networks -``` -While debugging a Data API implementation, it can be very -useful to view network(s) status. This command fetches the network -status from all available networks and prints it to the terminal. +For more information on the rosetta-cli tool, read our [The rosetta-cli tool](https://www.rosetta-api.org/docs/rosetta_cli.html) documentation. -If this command errors, it is likely because the /network/* endpoints are -not formatted correctly. +For more information on how to test your implementation file with the `rosetta-cli` tool, read our [How to Test Your Rosetta Implementation](https://www.rosetta-api.org/docs/rosetta_test.html) documentation. -Usage: - rosetta-cli view:networks [flags] +Our documentation is divided into the following sections: -Flags: - -h, --help help for view:networks +* [Product Overview](https://www.rosetta-api.org/docs/welcome.html) +* [Getting Started](https://www.rosetta-api.org/docs/getting_started.html) +* [Rosetta API Spec](https://www.rosetta-api.org/docs/Reference.html) +* [Testing](https://www.rosetta-api.org/docs/rosetta_cli.html) +* [Best Practices](https://www.rosetta-api.org/docs/node_deployment.html) +* [Repositories](https://www.rosetta-api.org/docs/rosetta_specifications.html) -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. +## Contributing - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` +You may contribute to the `rosetta-cli` project in various ways: -#### view:balance -``` -While debugging, it is often useful to inspect the state -of an account at a certain block. This command allows you to look up -any account by providing a JSON representation of a types.AccountIdentifier -(and optionally a height to perform the query). - -For example, you could run view:balance '{"address":"interesting address"}' 1000 -to lookup the balance of an interesting address at block 1000. Allowing the -address to specified as JSON allows for querying by SubAccountIdentifier. - -Usage: - rosetta-cli view:balance [flags] - -Flags: - -h, --help help for view:balance - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` +* [Asking Questions](CONTRIBUTING.md/#asking-questions) +* [Providing Feedback](CONTRIBUTING.md/#providing-feedback) +* [Reporting Issues](CONTRIBUTING.md/#reporting-issues) -#### view:block -``` -While debugging a Data API implementation, it can be very -useful to inspect block contents. This command allows you to fetch any -block by index to inspect its contents. It uses the -fetcher (https://github.com/coinbase/rosetta-sdk-go/tree/master/fetcher) package -to automatically get all transactions in the block and assert the format -of the block is correct before printing. - -If this command errors, it is likely because the block you are trying to -fetch is formatted incorrectly. - -Usage: - rosetta-cli view:block [flags] - -Flags: - -h, --help help for view:block - --only-changes Only print balance changes for accounts in the block - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` +Read our [Contributing](CONTRIBUTING.MD) documentation for more information. -#### utils:asserter-configuration -``` -In production deployments, it is useful to initialize the response -Asserter (https://github.com/coinbase/rosetta-sdk-go/tree/master/asserter) using -a static configuration instead of intializing a configuration dynamically -from the node. This allows a client to error on new types/statuses that may -have been added in an update instead of silently erroring. - -To use this command, simply provide an absolute path as the argument for where -the configuration file should be saved (in JSON). - -Usage: - rosetta-cli utils:asserter-configuration [flags] - -Flags: - -h, --help help for utils:asserter-configuration - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` +## rosetta-cli Tool Development -#### utils:train-zstd -``` -Zstandard (https://github.com/facebook/zstd) is used by -rosetta-sdk-go/storage to compress data stored to disk. It is possible -to improve compression performance by training a dictionary on a particular -storage namespace. This command runs this training and outputs a dictionary -that can be used with rosetta-sdk-go/storage. - -The arguments for this command are: - () - -You can learn more about dictionary compression on the Zstandard -website: https://github.com/facebook/zstd#the-case-for-small-data-compression - -Usage: - rosetta-cli utils:train-zstd [flags] - -Flags: - -h, --help help for utils:train-zstd - -Global Flags: - --block-profile string Save the pprof block profile in the specified file - --configuration-file string Configuration file that provides connection and test settings. - If you would like to generate a starter configuration file (populated - with the defaults), run rosetta-cli configuration:create. - - Any fields not populated in the configuration file will be populated with - default values. - --cpu-profile string Save the pprof cpu profile in the specified file - --mem-profile string Save the pprof mem profile in the specified file -``` +While working on improvements to this repository, we recommend that you use these commands to check your code: -## Correctness Checks -This tool performs a variety of correctness checks using the Rosetta Server. If -any correctness check fails, the CLI will exit and print out a detailed -message explaining the error. - -### Response Correctness -The validator uses the autogenerated [Go Client package](https://github.com/coinbase/rosetta-sdk-go) -to communicate with the Rosetta Server and assert that responses adhere -to the Rosetta interface specification. - -### Duplicate Hashes -The validator checks that a block hash or transaction hash is -never duplicated. - -### Non-negative Balances -The validator checks that an account balance does not go -negative from any operations. - -### Balance Reconciliation -#### Active Addresses -The CLI checks that the balance of an account computed by -its operations is equal to the balance of the account according -to the node. If this balance is not identical, the CLI will -exit. - -#### Inactive Addresses -The CLI randomly checks the balances of accounts that aren't -involved in any transactions. The balances of accounts could change -on the blockchain node without being included in an operation -returned by the Rosetta Data API. Recall that all balance-changing -operations should be returned by the Rosetta Data API. - -## Development * `make deps` to install dependencies * `make test` to run tests * `make lint` to lint the source code (included generated code) * `make release` to run one last check before opening a PR * `make compile version=RELEASE_TAG` to generate binaries -If you are developing on both rosetta-cli and rosetta-sdk-go, use [go.mod replace](https://golang.org/ref/mod#go-mod-file-replace) to reference local changes: +If you are developing on both the `rosetta-cli` and `rosetta-sdk-go` repositories, use [go.mod replace](https://golang.org/ref/mod#go-mod-file-replace) to reference local changes: ``` replace "github.com/coinbase/rosetta-sdk-go" v0.6.8 => "../rosetta-sdk-go" ``` ### Helper/Handler -Many of the packages use a `Helper/Handler` interface pattern to acquire -required information or to send events to some client implementation. An example -of this is in the `reconciler` package where a `Helper` is used to get -the account balance and the `Handler` is called to indicate whether the -reconciliation of an account was successful. +Many of the packages use a `Helper/Handler` interface pattern to acquire required information or to send events to some client implementation. An example of this is in the `reconciler` package where a `Helper` is used to get the account balance and the `Handler` is called to indicate whether the reconciliation of an account was successful. ### Repo Structure ``` @@ -590,16 +96,28 @@ pkg tester // test orchestrators ``` -## Troubleshoot -* While running `check:data` or `check:construction` option if you get the following error: +### Troubleshooting - ```dial tcp 127.0.0.1:8080: socket: too many open files: unable to sync to 1902533: unable to sync to 1902533``` +While running the `check:data` or `check:construction` option, if you get the following error: + +```dial tcp 127.0.0.1:8080: socket: too many open files: unable to sync to 1902533: unable to sync to 1902533``` - Please run `ulimit -n 10000` to increase the max concurrent opened file limit +Please run the `ulimit -n 10000` command to increase the max concurrent opened file limit. + +_Note: MacOS users, if you face `ulimit: setrlimit failed: invalid argument` error while setting `ulimit`, please run `sudo launchctl limit maxfiles 10000 200000` before setting the `ulimit`_ + +## Related Projects + +* [`rosetta-sdk-go`][https://github.com/coinbase/rosetta-sdk-go] — The `rosetta-sdk-go` SDK provides a collection of packages used for interaction with the Rosetta API specification. Much of the SDK code is generated from this, the [`rosetta-specifications`](https://github.com/coinbase/rosetta-specifications) repository. +* [`rosetta-specifications`](https://github.com/coinbase/rosetta-specifications) — The `rosetta-specifications` repository generates the SDK code in the [`rosetta-sdk-go`][https://github.com/coinbase/rosetta-sdk-go] repository. + +### Reference Implementations + +To help you with examples, we developed complete Rosetta API reference implementations for [Bitcoin](https://github.com/coinbase/rosetta-bitcoin) and [Ethereum](https://github.com/coinbase/rosetta-ethereum). Developers of Bitcoin-like or Ethereum-like blockchains may find it easier to fork these reference implementations than to write an implementation from scratch. - _Note: MacOS users, if you face `ulimit: setrlimit failed: invalid argument` error while setting `ulimit`, please run `sudo launchctl limit maxfiles 10000 200000` before setting the `ulimit`_ +You can also find community implementations for a variety of blockchains in the [rosetta-ecosystem][https://github.com/coinbase/rosetta-ecosystem] repository, and in the [ecosystem category](https://community.rosetta-api.org/c/ecosystem) of our community site. ## License This project is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). -© 2021 Coinbase +© 2022 Coinbase \ No newline at end of file diff --git a/pkg/results/data_results.go b/pkg/results/data_results.go index e6674094..1c2f98e6 100644 --- a/pkg/results/data_results.go +++ b/pkg/results/data_results.go @@ -498,7 +498,7 @@ func (c *CheckDataTests) Print() { table.Append( []string{ "Reconciliation", - "No balance discrepencies were found between computed and live balances", + "No balance discrepancies were found between computed and live balances", convertBool(c.Reconciliation), }, )