Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Add send_transaction2 support #8

Merged
merged 15 commits into from
Aug 8, 2022

Conversation

NatPDeveloper
Copy link
Contributor

@NatPDeveloper NatPDeveloper commented Aug 6, 2022

Change Description

Support Issue #5
Related: eosnetworkfoundation/product#30

  • Added support for /v1/chain/send_transaction2.
  • Added rpc unit test for /v1/chain/send_transaction2.
  • Added text-encoding as dev dependency in package.json to run unit tests.
  • Update api.transaction to include options for retrying transaction
  • Add error if server_version_string below v3.1.0
  • Update GetInfoResult type with latest returned results
  • Added retry transaction for node.test.ts

API Changes

  • added returnFailureTrace option, default false
  • added retryIrreversible option, default false
  • added retryTrxNumBlocks option, default 0
  • added useOldRPC option, default false
  • added useOldSendRPC option, default false

Documentation Additions

  • added documentation to the README.md file for 5 new API parameters.

@ericpassmore
Copy link
Contributor

Hi Nat, this is good thank you for submitting. I was actually working on the same based on your medium post, and not as far along. I am taking a look now.

@ericpassmore
Copy link
Contributor

ericpassmore commented Aug 6, 2022

one ask, can we better align with cleos send_transaction calling patterns? Specifically my ask is to include useOldSendRPC flag to transact. We can add a retry_irreversible later.

@NatPDeveloper
Copy link
Contributor Author

Hm looks like the wires got crossed there. Perhaps you can do a diff check with https://www.diffchecker.com/ and share the link for the various files you see being changed.

Yes I agree it should match cleos. In the meantime I'll try updating what parts I can piece together.

@ericpassmore
Copy link
Contributor

Here is the diff
https://www.diffchecker.com/9MErjwI0

@NatPDeveloper
Copy link
Contributor Author

NatPDeveloper commented Aug 6, 2022

Okay great, I added that as well as the irreversible feature, let me know what your thoughts are.

I also update the PR notes at the top to reflect removing the retryTrx option to match up with cleos.

I initially made the example in the README to use irreversible blocking by default, but in the days of dfuse 3 handoffs was considered pretty guaranteed. So perhaps (12 blocks per round * 3 handoffs) = 36 blocks so could potentially use 30 as the default instead of blocking for 3 minutes (12 blocks per round * 15 handoffs for 15/21).

Also to consider is that the default maximum amount of blocks for the nodeos to allow to retry is 90 blocks, so irreversible trx retries will cause the following error:

{
  code: 500,
  message: 'Internal Service Error',
  error: {
    code: 3040006,
    name: 'tx_exp_too_far_exception',
    what: 'Transaction Expiration Too Far',
    details: [
  {
    message: 'retry transaction expiration 2022-08-04T19:08:16 larger than allowed 2022-08-04T19:06:48',
    file: 'chain_plugin.cpp',
    line_number: 2304,
    method: 'send_transaction2'
  }
]
  }
}

@ericpassmore
Copy link
Contributor

Exciting stuff, thanks for the quick turnaround. I did a quick check and it looks good. I want to go back and closer look at irreversible updates in cleos code for comparison.

@NatPDeveloper
Copy link
Contributor Author

NatPDeveloper commented Aug 7, 2022

I've added a change to not use the retry feature by default and to return the failure trace by default to also match cleos.

cleos --print-request -u http://$NODEOS push action eosio.token transfer '["heliosselene","uuddlrlrbass","0.0001 EOS",""]' -p heliosselene
...
POST /v1/chain/send_transaction2 HTTP/1.0
Host: 3.91.147.242:8888
content-length: 467
Accept: */*
Connection: close

{
  "return_failure_trace": true,
  "retry_trx": false,
  "transaction": {
    "signatures": [
      "SIG_K1_KAH8gQeK74FP3RU53C5bNrFk6DZGRzeHMPX4bJnJFZaiRpgMRvzerEfTCFXdDbWQN2sTnbp2GyTJAz3qocyFW5T3m2Qvt6"
    ],
    "compression": "none",
    "packed_context_free_data": "",
    "packed_trx": "47e6ef6216849415f736000000000100a6823403ea3055000000572d3ccdcd01a0a68a0a63eaa26a00000000a8ed323221a0a68a0a63eaa26a80b13937de9892d6010000000000000004454f53000000000000"
  }
}
---------------------
executed transaction: 21ae7ccc96b342a61cd151cedd75281922416b632d6d4ef1ca33bbf3a5f4721c  128 bytes  229 us
#   eosio.token <= eosio.token::transfer        {"from":"heliosselene","to":"uuddlrlrbass","quantity":"0.0001 EOS","memo":""}
#  heliosselene <= eosio.token::transfer        {"from":"heliosselene","to":"uuddlrlrbass","quantity":"0.0001 EOS","memo":""}
#  uuddlrlrbass <= eosio.token::transfer        {"from":"heliosselene","to":"uuddlrlrbass","quantity":"0.0001 EOS","memo":""}
warning: transaction executed locally, but may not be confirmed by the network yet         ] 

Also some community feedback from Aaron of Greymass: https://t.me/c/1139062279/312536

@ericpassmore ericpassmore self-assigned this Aug 8, 2022
@ericpassmore ericpassmore added the enhancement New feature or request label Aug 8, 2022
@ericpassmore ericpassmore linked an issue Aug 8, 2022 that may be closed by this pull request
@@ -85,6 +85,51 @@ const transactWithoutBroadcast = async () => await api.transact({
blocksBehind: 3,
expireSeconds: 30,
});

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll add in a test for the old_send_rpc path. These new tests are good, thanks for adding them.

@@ -105,6 +105,14 @@ export interface GetInfoResult {
virtual_block_net_limit: number;
block_cpu_limit: number;
block_net_limit: number;
server_version_string: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed , thanks

}
if(retryTrxNumBlocks > 0) {
params = {
...params,
Copy link
Contributor

Choose a reason for hiding this comment

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

irreversible well done

@ericpassmore ericpassmore merged commit 251beab into eosnetworkfoundation:main Aug 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for send_transaction2
2 participants