Skip to content

Commit

Permalink
full deployment to xdai
Browse files Browse the repository at this point in the history
  • Loading branch information
Peiyuan Liao committed Aug 27, 2021
1 parent e025944 commit 44e95e6
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ eth/.ipynb_checkpoints/demo-checkpoint.ipynb
artifacts/src/Circuits/lr/lr.zkey
*.pyc
eth/keys/ipfs.json
eth/keys/.private_key
76 changes: 37 additions & 39 deletions eth/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 52,
"id": "0f0c2061",
"id": "e798537c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -13,7 +13,7 @@
{
"cell_type": "code",
"execution_count": 53,
"id": "c699576a",
"id": "250368b6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -23,7 +23,7 @@
{
"cell_type": "code",
"execution_count": 38,
"id": "7fa3cca3",
"id": "e8725e26",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -33,7 +33,7 @@
{
"cell_type": "code",
"execution_count": 71,
"id": "041cc00f",
"id": "010e9bcb",
"metadata": {},
"outputs": [
{
Expand All @@ -54,7 +54,7 @@
{
"cell_type": "code",
"execution_count": 72,
"id": "952643af",
"id": "f031ccdb",
"metadata": {},
"outputs": [
{
Expand All @@ -81,7 +81,7 @@
},
{
"cell_type": "markdown",
"id": "54dd3e5f",
"id": "43548867",
"metadata": {},
"source": [
"Command:\n",
Expand All @@ -94,7 +94,7 @@
{
"cell_type": "code",
"execution_count": 73,
"id": "f5c6f46c",
"id": "3c714321",
"metadata": {},
"outputs": [
{
Expand All @@ -112,7 +112,7 @@
{
"cell_type": "code",
"execution_count": 74,
"id": "bbfeffc1",
"id": "45c6c4d2",
"metadata": {},
"outputs": [
{
Expand All @@ -130,7 +130,7 @@
{
"cell_type": "code",
"execution_count": 75,
"id": "cb89c402",
"id": "357ec3f3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -144,7 +144,7 @@
{
"cell_type": "code",
"execution_count": 76,
"id": "d99c0b92",
"id": "7416c7ba",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -155,7 +155,7 @@
{
"cell_type": "code",
"execution_count": 77,
"id": "786753dd",
"id": "b5cb3f00",
"metadata": {},
"outputs": [
{
Expand All @@ -176,7 +176,7 @@
{
"cell_type": "code",
"execution_count": 78,
"id": "e5474855",
"id": "20aa8eed",
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -208,7 +208,7 @@
{
"cell_type": "code",
"execution_count": 79,
"id": "72e13ead",
"id": "e0703a4a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -226,7 +226,7 @@
{
"cell_type": "code",
"execution_count": 80,
"id": "ec00edb2",
"id": "d9e6a1b1",
"metadata": {},
"outputs": [
{
Expand All @@ -250,7 +250,7 @@
{
"cell_type": "code",
"execution_count": 81,
"id": "42e8e502",
"id": "3dfa7523",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -292,7 +292,7 @@
},
{
"cell_type": "markdown",
"id": "d0d8e977",
"id": "e799c5bb",
"metadata": {},
"source": [
"Command:\n",
Expand All @@ -305,7 +305,7 @@
{
"cell_type": "code",
"execution_count": 82,
"id": "379310bc",
"id": "e3c9457d",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -336,7 +336,7 @@
},
{
"cell_type": "markdown",
"id": "b5576cf4",
"id": "53ba4c5b",
"metadata": {},
"source": [
"Command:\n",
Expand All @@ -348,8 +348,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "d386771e",
"execution_count": 83,
"id": "f336bf75",
"metadata": {},
"outputs": [
{
Expand All @@ -366,7 +366,16 @@
"INFO: OK!\n",
"Paying 0x2546BcD3c84621e976D8185a91A922aE77ECEc30\n",
"With balance\n",
"10850.6\n"
"10850.6\n",
"Your Public Key: \n",
"[\n",
" \u001b[33m1700643759997457569245863490312877944508569018329107232774239121212875587628n\u001b[39m,\n",
" \u001b[33m12432032059012451124939976221853806268790884588923275757468717217243035579610n\u001b[39m\n",
"]\n",
"Your Private Key: \n",
"\u001b[33m16643980665868843823629143933455494516978640287615526294342242121812095812996n\u001b[39m\n",
"Current Balance\n",
"10899.6\n"
]
}
],
Expand All @@ -376,22 +385,16 @@
},
{
"cell_type": "code",
"execution_count": 30,
"id": "932a6851",
"execution_count": 84,
"id": "e3378ec5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Available bounties on dataset: dataset\r\n",
"[\r\n",
" {\r\n",
" \u001b[32m'publickey-1'\u001b[39m: \u001b[32m'7740372084585987155484008265620943144342913409804205385745482832325610494802'\u001b[39m,\r\n",
" \u001b[32m'publickey-2'\u001b[39m: \u001b[32m'13432246653756375231286144066765295473357154911140864565409792325468570091416'\u001b[39m,\r\n",
" \u001b[32m'MSE-Cap'\u001b[39m: \u001b[32m'18406'\u001b[39m\r\n",
" }\r\n",
"]\r\n"
"Available bounties on dataset: 14797455496207951391356508759149962584765968173479481191220882411966396840571\n",
"[]\n"
]
}
],
Expand All @@ -401,21 +404,16 @@
},
{
"cell_type": "code",
"execution_count": 31,
"id": "60cc9372",
"execution_count": 85,
"id": "cbc40c5d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Available datasets:\r\n",
"[\r\n",
" [\r\n",
" \u001b[32m'dataset'\u001b[39m,\r\n",
" \u001b[32m'14797455496207951391356508759149962584765968173479481191220882411966396840571'\u001b[39m\r\n",
" ]\r\n",
"]\r\n"
"[]\r\n"
]
}
],
Expand Down
40 changes: 17 additions & 23 deletions eth/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ task("balance", "Prints an account's balance")
});

task("list_bounties", "List bounties given dataset")
.addParam("walletprivatekey", "wallet private key", "./keys/.private_key")
.addParam("hash", "Dataset hash", "14797455496207951391356508759149962584765968173479481191220882411966396840571")
.setAction(async (taskArgs) => {
const fs = require("fs");
const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
const contract = await BountyManagerV2.attach(CONTRACT_ADDRESS);
const provider = new hre.ethers.providers.JsonRpcProvider();
const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const write_contract = contract.connect(wallet);
Expand All @@ -59,15 +58,14 @@ task("list_bounties", "List bounties given dataset")
});

task("list_datasets", "List of datasets with alias")
.addParam("walletprivatekey", "wallet private key", "./keys/.private_key")
.setAction(async (taskArgs) => {
const fs = require("fs");
const provider = new hre.ethers.providers.JsonRpcProvider();
const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);
const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
const contract = await BountyManagerV2.attach(CONTRACT_ADDRESS);

const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const write_contract = contract.connect(wallet);
Expand All @@ -81,10 +79,9 @@ task("list_datasets", "List of datasets with alias")
task("remove_bounty", "Remove bounty without claiming")
.addParam("hash", "Dataset hash", "14797455496207951391356508759149962584765968173479481191220882411966396840571")
.addParam("publickey", "bounty issuer's publilckey", "./keys/out_public.json")
.addParam("walletprivatekey", "wallet private key", "./keys/.private_key")
.addParam("mse", "mse cap, quantized", "18406")
.setAction(async (taskArgs) => {
const provider = new hre.ethers.providers.JsonRpcProvider();
const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);
const fs = require("fs");
const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
Expand All @@ -94,7 +91,7 @@ task("remove_bounty", "Remove bounty without claiming")
pubKey[0] = BigInt(pubKey[0]);
pubKey[1] = BigInt(pubKey[1]);

const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const write_contract = contract.connect(wallet);
Expand All @@ -115,9 +112,8 @@ task("remove_bounty", "Remove bounty without claiming")
});

task("claim_bounty", "Claim bounty")
.addParam("payment", "payment address", "0x2546BcD3c84621e976D8185a91A922aE77ECEc30")
.addParam("payment", "payment address", "0xd3162F2B88d05C882a1B26031E144753337ACDBF")
.addParam("publickey", "bounty issuer's publilckey", "./keys/out_public.json")
.addParam("walletprivatekey", "wallet private key", "./keys/.private_key")
.addParam("model", "model path", "./model")
.addParam("dataset", "dataset path", "./dataset")
.addParam("settings", "settings", "settings.json")
Expand Down Expand Up @@ -285,12 +281,12 @@ task("claim_bounty", "Claim bounty")
arg2 = [proof.pi_c[0], proof.pi_c[1]];
arg3 = publicSignals;

const provider = new hre.ethers.providers.JsonRpcProvider();
const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);
const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
const contract = await BountyManagerV2.attach(CONTRACT_ADDRESS);

const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const write_contract = contract.connect(wallet);
Expand Down Expand Up @@ -331,13 +327,12 @@ task("claim_bounty", "Claim bounty")
task("download_dataset", "download dataset")
.addParam("hash", "Dataset hash", "14797455496207951391356508759149962584765968173479481191220882411966396840571")
.addParam("publickey", "bounty issuer's publilckey", "./keys/out_public.json")
.addParam("walletprivatekey", "wallet private key", "./keys/.private_key")
.addParam("mse", "mse cap, quantized", "18406")
.addParam("path", "save path", "./ipfs_dataset")
.setAction(async (taskArgs) => {
console.log("Downloading from IPFS to " + taskArgs.path + " ...");
const provider = new hre.ethers.providers.JsonRpcProvider();

const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);
const fs = require("fs");
const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
Expand All @@ -347,7 +342,7 @@ task("download_dataset", "download dataset")
pubKey[0] = BigInt(pubKey[0]);
pubKey[1] = BigInt(pubKey[1]);

const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const write_contract = contract.connect(wallet);
Expand Down Expand Up @@ -389,9 +384,8 @@ task("download_dataset", "download dataset")
});

task("add_bounty", "Deposit bounty")
.addParam("amount", "amount to add to bounty", "49")
.addParam("amount", "amount to add to bounty", "0.001")
.addParam("keyfile", "file prefix to export private and public key", "out")
.addParam("walletprivatekey", "private key", "./keys/.private_key")
.addParam("dataset", "dataset path", "./dataset")
.addParam("settings", "settings", "settings.json")
.setAction(async (taskArgs) => {
Expand Down Expand Up @@ -498,13 +492,13 @@ task("add_bounty", "Deposit bounty")
() => {},
);

const provider = new hre.ethers.providers.JsonRpcProvider();
const provider = new hre.ethers.providers.JsonRpcProvider(process.env.URL);

const BountyManagerV2 = await hre.ethers.getContractFactory('BountyManagerV2');
const CONTRACT_ADDRESS = fs.readFileSync('./artifacts/.env_contract', 'utf-8');
const contract = await BountyManagerV2.attach(CONTRACT_ADDRESS);

const wallet_raw = new hre.ethers.Wallet(fs.readFileSync(taskArgs.walletprivatekey, 'utf-8'));
const wallet_raw = new hre.ethers.Wallet(process.env.PRIVATE_KEY);
const wallet = wallet_raw.connect(provider);

const ipfs = require('ipfs-http-client')
Expand Down Expand Up @@ -587,8 +581,8 @@ module.exports = {
hardhat: {
initialBaseFeePerGas: 0, // workaround from https://github.com/sc-forks/solidity-coverage/issues/652#issuecomment-896330136 . Remove when that issue is closed.
},
ropsten: {
url: process.env.ROPSTEN_URL || "",
xdai: {
url: process.env.URL || "",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
Expand Down
1 change: 0 additions & 1 deletion eth/keys/.private_key

This file was deleted.

Loading

0 comments on commit 44e95e6

Please sign in to comment.