filecoin-project / filecoin-solidity

Filecoin Solidity API Library
Other
17 stars 11 forks source link

Reduce high number of custom nested structs #33

Closed wertikalk closed 9 months ago

wertikalk commented 9 months ago

Description

wertikalk commented 9 months ago

We are discussing ways to approach this.

This is the current state (example taken from MinerAPI.sol):

function minerRawPower(uint64 minerID) internal view returns (int256, PowerTypes.MinerRawPowerReturn memory) {
    bytes memory raw_request = minerID.serialize();

    (int256 exit_code, bytes memory result) = Actor.callByIDReadOnly(PowerTypes.ActorID, PowerTypes.MinerRawPowerMethodNum, Misc.CBOR_CODEC, raw_request);

    if (exit_code == 0) {
        return (0, result.deserializeMinerRawPowerReturn());
    }

    PowerTypes.MinerRawPowerReturn memory empty_res;
    return (exit_code, empty_res);
}

where:

struct MinerRawPowerReturn {
    CommonTypes.BigInt raw_byte_power;
    bool meets_consensus_minimum;
}

The two main issues of replacing custom structs (in the example PowerTypes.MinerRawPowerReturn) with flatten parameters are that:

Soon we will post proposed structs that should be replaced according to their priority.