Skip to content

RFC-0024 method indices are 2 below @parity/truapi from 0.9.0 (chain_get_chain_info not reserved) #250

Description

@tommyldev

host-api never reserves an index for chain_get_chain_info, so all three RFC-0024 methods sit two discriminants below where
@parity/truapi puts them. Any client on truapi 0.9.0 or later hits the wrong handler.

Measured

Both tables executed from the published packages:

@novasamatech/host-api 0.9.4          @parity/truapi 0.9.0
 164  host_account_sign_vrf            164  ACCOUNT_SIGN_VRF
                                       166  CHAIN_GET_CHAIN_INFO
 166  host_account_register_ring…      168  ACCOUNT_REGISTER_RING_VRF_KEY
 168  host_account_list_ring_vrf_keys  170  ACCOUNT_LIST_RING_VRF_KEYS
 170  host_account_ring_vrf_sign       172  ACCOUNT_RING_VRF_SIGN

host_chain_get_chain_info is absent from hostApiProtocol, and the highest index is 170, so truapi's 172 has nothing to land on.

Effect on a product

The frame is undecodable, so no reply goes back. @parity/truapi/dist/transport.js has no per-call timeout, so the caller's promise
never settles. From the product side an RFC-0024 call just hangs, with no error to read, until the product's own deadline fires. We
spent a while on this because a dropped frame is indistinguishable from a slow host.

Arguably a second bug: a frame that fails to decode should get a MalformedFrame reply rather than nothing.

Fix

packages/host-api/src/protocol/impl.ts, around line 461. Pad two indices onto the first RFC-0024 entry, the same way sign_vrf
already skips the unimplemented coin-payment range:

-  host_account_register_ring_vrf_key: versionedRequest(indexer.request(), {
+  // Prefix 2 reserves 166/167 for `chain_get_chain_info`, which this SDK does
+  // not implement, so the RFC-0024 methods keep the indices truapi assigns them.
+  host_account_register_ring_vrf_key: versionedRequest(indexer.request(2), {

Verified against the local copy:

164  host_account_sign_vrf
168  host_account_register_ring_vrf_key
170  host_account_list_ring_vrf_keys
172  host_account_ring_vrf_sign

Matches truapi 0.9.0 and 0.10.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingteam: novasamaOrigin: Novasama

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions