You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The automatic JSON RPC server and client from foundation rely on a ClassConverter object, which requires classes to be (de)serialised to be registered. Classes are indexed by the class object itself.
However, it can be the case that the same classes is loaded from different instances of the same module. We hit this error with PrivateKey: while the type registered in the aztec_rpc_client is exported from the circuits.js, an instance of the PrivateKey from the types package (which re-exports PrivateKey) is the one that gets sent.
This would be ok if aztec.js and types loaded the same circuits.js from node_modules, but it can be the case that each package keeps its own copy of the dependency. If that happens, they are considered different modules, so each PrivateKey class is not the same. So the lookup in the converter fails.
The end result is that the PrivateKey is serialised incorrectly, so it is deseralised incorrectly on the other side, and the RPC server carries on execution with an incorrect type, which never gets validated because of #1819.
The text was updated successfully, but these errors were encountered:
… name (#1820)
Prevents from accidentally passing an unregistered class in the
autogenerated JSON RPC client and server. Picks the converter to use for
serialisation based on constructor name if function equality match fails
(since constructor name match may fail in minimised browser bundles).
We were bit by this when the `PrivateKey` class was registered in the
client, but due to a duplicated module, the `PrivateKey` class
registered was not the same as the one passed as an argument. This
caused the object not to be properly serialised, which due to #1819 was
not picked up on the server side, and caused all sort of issues.
Fixes#1826
---------
Co-authored-by: spypsy <[email protected]>
The automatic JSON RPC server and client from foundation rely on a
ClassConverter
object, which requires classes to be (de)serialised to be registered. Classes are indexed by the class object itself.However, it can be the case that the same classes is loaded from different instances of the same module. We hit this error with
PrivateKey
: while the type registered in theaztec_rpc_client
is exported from thecircuits.js
, an instance of thePrivateKey
from thetypes
package (which re-exportsPrivateKey
) is the one that gets sent.aztec-packages/yarn-project/aztec.js/src/aztec_rpc_client/aztec_rpc_client.ts
Line 1 in 94053e4
aztec-packages/yarn-project/aztec.js/src/account/account.ts
Line 2 in 94053e4
This would be ok if
aztec.js
andtypes
loaded the samecircuits.js
fromnode_modules
, but it can be the case that each package keeps its own copy of the dependency. If that happens, they are considered different modules, so eachPrivateKey
class is not the same. So the lookup in the converter fails.The end result is that the
PrivateKey
is serialised incorrectly, so it is deseralised incorrectly on the other side, and the RPC server carries on execution with an incorrect type, which never gets validated because of #1819.The text was updated successfully, but these errors were encountered: