Skip to content

Tolk: originalForwardFee hardcodes workchain 0, breaks on masterchain #1967

@Gusarich

Description

@Gusarich

The InMessage.originalForwardFee accessor hardcodes workchain 0 when calling GETORIGINALFWDFEE, producing incorrect results for contracts deployed on masterchain.

fun onInternalMessage(in: InMessage): coins {
    return in.originalForwardFee;
}

Compiles to:

PROGRAM{
  0 DECLMETHOD onInternalMessage()
  onInternalMessage() PROC:<{  //  in.body
    DROP
    INMSG_BOUNCED
    0 THROWIF
    INMSG_FWDFEE
    0 PUSHINT
    GETORIGINALFWDFEE
  }>
}END>c

The GETORIGINALFWDFEE instruction requires the workchain to compute the original fee based on that chain's fee configuration. Masterchain (workchain -1) has significantly higher fees than basechain (workchain 0).

A contract on masterchain using in.originalForwardFee will receive basechain fee calculations instead, causing incorrect fee accounting and potentially under-reserving funds for message forwarding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions