Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework signal handling #189

Merged
merged 30 commits into from
May 12, 2022
Merged

Conversation

oschwaldp-oci
Copy link
Contributor

@oschwaldp-oci oschwaldp-oci commented May 6, 2022

Rework signal handling to handle transactions as they are received

Currently, transactions are accumulated till the block state is accepted and the accumulated transactions are sent along with the block state to be handled. This is a problem because when a user calls the send_transaction api, it will take till the speculative block is aborted and the next block is applied before all the transactions are then recorded. This means that if the user tries to immediately get the status of the transaction, it will get back “UNKNOWN” till the transaction is finally processed (up to 500 ms later).

Integration test work

Added integration tests to verify calls to get_transaction_status for a known transaction progressed from "APPLIED_LOCALLY" to "IN_BLOCK" to "IRREVERSIBLE" and then, after passing the success duration, returning "UNKNOWN". Also added a test to verify that get_transaction_status reported the correct status when a transaction's block was forked out.

Issue Resolution

Also resolves Issue: #176

curl -sd '{"id": "240ed958f05b672f9d15bdb332a49fa9e53715ec18272649b951d8f91bfb23e7"}' http://localhost:8888/v1/chain/get_transaction_status | jq
{
  "state": "IN_BLOCK",
  "block_number": 84,
  "block_id": "0000005492ae08787b46c6cc07852fc9391be887dd79e980bcd9245a574c9f56",
  "block_timestamp": "2022-05-06T15:34:17.500",
  "expiration": "2022-05-06T15:34:47.000",
  "head_number": 326,
  "head_id": "00000146f7df7ece3967526f35bcafcf5ae090fbfca208910f20eab73a03efa6",
  "head_timestamp": "2022-05-06T15:36:18.500",
  "irreversible_number": 23,
  "irreversible_id": "0000001727b6d94facf760a323a943ccfe9249224fecce23c402c1f66d09df20",
  "irreversible_timestamp": "2022-05-06T15:33:47.000",
  "earliest_tracked_block_id": "000000110b2a85d157470bfbba56802db4bbad616c0959027d27bd18cdb0d9f1",
  "earliest_tracked_block_number": 17
}

curl -sd '{"id": "00"}' http://localhost:8888/v1/chain/get_transaction_status | jq
{
  "code": 400,
  "message": "Invalid Request",
  "error": {
    "code": 3200006,
    "name": "invalid_http_request",
    "what": "invalid http request",
    "details": [
      {
        "message": "Invalid transaction id",
        "file": "chain_api_plugin.cpp",
        "line_number": 62,
        "method": "parse_params<eosio::chain_apis::read_only::get_transaction_status_params>"
      }
    ]
  }
}
curl -sd '' http://localhost:8888/v1/chain/get_transaction_status | jq
{
  "code": 400,
  "message": "Invalid Request",
  "error": {
    "code": 3200006,
    "name": "invalid_http_request",
    "what": "invalid http request",
    "details": [
      {
        "message": "A Request body is required",
        "file": "chain_api_plugin.cpp",
        "line_number": 54,
        "method": "parse_params<eosio::chain_apis::read_only::get_transaction_status_params>"
      }
    ]
  }
}

Copy link
Contributor

@jgiszczak jgiszczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitting review prematurely because Github has decided to stop displaying my comments in line, for some reason.

I did stop calling out all individual instances of strings which should be converted to f-strings, and also stopped calling out individual instances of assert being used incorrectly. All such changes should still be made.

tests/Node.py Outdated Show resolved Hide resolved
tests/Node.py Outdated Show resolved Hide resolved
tests/Node.py Outdated Show resolved Hide resolved
tests/Node.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_test.py Show resolved Hide resolved
tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
postInfo = None
transferAmount=10

# ensuring that prod0's producer is active, which will give sufficient time to identify the transaction as "LOCALLY_APPLIED" before it travels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may give sufficient time, assuming the efficiency of net_plugin doesn't considerably improve.

We should probably come up with a way to label tests like this which are non-deterministic to tell us where to look first if automated tests get flaky in the future.

tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_forked_test.py Outdated Show resolved Hide resolved
Remove unnecessary signals_processor and route everything directly to the trx_finality_status_processing handler.
@tedcahalleos tedcahalleos assigned larryk85 and unassigned larryk85 May 10, 2022
tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
tests/trx_finality_status_test.py Outdated Show resolved Hide resolved
tests/Node.py Outdated Show resolved Hide resolved
@brianjohnson5972 brianjohnson5972 merged commit 649b2aa into main May 12, 2022
@brianjohnson5972 brianjohnson5972 deleted the enfs-78-pwo-rework-signal-handling branch May 12, 2022 04:03
@heifner heifner added the OCI OCI working this issue... label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI OCI working this issue...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants