Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Feature request - Fetch code_hash without the entire ABI #4222

Closed
nsjames opened this issue Jun 19, 2018 · 12 comments
Closed

Feature request - Fetch code_hash without the entire ABI #4222

nsjames opened this issue Jun 19, 2018 · 12 comments

Comments

@nsjames
Copy link
Contributor

nsjames commented Jun 19, 2018

Some ABIs are massive ( system for instance is 1.3mb ) and take a good 1-3 seconds to fetch.
If there was a way to fetch only the hash of the contract without the rest of the ABI it would allow signature providers a way to cache ABIs locally and only re-cache if the code hash changes.

eosjs doesn't propagate the code abi to the signature provider so it has to be double fetched ( once for eosjs and once for the signature app ) to parse data and retrieve ricardian contracts which adds between 2 - 6 seconds per contract from the moment a user clicks a button to sign to the time the transaction parameters + ricardians can be displayed to them.

@nsjames
Copy link
Contributor Author

nsjames commented Jun 19, 2018

image

@nsjames
Copy link
Contributor Author

nsjames commented Jun 19, 2018

Actually seeing as how getting only the hash is supported in cleos, I'm moving this ticket to eosjs itself for support there.

EOSIO/eosjs#206

@nsjames nsjames closed this as completed Jun 19, 2018
@nsjames
Copy link
Contributor Author

nsjames commented Jun 20, 2018

Reopening as it seems the RPC doesn't have an option for code_hash only
https://github.com/EOSIO/eos/blob/master/plugins/chain_plugin/chain_plugin.cpp#L952

@nsjames nsjames reopened this Jun 20, 2018
@jcalfee
Copy link
Contributor

jcalfee commented Jun 20, 2018

Did you see this: #566

Looks like get_abi was added about 2 weeks ago.. so that will help greatly. I was foced to fetch code and the ABI at the same time. I'll update to use get_abi on this ticket.

It will not tell me if it was modified though so I will have to keep re-fetching..

@jcalfee jcalfee self-assigned this Jun 20, 2018
@nsjames
Copy link
Contributor Author

nsjames commented Jun 20, 2018

Yeah I saw that one last night too, which is massively faster than get_code, but doesn't include the hash :(

@jcalfee
Copy link
Contributor

jcalfee commented Jun 21, 2018

I suggest adding abi_hash:

   fc::sha256 abi_hash;

Then add optional<abi_hash> abi_hash to get_abi's parameters and result:

   struct get_abi_params {
      name account_name;
      optional<abi_hash> abi_hash;
   };

   struct get_abi_results {
      name                   account_name;
      optional<abi_def>      abi;
      optional<abi_hash>     abi_hash;
   };
  • The abi_hash is the sha256 hash of the binary abi_def serialization
  • If an ABI exists for the account its hash is always returned.
  • If a hash was provided in the request and it matches the current ABI, the ABI hash is returned but the abi is not.
  • If a hash was provided in the request and the ABI does not exist (was probably removed) neither hash nor ABI are returned.

@taokayan
Copy link
Contributor

Can you get it once then store the result somewhere else? As code and abi are not frequently changed?

@nsjames
Copy link
Contributor Author

nsjames commented Aug 25, 2018

@tbfleming

@tbfleming tbfleming mentioned this issue Aug 25, 2018
@ScottSallinen
Copy link
Contributor

For getting just the code hash, see this PR:
#5434

@jcalfee
Copy link
Contributor

jcalfee commented Sep 4, 2018

Great .. I'll have it in eosjs for the next release.

@tbfleming
Copy link
Contributor

@jcalfee I added your abi_hash caching idea to #5375's get_raw_abi

@jgiszczak
Copy link
Contributor

The get_code_hash API has been available since the v1.3.0 release on 2018 September 18.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants