Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validTransition in NitroAdjudicator #86

Open
andrewgordstewart opened this issue Jul 24, 2019 · 2 comments
Open

validTransition in NitroAdjudicator #86

andrewgordstewart opened this issue Jul 24, 2019 · 2 comments

Comments

@andrewgordstewart
Copy link
Contributor

In order to validate transitions from the client wallet, the NitroAdjudicator should expose Rules.validTransition.

The naive method

    function validTransition(
        Commitment.CommitmentStruct memory agreedCommitment,
        Commitment.CommitmentStruct memory challengeCommitment
    ) public pure returns (bool) {
        return Rules.validTransition(agreedCommitment, challengeCommitment);
    }

seems to require an infinite amount of gas to deploy. I've managed to exceed 8 000 000 000 -- the gas limit on mainnet is currently around 8 000 000.

Setting the gas limit to a googol causes the migrations script to fail silently, perhaps due to truffle or ganache not properly handling numbers greater than 2^256.

The following method, with an unused Signature[] memory argument, works, requiring ~6500000 gas

    function validTransition(
        Commitment.CommitmentStruct memory agreedCommitment,
        Commitment.CommitmentStruct memory challengeCommitment,
        Signature[] memory unusedArg
    ) public pure returns (bool) {
        return Rules.validTransition(agreedCommitment, challengeCommitment);
    }

The following method, with an unused uint[] memory argument also uses at least 8 billion gas:

    function validTransition(
        Commitment.CommitmentStruct memory agreedCommitment,
        Commitment.CommitmentStruct memory challengeCommitment,
        uint[] memory unusedArg
    ) public pure returns (bool) {
        return Rules.validTransition(agreedCommitment, challengeCommitment);
    }

I thought perhaps any array of an arbitrary user-defined struct would work, but this one also uses at least 8 billion gas.

    struct SimpleStruct {
        bool flag;
    }

    function validTransition(
        Commitment.CommitmentStruct memory agreedCommitment,
        Commitment.CommitmentStruct memory challengeCommitment,
        SimpleStruct[] memory unusedArg
    ) public pure returns (bool) {
        return Rules.validTransition(agreedCommitment, challengeCommitment);
    }
@andrewgordstewart
Copy link
Contributor Author

andrewgordstewart commented Jul 24, 2019

Note that in order to allow more gas usage in contract deployments, you need to both

  • increase the gasLimit when you start ganache, which sets the block gas limit of the network
  • increase the gas config option in truffle, which sets how much gas is sent with a transaction by truffle deploys

I patched my local version of magmo-devtools to increase the gasLimit to 8000000000, and also set it to an obscenely high number.

@andrewgordstewart
Copy link
Contributor Author

andrewgordstewart commented Jul 24, 2019

I've recorded a couple of the above examples in the solidity-bug branch. Note that the block-gas-limit is the default truffle/ganache value of 6721975. Deploying the TestNitroAdjudicator does use almost that much gas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant