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

SRI milestone 5 #824

Merged
merged 124 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
3306c53
Create Ccsm.sol contract
biscuitdey Jun 20, 2024
e2176bd
Add setAnchorHash function
biscuitdey Jun 20, 2024
8987510
Add getAnchorHash function
biscuitdey Jun 20, 2024
fbb9cf7
Fix formatting
biscuitdey Jun 20, 2024
779ad91
add develop branch to bri-3.yml file
ognjenkurtic Jun 25, 2024
4651530
Add access control to contract
biscuitdey Jun 30, 2024
239b8d5
Bug fix
biscuitdey Jun 30, 2024
52ed45d
Updated etherjs packages
biscuitdey Jun 30, 2024
c3d3633
Remove unnecesary files
biscuitdey Jun 30, 2024
2827151
Revert "Remove unnecesary files"
biscuitdey Jun 30, 2024
31da6f3
Fix hardhat dependency
biscuitdey Jun 30, 2024
128732a
Fix imports
biscuitdey Jun 30, 2024
a9be4f0
Add Workstep2 artifacts
biscuitdey Jun 30, 2024
80f6aa7
Add Workstep3 artifacts
biscuitdey Jun 30, 2024
4e2ac90
Merge branch 'develop' into feature/797-create-smart-contract
biscuitdey Jul 1, 2024
3b4687f
Bug fix
biscuitdey Jul 1, 2024
e727269
Merge pull request #798 from ethereum-oasis-op/feature/797-create-sma…
biscuitdey Jul 1, 2024
f56d12c
Remove unnecessary params from prepareInputs call in circuitService i…
ognjenkurtic Jun 23, 2024
5a766d0
MOve prepareInputs to transaction agent level as preparation for refa…
ognjenkurtic Jun 23, 2024
6f3f399
Refactor circuit input preparation to split public and payload inputs
ognjenkurtic Jun 25, 2024
bf17f4d
Use circuitInputsParserService in tx agent to prep inputs WIP
ognjenkurtic Jun 25, 2024
ae51812
Introduce parsing of arrays of objects to cirucit input parser
ognjenkurtic Jun 27, 2024
16c6bec
Extend the e2e test to use a mapping to translate tx payload into cir…
ognjenkurtic Jun 27, 2024
02e5224
Refactor trasaction agent executeTransaction method for better readab…
ognjenkurtic Jun 28, 2024
f64347d
Fix formatting
ognjenkurtic Jun 28, 2024
0373142
Update hardhat config
biscuitdey Jul 9, 2024
88b21bd
Compile ccsm contract using hardhat
biscuitdey Jul 9, 2024
9f4ef0f
Add string verification in the ccsm contract
biscuitdey Jul 9, 2024
ad1dc90
Add alchemy connection env values
biscuitdey Jul 9, 2024
463fd49
Add ccsm interface
biscuitdey Jul 9, 2024
8b10506
Add ethereum service for ccsm interface
biscuitdey Jul 9, 2024
0464d30
Add config options
biscuitdey Jul 9, 2024
22bcc4c
Add workstep2 execution to e2e test
ognjenkurtic Jul 4, 2024
919c975
Add workstep3 execution to e2e test
ognjenkurtic Jul 4, 2024
febb9be
Fix wrong workstep reference when adding schema to workstep3 in the e…
ognjenkurtic Jul 4, 2024
aae1e2d
Introduce correct from and to accounts in e2e test workste 2 and 3
ognjenkurtic Jul 8, 2024
0e8fead
Fix formatting
ognjenkurtic Jul 8, 2024
accb6f0
Fix typo in e2e test name
ognjenkurtic Jul 8, 2024
d7d53b3
Update state module setup so that the GetStateTreeLeafValueContentQue…
ognjenkurtic Jul 9, 2024
df04378
Update Postman collection with endpoint for fetching the state leaf
ognjenkurtic Jul 9, 2024
bbf4b1e
Bug fix
biscuitdey Jul 10, 2024
fbae10d
Ccsm contract compiled artifacts
biscuitdey Jul 10, 2024
9e158f9
Bug fix in ethereum.spec.ts
biscuitdey Jul 11, 2024
f311c26
Extend e2e test to verify state and history tree storage and state tr…
ognjenkurtic Jul 12, 2024
a1c001e
Run format
ognjenkurtic Jul 12, 2024
2db1b10
Setup proper CCSM hardhat project separate from the SRI app
ognjenkurtic Jul 15, 2024
007997f
Add a bunch of TODOs
ognjenkurtic Jul 15, 2024
7d6a5ed
Fix formatting
ognjenkurtic Jul 15, 2024
543d380
Skip ethereum service test suite that requires a deployed contract
ognjenkurtic Jul 17, 2024
74cd1c4
Change DID_NETWORK env var to CCSM_NETWORK as it is used for connecti…
ognjenkurtic Jul 17, 2024
2eca94d
Update env sample docs
ognjenkurtic Jul 17, 2024
70db42c
Add sepolia config to hardhat
ognjenkurtic Jul 17, 2024
e595f2b
Add tests to achieve 100% coverage of the CcsmBpiStateAnchor smart co…
ognjenkurtic Jul 17, 2024
70e2152
Remove deployContract method from ccsm.interface and add CCSM_BPI_STA…
ognjenkurtic Jul 17, 2024
f6517ed
Move compiled contract to ccsmArtifacts and delete irelevant artifact…
ognjenkurtic Jul 17, 2024
b3e9078
Cleanup
ognjenkurtic Jul 17, 2024
e30e047
Remove bin folder with content
ognjenkurtic Jul 18, 2024
5375bc5
Remove obsolete paths from git ignore
ognjenkurtic Jul 18, 2024
5f944db
Remove options param from connectToContract method in ccsm service
ognjenkurtic Jul 18, 2024
1ab172e
Skip computePublicInputs tests as they are resource heavy
ognjenkurtic Jul 18, 2024
29bf04f
Merge pull request #808 from ethereum-oasis-op/803-sri-ccsm-connect-b…
biscuitdey Jul 18, 2024
8bd669a
Merge pull request #809 from ethereum-oasis-op/806-endpoint-to-fetch-…
Therecanbeonlyone1969 Jul 18, 2024
e47e9bb
Fix lint err
ognjenkurtic Jul 18, 2024
19c519a
Store verifier.sol contracts under ccsm contracts
biscuitdey Jul 18, 2024
543ca9f
Generate verifier solidity contract for all three worksteps
biscuitdey Jul 18, 2024
901c22b
Switch workflowId with workstepInstanceId in the ccsm contract
biscuitdey Jul 18, 2024
10ea038
Switch workgroupId to WorkstepInstanceId in hardhat unit test
biscuitdey Jul 18, 2024
04de091
Switch workgroupId to workstepInstanceId in ccsm interface
biscuitdey Jul 18, 2024
9c097b6
Switch workgroupId to workstepInstanceId in ethereum service
biscuitdey Jul 18, 2024
e8e7208
Replace workgroupId with workstepInstanceId
biscuitdey Jul 18, 2024
c26ee0e
Remove separate workstep verifier contracts
biscuitdey Jul 22, 2024
ae909ea
Add universal PlonkVerifier contract that accepts vk as param
biscuitdey Jul 22, 2024
a8192f0
Comment out shell command for creating plonk verifier contract
biscuitdey Jul 22, 2024
9c09091
Add workflowId and workstepId to transaction model
biscuitdey Jul 22, 2024
4b8fd8b
Convert workflowInstanceId to workflowId in e2e test
biscuitdey Jul 22, 2024
299b541
Change workflowInstanceId to workflowId in createTransaction command …
biscuitdey Jul 22, 2024
e9cf5f2
Add update functions for workflowInstanceId and workstepInstanceId in…
biscuitdey Jul 22, 2024
a9d4dfe
Change workstepInstanceId to workstepId in createTransaction
biscuitdey Jul 22, 2024
bfd5e29
Add workflowId and workstepId to prisma schema
biscuitdey Jul 22, 2024
0882f1e
Generate and store workflowInstanceId & workstepInstanceId for each t…
biscuitdey Jul 22, 2024
43ddb3f
Update transaction schema to make workflowInstanceId & workstepInstan…
biscuitdey Jul 22, 2024
6a94209
Update transactionController to accept workflowId and workstepId
biscuitdey Jul 22, 2024
325b3d1
Update createTransactionDto to accept workflowId and workstepId
biscuitdey Jul 22, 2024
c352bdc
Update transactionController test to accept workflowId & workstepId
biscuitdey Jul 22, 2024
d273675
Update createTransactionDto test to accept workflowId and workstepId
biscuitdey Jul 22, 2024
3166a15
Update executeVsmCycle command handler to search workflowId and works…
biscuitdey Jul 22, 2024
83b6b82
ccsmArtifacts for verifier contracts
biscuitdey Jul 22, 2024
1a977e2
Merge branch 'develop' of https://github.com/eea-oasis/baseline into …
biscuitdey Jul 22, 2024
9dfeedc
Merge pull request #820 from ethereum-oasis-op/811-sri-add-workflowid…
biscuitdey Jul 22, 2024
d26bd73
add contract deploy script to hardhat
ognjenkurtic Jul 18, 2024
3de294d
WIP Script for running the e2e tests
ognjenkurtic Jul 18, 2024
0ffac40
Add prisma reset command to e2e bash script
ognjenkurtic Jul 20, 2024
a30414f
Update github actions to run hardhat and deply contract
ognjenkurtic Jul 20, 2024
151e19b
Add npm i to ccsm project step in gh actions
ognjenkurtic Jul 20, 2024
f5a5658
...
ognjenkurtic Jul 20, 2024
a843fcd
Update readme re: e2e test running
ognjenkurtic Jul 20, 2024
5fe42b4
Update .github/workflows/bri-3.yml
Therecanbeonlyone1969 Jul 22, 2024
63cbc54
Merge pull request #818 from ethereum-oasis-op/815-sri-add-the-verifi…
biscuitdey Jul 23, 2024
f9fb2d0
Add localhost network to hardhat config and bpi contract address for …
ognjenkurtic Jul 22, 2024
722f2ed
Extend the bpi smart contract to accept uuid length for workstepinst…
ognjenkurtic Jul 23, 2024
1e8866e
Deploy bpi smart contract with local internal bpi subject as owner
ognjenkurtic Jul 23, 2024
8169c40
Hardcode sepolia for DID usage temporarely; Use CCSM_NETWORK env var …
ognjenkurtic Jul 23, 2024
21fa052
Use ICcsmService instead of IBlockchainService
ognjenkurtic Jul 23, 2024
938adf2
Add CAH storage after tx execution; Refactor storage of tx workflow a…
ognjenkurtic Jul 23, 2024
cb05b98
Run formatting
ognjenkurtic Jul 23, 2024
ea52e29
Use 127.0.0.1 instead of localhost for hardhat node
ognjenkurtic Jul 23, 2024
55ddbbd
Dummy commit to trigger GH action
ognjenkurtic Jul 24, 2024
925bd60
...
ognjenkurtic Jul 24, 2024
853b477
Update ccsmArtifacts with latest changes
ognjenkurtic Jul 24, 2024
eedc526
Extend the e2e test to verify proper storage of CAH on chain
ognjenkurtic Jul 24, 2024
45c7d14
Run formatting
ognjenkurtic Jul 24, 2024
e6266d9
Wait for HH to be killed before exiting the e2e bash script
ognjenkurtic Jul 24, 2024
6145e55
Remove resolved TODO
ognjenkurtic Jul 24, 2024
a2c732d
Add workstep verifier contracts from the sri use-case to hardhhat deploy
ognjenkurtic Jul 25, 2024
3e4c7df
add workstep verifier contract artifacts to zkartifacts folder
ognjenkurtic Jul 25, 2024
b6f16f7
Remove obsoelte method for contract connection from ethereum service …
ognjenkurtic Jul 25, 2024
8faa7bd
WIP verify proof in transaction execution
ognjenkurtic Jul 25, 2024
9adf3b5
Implement on chain verifiction for workstep1 from use-case
ognjenkurtic Jul 26, 2024
ce83c83
Run formatting
ognjenkurtic Jul 26, 2024
2f56ec1
Add verifier contract address to workstep model and execute respectiv…
ognjenkurtic Jul 26, 2024
1d417d5
Fix fomratting
ognjenkurtic Jul 26, 2024
e72c01e
Fix tests
ognjenkurtic Jul 26, 2024
5ba07c3
Remove commented out import
ognjenkurtic Jul 26, 2024
47ef994
Rem obsolete TODOs
ognjenkurtic Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/bri-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
- examples/bri-3/**
branches:
- main
- develop
pull_request:
paths:
- examples/bri-3/**
branches:
- main
- develop

jobs:
ci:
Expand Down Expand Up @@ -44,8 +46,9 @@ jobs:
DID_REGISTRY: "0x03d5003bf0e79c5f5223588f347eba39afbc3818"
DID_BPI_OPERATOR_PUBLIC_KEY: "0x08872e27BC5d78F1FC4590803369492868A1FCCb"
DID_BPI_OPERATOR_PRIVATE_KEY: "2c95d82bcd8851bd3a813c50afafb025228bf8d237e8fd37ba4adba3a7596d58"
DID_NETWORK: "sepolia"
CCSM_NETWORK: "localhost"
INFURA_PROVIDER_API_KEY: "c5f37cd25eca4007a9768f18f492bc6f"
CCSM_BPI_STATE_ANCHOR_CONTRACT_ADDRESS: "0x1CC96ba639d4fd7624913fde39122270a1aC5c34"
SERVICE_URL: "bri-3"
BPI_NATS_SERVER_URL: "localhost:4222"
BPI_NATS_SERVER_USER: "bpi_operator"
Expand Down Expand Up @@ -105,6 +108,16 @@ jobs:
- name: Run prisma db seed
working-directory: examples/bri-3
run: npx prisma db seed

- name: Install hardhat dependencies
working-directory: examples/bri-3/ccsm
run: npm ci

- name: Run hardhat and deploy contracts
working-directory: examples/bri-3/ccsm
run: |
npx hardhat node &
npx hardhat run scripts/deploy.ts

- name: Run e2e tests
working-directory: examples/bri-3
Expand Down
3 changes: 2 additions & 1 deletion examples/bri-3/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ DATABASE_URL="postgresql://postgres:example@localhost:5432/postgres" # DB connec
DID_REGISTRY="0x03d5003bf0e79c5f5223588f347eba39afbc3818" # Sepolia did registry https://sepolia.etherscan.io/address/0x03d5003bf0e79c5f5223588f347eba39afbc3818#code
DID_BPI_OPERATOR_PUBLIC_KEY="<bpi_operator_public_key>" # bpi_operator_public_key = public key of the bpi operator that represents the issuer of the JWT token
DID_BPI_OPERATOR_PRIVATE_KEY="<bpi_operator_private_key>" # bpi_operator_private_key = private key of the bpi operator that is used to sign the issued JWT token
DID_NETWORK="sepolia" # network used to resolve dids
CCSM_NETWORK="localhost" # network used to connect to BPI smart contract
INFURA_PROVIDER_API_KEY="<infura_api_key>" # API key of the infura account used to connect to the network
CCSM_BPI_STATE_ANCHOR_CONTRACT_ADDRESS="<smart_contract_address>" # address of the smart contract where CAHs are stored (0x1CC96ba639d4fd7624913fde39122270a1aC5c34 for local hardhat node)
SERVICE_URL="bri-3" # JWT token audience
BPI_NATS_SERVER_URL="localhost:4222" # URL of the local NATS server instance used by the BPI
BPI_NATS_SERVER_USER="bpi_operator"
Expand Down
1 change: 0 additions & 1 deletion examples/bri-3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/dist
/node_modules
src/bri/zeroKnowledgeProof/services/circuit/snarkjs/*.sol
/zeroKnowledgeArtifacts/blockchain/ethereum/artifacts
/typechain-types
/cache

Expand Down
4 changes: 3 additions & 1 deletion examples/bri-3/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"solidity-va.diagnostics.cdili_json.import": true,
"solidity.compileUsingRemoteVersion": "v0.8.20+commit.a1b79de6"
}
6 changes: 3 additions & 3 deletions examples/bri-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ $ npm run test -- transactions.agent.spec.ts


```bash
# e2e testing - .e2e.spec files located in ./test folder
# e2e testing - .e2e.spec files and the bash script used for running located in ./test folder
# before running the tests, make sure that postgres and nats are running
# and the database is properly populated with the seed.ts command (explained above)
# also make sure that the .env file contains correct values for DID login to work (as explained in the .env.sample)

$ npm run test:e2e
$ cd test
$ sh ./e2e-test.sh
```

## Architecture
Expand Down
17 changes: 17 additions & 0 deletions examples/bri-3/ccsm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
12 changes: 12 additions & 0 deletions examples/bri-3/ccsm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
```
56 changes: 56 additions & 0 deletions examples/bri-3/ccsm/contracts/CcsmBpiStateAnchor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;

import '@openzeppelin/contracts/access/AccessControl.sol';

contract CcsmBpiStateAnchor is AccessControl {
mapping(string => string) public anchorHashStore;
event AnchorHashSet(string indexed workstepInstanceId, string anchorHash);

bytes32 public constant ADMIN_ROLE = keccak256('ADMIN_ROLE');

constructor(address[] memory admins) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // Grant deployer the default admin role

for (uint i = 0; i < admins.length; i++) {
_grantRole(ADMIN_ROLE, admins[i]); // Grant admin role to each address
}
}

function setAnchorHash(
string calldata _workstepInstanceId,
string calldata _anchorHash
) external onlyAdmin {
require(
bytes(_workstepInstanceId).length > 0,
'WorkstepInstanceId cannot be empty'
);
require(
bytes(_workstepInstanceId).length < 40,
'WorkstepInstanceId cannot exceed 40 bytes'
);
require(bytes(_anchorHash).length > 0, 'AnchorHash cannot be empty');
require(
bytes(_anchorHash).length <= 256,
'AnchorHash cannot exceed 256 bytes'
);

anchorHashStore[_workstepInstanceId] = _anchorHash;

emit AnchorHashSet(_workstepInstanceId, _anchorHash);
}

function getAnchorHash(
string calldata _workstepInstanceId
) external view returns (string memory) {
return anchorHashStore[_workstepInstanceId];
}

modifier onlyAdmin() {
require(
hasRole(ADMIN_ROLE, msg.sender),
'Only admin can call this function'
);
_;
}
}
Loading
Loading