Skip to content

Commit 18d2a17

Browse files
authored
fix: address issues (#773)
Please be sure to look over the pull request guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr. # Please go through the following checklist - [x] The PR title and commit messages adhere to guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md. In particular `!` is used if and only if at least one breaking change has been introduced. - [x] I have run the ci check script with `source scripts/run_ci_checks.sh`. - [x] I have run the clean commit check script with `source scripts/check_commits.sh`, and the commit history is certified to follow clean commit guidelines as described here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/COMMIT_GUIDELINES.md - [x] The latest changes from `main` have been incorporated to this PR by simple rebase if possible, if not, then conflicts are resolved appropriately. # Rationale for this change We need to address the following issues. <!-- Why are you proposing this change? If this is already explained clearly in the linked issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. Example: Add `NestedLoopJoinExec`. Closes #345. Since we added `HashJoinExec` in #323 it has been possible to do provable inner joins. However performance is not satisfactory in some cases. Hence we need to fix the problem by implement `NestedLoopJoinExec` and speed up the code for `HashJoinExec`. --> # What changes are included in this PR? - add to docs for plan name skipping with respect to what is returned - fix typo in Doc - replace `mulmod` with `mul` in `make_transcript` <!-- There is no need to duplicate the description in the ticket here but it is sometimes worth providing a summary of the individual changes in this PR. Example: - Add `NestedLoopJoinExec`. - Speed up `HashJoinExec`. - Route joins to `NestedLoopJoinExec` if the outer input is sufficiently small. --> # Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? Example: Yes. --> N/A.
2 parents a8e21f9 + e2292b0 commit 18d2a17

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

solidity/src/base/Errors.sol

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ uint32 constant ERR_INVALID_EC_ADD_INPUTS = 0x765bcba0;
88
uint32 constant ERR_INVALID_EC_MUL_INPUTS = 0xe32c7472;
99
/// @dev Error code for when ECPAIRING inputs are invalid.
1010
uint32 constant ERR_INVALID_EC_PAIRING_INPUTS = 0x4385b511;
11+
/// @dev Error code for commitment array having odd length which is impossible
12+
/// since each commitment is 2 elements.
13+
uint32 constant ERR_COMMITMENT_ARRAY_ODD_LENGTH = 0x88acadef;
1114
/// @dev Error code for when the size of a sumcheck proof is incorrect.
1215
uint32 constant ERR_INVALID_SUMCHECK_PROOF_SIZE = 0x3f889a17;
1316
/// @dev Error code for when the evaluation of a round in a sumcheck proof does not match the expected value.
@@ -58,6 +61,9 @@ library Errors {
5861
error InvalidECMulInputs();
5962
/// @notice Error thrown when the inputs to the ECPAIRING precompile are invalid.
6063
error InvalidECPairingInputs();
64+
/// @notice Error code for commitment array having odd length which is impossible
65+
/// since each commitment is 2 elements.
66+
error CommitmentArrayOddLength();
6167
/// @notice Error thrown when the size of a sumcheck proof is incorrect.
6268
error InvalidSumcheckProofSize();
6369
/// @notice Error thrown when the evaluation of a round in a sumcheck proof does not match the expected value.

solidity/src/proof_exprs/ProofExpr.pre.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ library ProofExpr {
3131
/// length equal to the columns in the expression
3232
/// ##### Return Values
3333
/// * `expr_ptr_out` - pointer to the remaining expression after consuming the proof expression
34-
/// * `eval` - the evaluation of the result of this expression. Cirically, this resulting evaluation must be guarenteed to be
34+
/// * `eval` - the evaluation of the result of this expression. Critically, this resulting evaluation must be guarenteed to be
3535
/// the correct evaluation of a column with the same length as the columns in the expression. Every column has implicit infinite length
3636
/// but is padded with zeros. This is guarenteed to match the length of the chi column, and varients must be designed to handle this.
3737
/// ##### Proof Plan Encoding

solidity/src/verifier/PlanUtil.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ library PlanUtil {
2525
/// @dev * length of output column name (uint64)
2626
/// @dev * output column name (variable length)
2727
/// @param __plan The calldata pointer to the plan.
28-
/// @return __planOut The updated pointer after skipping names.
28+
/// @return __planOut The updated pointer after skipping names which points to the actual plan itself. i.e., the AST without any names.
2929
function __skipPlanNames(bytes calldata __plan) external pure returns (bytes calldata __planOut) {
3030
assembly {
3131
function skip_plan_names(plan_ptr) -> plan_ptr_out {

solidity/src/verifier/Verifier.pre.sol

+5-2
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ library Verifier {
454454
append_array(transcript_ptr, table_lengths_ptr)
455455

456456
let commitment_len := mload(commitments_ptr)
457-
mstore(commitments_ptr, mulmod(commitment_len, 2, MODULUS))
457+
mstore(commitments_ptr, mul(commitment_len, 2))
458458
append_array(transcript_ptr, commitments_ptr)
459459
mstore(commitments_ptr, commitment_len)
460460

@@ -519,7 +519,10 @@ library Verifier {
519519
verify_result_evaluations(result_ptr, evaluation_point_ptr, evaluations_ptr)
520520
}
521521

522-
mstore(__commitments, div(mload(__commitments), 2))
522+
// Revert if the commitments array has an odd length
523+
let commitments_len := mload(__commitments)
524+
if mod(commitments_len, 2) { err(ERR_COMMITMENT_ARRAY_ODD_LENGTH) }
525+
mstore(__commitments, div(commitments_len, 2))
523526
verify_query(__result.offset, __plan.offset, __proof.offset, __tableLengths, __commitments)
524527
}
525528
}

solidity/test/base/Errors.t.sol

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ contract ErrorsTest is Test {
2727
Errors.__err(ERR_INVALID_EC_PAIRING_INPUTS);
2828
}
2929

30+
/// forge-config: default.allow_internal_expect_revert = true
31+
function testErrorCommitmentArrayOddLength() public {
32+
assert(Errors.CommitmentArrayOddLength.selector == bytes4(ERR_COMMITMENT_ARRAY_ODD_LENGTH));
33+
vm.expectRevert(Errors.CommitmentArrayOddLength.selector);
34+
Errors.__err(ERR_COMMITMENT_ARRAY_ODD_LENGTH);
35+
}
36+
3037
/// forge-config: default.allow_internal_expect_revert = true
3138
function testErrorInvalidSumcheckProofSize() public {
3239
assert(Errors.InvalidSumcheckProofSize.selector == bytes4(ERR_INVALID_SUMCHECK_PROOF_SIZE));

0 commit comments

Comments
 (0)