Transactions weren't sent to the blockchain with rosetta-cli

Hi, guys. The report shows 1092 successful transfer transactions, but why are there no transactions in the blockchain?

rosetta-cli version: v0.5.1
configuration : https://github.com/tronprotocol/tron-rosetta-api/blob/master/rosetta-cli-conf/privatenet/conf.json
check:construction log:

Summary
badger 2020/09/15 18:11:53 INFO: All 0 tables opened in 0s
2020/09/15 18:11:53 construction tester initialized with 0 accounts
2020/09/15 18:11:53 0 Balances Updated
2020/09/15 18:11:53 waiting for first block synced...
2020/09/15 18:11:53 Syncing 780
2020/09/15 18:11:54 processing workflow "transfer"
2020/09/15 18:11:54 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:11:54 processing workflow "create_account"
2020/09/15 18:11:54 processed workflow "create_account" for job "0"
2020/09/15 18:11:54 processing workflow "transfer"
2020/09/15 18:11:54 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:11:54 processing workflow "request_funds"
2020/09/15 18:11:54 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:11:54 processed workflow "request_funds" for job "1"
2020/09/15 18:11:54 processing workflow "request_funds" for job "1"
2020/09/15 18:11:54 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}} on account {"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}
2020/09/15 18:11:54 processing workflow "transfer"
2020/09/15 18:11:54 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:11:54 waiting for available jobs...
2020/09/15 18:11:55 Syncing 781
2020/09/15 18:11:57 Syncing 782
2020/09/15 18:12:02 Syncing 783
[STATS] Transactions Confirmed: 0 (Created: 0, In Progress: 0, Stale: 0, Failed: 0) Addresses Created: 1
2020/09/15 18:12:04 Syncing 784
2020/09/15 18:12:04 processing workflow "request_funds" for job "1"
2020/09/15 18:12:04 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}} on account {"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}
2020/09/15 18:12:05 processing workflow "transfer"
2020/09/15 18:12:05 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:05 waiting for available jobs...
2020/09/15 18:12:06 Syncing 785
2020/09/15 18:12:10 Syncing 786
2020/09/15 18:12:12 Syncing 787
2020/09/15 18:12:15 processing workflow "request_funds" for job "1"
2020/09/15 18:12:15 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}} on account {"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}
2020/09/15 18:12:15 processing workflow "transfer"
2020/09/15 18:12:15 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:15 waiting for available jobs...
2020/09/15 18:12:16 Syncing 788
2020/09/15 18:12:18 Syncing 789
2020/09/15 18:12:22 Syncing 790
2020/09/15 18:12:24 Syncing 791
2020/09/15 18:12:25 processing workflow "request_funds" for job "1"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}} on account {"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}
2020/09/15 18:12:25 processed workflow "request_funds" for job "1"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"319135954"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processing workflow "create_account"
2020/09/15 18:12:25 processed workflow "create_account" for job "2"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"62903250"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processing workflow "create_account"
2020/09/15 18:12:25 processed workflow "create_account" for job "3"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"73434244"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processing workflow "create_account"
2020/09/15 18:12:25 processed workflow "create_account" for job "4"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"843355315"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processing workflow "create_account"
2020/09/15 18:12:25 processed workflow "create_account" for job "5"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"721587677"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processed workflow "transfer" for job "6"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"10259527"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processed workflow "transfer" for job "7"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"615339482"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processed workflow "transfer" for job "8"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"462212208"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processed workflow "transfer" for job "9"
2020/09/15 18:12:25 processing workflow "transfer"
2020/09/15 18:12:25 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:12:25 Message: {"recipient_amount":"243848342"}
2020/09/15 18:12:25 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:12:25 processing workflow "create_account"

......

2020/09/15 18:13:34 processed workflow "transfer" for job "1189"
2020/09/15 18:13:34 processing workflow "transfer"
2020/09/15 18:13:34 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:13:34 Message: {"recipient_amount":"225402622"}
2020/09/15 18:13:34 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:13:34 processed workflow "transfer" for job "1190"
2020/09/15 18:13:34 processing workflow "transfer"
2020/09/15 18:13:34 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:13:34 Message: {"recipient_amount":"832190636"}
2020/09/15 18:13:34 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:13:34 processed workflow "transfer" for job "1191"
2020/09/15 18:13:34 processing workflow "transfer"
2020/09/15 18:13:34 looking for balance {"value":"1000000000","currency":{"symbol":"TRX","decimals":6}}
2020/09/15 18:13:34 Message: {"recipient_amount":"573684135"}
2020/09/15 18:13:34 looking for balance {"value":"0","currency":{"symbol":"TRX","decimals":6}} != to accounts [{"address":"TNmzkEpYV7UuLjggzSCeQU5KfKA58ynFm3"}]
2020/09/15 18:13:34 processed workflow "transfer" for job "1192"

Success: {"create_account":100,"transfer":1000}

+--------------------------+--------------------------------+-------+
| CHECK:CONSTRUCTION STATS |          DESCRIPTION           | VALUE |
+--------------------------+--------------------------------+-------+
| Addresses Created        | # of addresses created         |   100 |
+--------------------------+--------------------------------+-------+
| Transactions Created     | # of transactions created      |     0 |
+--------------------------+--------------------------------+-------+
| Stale Broadcasts         | # of broadcasts missing after  |     0 |
|                          | stale depth                    |       |
+--------------------------+--------------------------------+-------+
| Transactions Confirmed   | # of transactions seen         |     0 |
|                          | on-chain                       |       |
+--------------------------+--------------------------------+-------+
| Failed Broadcasts        | # of transactions that         |     0 |
|                          | exceeded broadcast limit       |       |
+--------------------------+--------------------------------+-------+
+------------------------------+-------+
| CHECK:CONSTRUCTION WORKFLOWS | COUNT |
+------------------------------+-------+
| request_funds                |     1 |
+------------------------------+-------+
| create_account               |   100 |
+------------------------------+-------+
| transfer                     |  1092 |
+------------------------------+-------+

:wave: @Matt.Yue! Sorry for the confusion here. We are actively working on writing some better documentation for automated Construction API testing. I’ve decided to provide some more detail on writing workflows before answering your immediate question. Let me know if you have any other questions in the meantime!

Writing Construction API Workflows

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 process here:

You can find examples of some Workflows here:


This section should be considered “required reading” for anyone working with the automated Construction API tester.

Terminology

When first learning about a new topic, it helps me to understand the “hierarchy” of concerns. In the automated Construction API tester, this “hierarchy” is as follows:

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:

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:

If you have suggestions for more actions, please open an issue in rosetta-sdk-go!

Required Workflows

To use the automated Construction API tester, you must implement 2 required Workflows:

  • create_account
  • request_funds

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” when running the tester (otherwise you would need to manually fund generated accounts): https://github.com/coinbase/rosetta-cli/blob/63d5966476321055b3a81476dde2bc71326d53a8/configuration/configuration.go#L122-L124

We are actively working on supporting a “return funds” Workflow that sends all funds back to a single account during shutdown (so testnet funds aren’t blackholed on each run). You can track progress on that feature here:

Broadcast Fields

If you’d like to broadcast a transaction at the end of a Scenario, you must populate the following fields:

  • <scenario>.network
  • <scenario>.operations
  • <scenario>.confirmation_depth (allows for stake-related transactions to complete before marking as a success)

Optionally, you can populate the following field:

  • <scenario>.preprocess_metadata

Once a transaction is confirmed on-chain (after the provided <scenario>.confirmation_depth, it is stored by the tester at <scenario>.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 <scenario>.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:

  • <scenario>.dry_run = true

If this field is not populated or set to false, the transaction will be constructed, signed, and broadcast.

The suggested fee will then be stored as <scenario>.suggested_fee for use by other Scenarios in the same Job.

Future Work

We are looking to create a DSL to make writing Workflows less cumbersome. If anyone in the community has ideas for this, we are all ears!

Quick Fix

The Construction API tester will only broadcast at the end of a Scenario if you’ve populated <scenario>.operations. In your configuration file, you populate <workflow>.operations.

Fortunately, this is a quick fix! In your config files, you need to change all your transfer.* variable names in the transfer.TransferContract scenario to TransferContract.*.