Assessment reports>Nocturne>Discussion>Gas tokens can be identified by index in Operation

Gas tokens can be identified by index in Operation

In an Operation, the token used to pay back the bundler for gas is identified as an EncodedAsset encodedGasAsset, which must match one of the trackedAssets because it will be unwrapped after the actions run:

struct Operation {
    PublicJoinSplit[] pubJoinSplits;
    JoinSplit[] confJoinSplits;
    CompressedStealthAddress refundAddr;
    TrackedAsset[] trackedAssets;
    Action[] actions;
    EncodedAsset encodedGasAsset;
    uint256 gasAssetRefundThreshold;
    uint256 executionGasLimit;
    uint256 gasPrice;
    uint256 deadline;
    bool atomicActions;
}

In a PublicJoinSplit, the asset that the joinsplit points at is referred to using an index uint8 assetIndex:

struct PublicJoinSplit {
    JoinSplit joinSplit;
    uint8 assetIndex; // Index in op.joinSplitAssets
    uint256 publicSpend;
}

Instead of having to decode the encoded gas asset and compare that against each tracked asset, it would simplify the Operation struct and save gas to just specify the index of the gas asset.

Zellic © 2024Back to top ↑