Skip to content

v0 offchain message size checks exclude the preamble #1726

@mcintyre94

Description

@mcintyre94

Overview

Found while looking into offchain-messages as part of the signOffchainMessage feature. We've decided to make that only support v1 transactions, so I'm just opening this as a bug. Doesn't block that feature because v1 doesn't enforce a max size in the spec.

Description of bug

The checks for max size in eg

export function assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent: {
have checks like:

const length = getUtf8Encoder().getSizeFromValue(putativeContent.text);
if (length > MAX_BODY_BYTES_HARDWARE_WALLET_SIGNABLE)

That is, they are only checking the length of the text content against the maximum.

The offchain message spec specifies size limits as "Combined length of the message preamble and message body"

The kit functions should throw if the size of the text is smaller than the limit, but the size of the text + preamble is larger than the limit. This is not currently the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions