-
Notifications
You must be signed in to change notification settings - Fork 7
Description
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);
}