eosnetworkfoundation / mandel-eosjs

Official Javascript Library for Working with EOS Blockchain
Other
22 stars 6 forks source link

Add send_transaction2 support #8

Closed NatPDeveloper closed 2 years ago

NatPDeveloper commented 2 years ago

Change Description

Support Issue #5 Related: https://github.com/eosnetworkfoundation/product/pull/30

API Changes

Documentation Additions

ericpassmore commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

NatPDeveloper commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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