The wire format for a TokenMessage is a packed binary encoding of these fields, followed by base64url encoding.
Pact needs to provide a builtin for decoding such an encoded message into its original form, to support the larger SPI scheme. This PR implements that builtin, named hyperlane-decode-token-message. It also provides a convenience function for encoding a TokenMessage, useful for testing.
The results are: 2 microseconds for a 256-byte message, 11 microseconds for an 10880-byte message, 21 microseconds for a 21548-byte message.
400 MilliGas = 1 microsecond by policy. 10k bytes = 10 microseconds by benchmarks. 100 bytes = 0.1 microseconds = 40 MilliGas. We round up to 50 MilliGas as a safety buffer.
PR checklist:
[x] Test coverage for the proposed changes
[x] PR description contains example output from repl interaction or a snippet from unit test output
[ ] Documentation has been updated if new natives or FV properties have been added. To generate new documentation, issue cabal run tests. If they pass locally, docs are generated.
Part of the SPI interface is a
TokenMessage
: a tuple of a recipient, and amount, and a chain id:The wire format for a
TokenMessage
is a packed binary encoding of these fields, followed by base64url encoding.Pact needs to provide a builtin for decoding such an encoded message into its original form, to support the larger SPI scheme. This PR implements that builtin, named
hyperlane-decode-token-message
. It also provides a convenience function for encoding aTokenMessage
, useful for testing.Usage:
Todo:
Gas analysis:
The following code was used to benchmark decoding:
The results are: 2 microseconds for a 256-byte message, 11 microseconds for an 10880-byte message, 21 microseconds for a 21548-byte message.
400 MilliGas = 1 microsecond by policy. 10k bytes = 10 microseconds by benchmarks. 100 bytes = 0.1 microseconds = 40 MilliGas. We round up to 50 MilliGas as a safety buffer.
PR checklist:
cabal run tests
. If they pass locally, docs are generated.pact -t
), make sure pact-lsp is in sync.Additionally, please justify why you should or should not do the following: