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

Refactor the contract according to V1 consolidation spec #178

Merged

Conversation

alxkzmn
Copy link
Contributor

@alxkzmn alxkzmn commented Nov 3, 2023

No description provided.

sifnoc and others added 3 commits November 3, 2023 13:04
* feat: create bash script for updating verifier interface files in backend

* fix: error propagation with try operator; remove unnecessaries

* refactor: changed data type in 'MstInclusionProof'

* fix: generate solvency verifier contract

* chore: remove left over

* chore: update README

* fix: remove left over; assert term

* fix: update README; small fixes

* feat: Signer accepts address or file path for init

event AddressOwnershipProofSubmitted(
AddressOwnershipProof[] addressOwnershipProofs
);
event SolvencyProofSubmitted(
uint256 indexed timestamp,
uint256 mstRoot,
Asset[] assets
uint256 rootSum,
Asset assets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is no longer an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we're now having a single asset per tree per the new specs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roll back to multi-assets as discussed privately

Asset asset;
}

//User inclusion proof verifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

@@ -77,6 +90,7 @@ contract Summa is Ownable {
);
uint256 index = ownershipProofByAddress[addressHash];
require(index == 0, "Address already verified");
//Offsetting the index by 1 to distinguish with the case when the proof hasn't been submitted (the storage slot would be zero)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

@@ -255,113 +242,85 @@ describe("Summa Contract", () => {
const calldata: any = JSON.parse(jsonData);

mstRoot = calldata.public_inputs[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will no longer have solvency_proof_solidity_calldata.json and its generator script in the future. How do you think we should modify the flow accordingly? One suggestion that I have is to modify the gen_inclusion_verifier.rs example with generate_mst_commitment.rs that outputs something like commitment_calldata.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea.

});

it("should verify the proof of inclusion for the given public input", async () => {
await summa.submitProofOfAddressOwnership(ownedAddresses);
await submitProofOfSolvency(summa, mstRoot, solvencyProof);
await submitCommitment(summa, mstRoot, rootSum);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that there's a security issue here. You hardcode rootSum as 10000000 when sending the commitment. But this is not the correct root sum associated with mstRoot. To fix that, the ProofOfInclusion should also output the rootSum as public output and the verification function should check that it matches the committed one

});

describe("verify proof of inclusion", () => {
let mstRoot: BigNumber;
let rootSum: BigNumber;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot comment on the right line but solvencyProof should no longer exist here

@enricobottazzi enricobottazzi linked an issue Nov 6, 2023 that may be closed by this pull request
contracts/src/Summa.sol Outdated Show resolved Hide resolved
contracts/src/Summa.sol Outdated Show resolved Hide resolved
* @param timestamp The timestamp at which the CEX took the snapshot of its assets and liabilities
*/
function submitProofOfSolvency(
function submitCommitment(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should check that Asset amount is greater than rootSums

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in private discussion

@enricobottazzi enricobottazzi self-requested a review November 8, 2023 13:26
Copy link
Member

@sifnoc sifnoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@enricobottazzi enricobottazzi merged commit 19dcb54 into summa-dev:v1-improvements-and-consolidation Nov 8, 2023
2 checks passed
@enricobottazzi enricobottazzi mentioned this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

contracts V1 updates
3 participants