This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
forked from dapperlabs/flow-rosetta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from foundryservices/wait
Wait
- Loading branch information
Showing
6 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
*.cdc | ||
*.checkpoint | ||
*.log | ||
flow-go/ | ||
flow-go/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,99 @@ | ||
# flow-rosetta | ||
forked from [dapperlabs/flow-rosetta](https://github.com/dapperlabs/flow-rosetta) | ||
|
||
## Description | ||
|
||
The Flow Rosetta Server implements the Rosetta Data API specifications for the Flow network. | ||
It uses the Flow DPS Server's GRPC API as the backend to query the required data. | ||
Flow core contract addresses are derived from the chain ID with which the service is started. | ||
This allows the Rosetta API to access state remotely, or locally by running the Flow DPS Server on the same host. | ||
|
||
## Dependencies | ||
|
||
Go `v1.16` or higher is required to compile `flow-dps-rosetta`. | ||
Only Linux amd64 builds are supported, because of the dependency to the [`flow-go/crypto`](https://github.com/onflow/flow-go/tree/master/crypto) package. | ||
|
||
In order to build the live binary, the following extra steps and dependencies are required: | ||
|
||
* [`CMake`](https://cmake.org/install/) | ||
|
||
Please note that the flow-go repository should be cloned into this projects directory with its default name, so that the Go module replace statement works as intended: `replace github.com/onflow/flow-go/crypto => ./flow-go/crypto`. | ||
|
||
* `git clone [email protected]:onflow/flow-go.git` | ||
* `cd flow-go/crypto` | ||
* `git checkout v0.21.4` | ||
* `go generate` | ||
|
||
You can then verify that the installation of the flow-go crypto package has been successful by running the tests of the project. | ||
|
||
## Testing | ||
|
||
The Flow system model, where resources can be moved freely between accounts without generating events, makes it impossible to fully reconcile account balances on the Rosetta Data API. | ||
As a consequence, balance reconciliation has to be disabled when running the Rosetta CLI against the Flow Rosetta Server. | ||
|
||
Additionally, some of the events generated by Flow are not accurately reflecting the account address they relate to. | ||
This is also due to the same resource-based smart contract programming model. | ||
For instance, when an account receives vaults from different locations to execute a swap of tokens, the events related to this swap might indicate the swap | ||
contract's address, as it uses volatile vaults. | ||
|
||
Currently, the only way to work around this issue is to create exemptions for accounts which contain such smart contracts. | ||
As account balances using non-standard approaches to transfer Flow tokens can already not be reconciled, this is an acceptable limitation. | ||
In general, transactions by Rosetta should not be used to deduce account balances. | ||
Full historical account balance lookup is available and should thus be prefered to determine the account balance at any block height. | ||
|
||
The discussed configuration is available in the `flow.json` and `exemptions.json` files for the `mainnet-9` spork DPS. | ||
The following command can be executed to validate the Data API for that spork: | ||
|
||
```sh | ||
rosetta-cli check:data --configuration-file flow.json | ||
``` | ||
|
||
## Usage | ||
|
||
```sh | ||
Usage of flow-rosetta-server: | ||
-a, --api string host URL for GRPC API endpoint (default "127.0.0.1:5005") | ||
-e, --cache uint maximum cache size for register reads in bytes (default 1073741824) | ||
-l, --level string log output level (default "info") | ||
-p, --port uint16 port to host Rosetta API on (default 8080) | ||
-t, --transaction-limit int maximum amount of transactions to include in a block response (default 200) | ||
--smart-status-codes enable smart non-500 HTTP status codes for Rosetta API errors | ||
``` | ||
## Example | ||
The following command line starts the Flow Rosetta server for a main network spork on port 8080. | ||
It uses a local instance of the Flow DPS Server for access to the execution state. | ||
```sh | ||
./flow-rosetta-server -a "127.0.0.1:5005" -p 8080 | ||
``` | ||
## Architecture | ||
The Rosetta API needs its own documentation because of the amount of components it has that interact with each other. | ||
The main reason for its complexity is that it needs to interact with the Flow Virtual Machine (FVM) and to translate between the Flow and Rosetta application domains. | ||
### Invoker | ||
This component, given a Cadence script, can execute it at any given height and return the value produced by the script. | ||
[Package documentation](https://pkg.go.dev/github.com/optakt/flow-dps-rosetta/service/invoker) | ||
### Retriever | ||
The retriever uses the other components to retrieve account balances, blocks and transactions. | ||
[Package documentation](https://pkg.go.dev/github.com/optakt/flow-dps-rosetta/service/retriever) | ||
### Scripts | ||
The script package produces Cadence scripts with the correct imports and storage paths, depending on the configured Flow chain ID. | ||
[Package documentation](https://pkg.go.dev/github.com/optakt/flow-dps-rosetta/service/scripts) | ||
### Validator | ||
The Validator component validates whether the given Rosetta identifiers are valid. | ||
[Package documentation](https://pkg.go.dev/github.com/optakt/flow-dps-rosetta/service/validator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters