Skip to content

Commit

Permalink
Added sepolia and localhost deploy script and config. Added storage s…
Browse files Browse the repository at this point in the history
…tate proof and template gate contracts.
  • Loading branch information
Zontec authored and NickVolynkin committed Aug 11, 2023
1 parent f8ddc34 commit 3bd51f0
Show file tree
Hide file tree
Showing 10 changed files with 10,365 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ cmake-build-debug/
# configuration directory with Proof Market credentials
.config

__pycache__/
#hardhat files
deploy/artifacts
deploy/cache
deploy/node_modules
deploy/typechain-types
19 changes: 19 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Deploy

## How to start

Install hardhat by simply typing `npm hardhat install`
When installation is done, compile contracts `npx hardhat compile`
To deploy contracts locally: `npx hardhat deploy` -- script will deploy the gate first, then storage proof verifier with verifier and gate address.
Verifier is hard-set in the script(you can change in manually). Gate deploys first, and then its address is used as input for storage verier.

## Deploy on Sepolia

First, you will need test ETH on the Sepolia network. You can use this (https://sepoliafaucet.com/) faucet or any other you want.

Then you will need your private key that must be inserted in `hardhat.config.ts` file. Do not reveal your private key to anyone!

You will need url. You can use Alchemy, Go to the website https://dashboard.alchemy.com/ and create your application on the Sepolia network. Then derive the HTTPS API key and insert it in `hardhat.config.ts` file.

Then you can deploy on Sepolia using the following command: `npx hardhat deploy --network sepolia`.
Be advised deployment on the test network can be a bit time-consuming.
28 changes: 28 additions & 0 deletions deploy/contracts/IStorageProofVerifier.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: Apache-2.0.
//---------------------------------------------------------------------------//
// Copyright (c) 2023 Ilya Marozau <ilya.marozau@nil.foundation>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//---------------------------------------------------------------------------//
pragma solidity >=0.8.4;

interface IStorageProofVerifier {

event VerificationStatusPositive(bool);

function verifyStorageProof(
bytes calldata _blob,
uint256[] calldata _init_params,
int256[][] calldata _columns_rotations
) external returns (bool result);
}
53 changes: 53 additions & 0 deletions deploy/contracts/StorageProofVerifier.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: Apache-2.0.
//---------------------------------------------------------------------------//
// Copyright (c) 2023 Ilya Marozau <ilya.marozau@nil.foundation>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//---------------------------------------------------------------------------//
pragma solidity >=0.8.4;

import '@nilfoundation/evm-placeholder-verification/contracts/interfaces/verifier.sol';
import "./IStorageProofVerifier.sol";

contract StorageProofVerifier is IStorageProofVerifier {

address verifier;
address owner;
address gate_argument;
constructor(address _verifier, address _gate_argument) {
owner = msg.sender;
verifier = _verifier;
gate_argument = _gate_argument;
}

function setVerifierAddress(address _verifier) public {
require(msg.sender == owner, "Not owner!");
verifier = _verifier;
}

function setGateAddress(address _gate_argument) public {
require(msg.sender == owner, "Not owner!");
gate_argument = _gate_argument;
}

function verifyStorageProof(
bytes calldata _blob,
uint256[] calldata _init_params,
int256[][] calldata _columns_rotations
) external returns (bool result) {

result = IVerifier(verifier).verify(_blob, _init_params, _columns_rotations, gate_argument);

emit VerificationStatusPositive(result);
}
}
220 changes: 220 additions & 0 deletions deploy/contracts/gate/template.sol

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require("@nomicfoundation/hardhat-toolbox");
require('@openzeppelin/hardhat-upgrades');
require("@nomiclabs/hardhat-ethers");

import './tasks/deploy'

module.exports = {
solidity: {
version: "0.8.16",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
hardhat: {
blockGasLimit: 100_000_000,
chainId: 100,
},
localhost: {
url: "http://127.0.0.1:8545",
},
sepolia: {
url: "your url with API key",
accounts: ['0x0000000000000000000000000000000000000000000000000000000000000000']
}
},
allowUnlimitedContractSize:true
};
Loading

0 comments on commit 3bd51f0

Please sign in to comment.