Skip to content

Commit 6ed25e4

Browse files
committed
fix: reconcile docs for rename and updates
Signed-off-by: Sam Stuewe <[email protected]>
1 parent eefcdf2 commit 6ed25e4

File tree

13 files changed

+75
-65
lines changed

13 files changed

+75
-65
lines changed

docs/parsec_architecture.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Therefore transaction throughput is horizontally scalable with additional server
2525
For example, in contrast to the Ethereum blockchain, this system executes native value transfers and smart contract transactions (e.g. [ERC20 token](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) transfers) in parallel for independent addresses.
2626

2727
# Architecture Diagram
28-
![Architecture Diagram](PArSEC_architecture_diagram.svg)
28+
![Architecture Diagram](parsec_architecture_diagram.svg)
2929

3030
# System Components
3131
### Agent (Transaction Coordinator)

docs/parsec_user_guide.md

+45-38
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# PArSEC User Guide
22

3-
This guide runs through setting up the PArSEC system with the EVM runner, and then interacting with it using Hardhat and MetaMask. This assumes that the system has been set up as described in the [README](https://github.com/mit-dci/opencbdc-tx#readme).
3+
This guide runs through setting up the PArSEC system with the EVM runner, and then interacting with it using Hardhat and MetaMask.
4+
This assumes that the system has been set up as described in the [README](https://github.com/mit-dci/opencbdc-tx#readme).
45

56
## Prerequisites
67

78
Make sure you have [NodeJS installed](https://github.com/nodesource/distributions/blob/master/README.md).
89
We recommend using `v18` or `v20`, as Hardhat [actively supports these versions](https://github.com/nodejs/release#release-schedule) currently.
9-
We also provide a [.nvmrc](https://github.com/mit-dci/opencbdc-tx/blob/trunk/.nvmrc).
10+
We also provide a [.nvmrc](../.nvmrc).
1011
## Running the Server
1112
### Run with Docker
1213

13-
Spawns an agent running the EVM runner by default.
14-
Lua runner may be used by modifying the --runner_type flag in the command keyed by agent0, in the file [`docker-compose-PArSEC.yml`](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docker-compose-PArSEC.yml).
14+
Spawns an agent running the EVM runner by default.
15+
Lua runner may be used by modifying the --runner_type flag in the command keyed by agent0, in the file [`docker-compose-parsec.yml`](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docker-compose-parsec.yml).
1516

1617
### Start it up
1718
```console
18-
# docker compose -f docker-compose-PArSEC.yml up -d
19+
# docker compose -f docker-compose-parsec.yml up -d
1920
```
2021

2122
The agent is now available on `http://localhost:8080/`.
@@ -27,7 +28,7 @@ If you are using MacOS or an Ubuntu-like distribution, you can run the system wi
2728
Build and run the system:
2829
```console
2930
$ ./scripts/build.sh
30-
$ ./scripts/PArSEC-run-local.sh [OPTIONS] # use --help flag for help
31+
$ ./scripts/parsec-run-local.sh [OPTIONS] # use --help flag for help
3132
```
3233
The agent is now available on the specified IP address and port (defaults to localhost:8888).
3334

@@ -37,12 +38,13 @@ Follow below for a demo.
3738

3839
### Setup Hardhat environment
3940

40-
Go to a new separate directory and run `npm init` and `npm install --save-dev hardhat @nomiclabs/hardhat-waffle`:
41+
Go to a new separate directory and run the following:
4142

4243
```console
43-
$ mkdir PArSEC-playground && cd PArSEC-playground
44-
$ npm init # all fields may be left as defaults (or blank)
45-
$ npm install --save-dev hardhat @nomiclabs/hardhat-waffle
44+
$ mkdir parsec-playground && cd parsec-playground
45+
$ npm -y init # `-y` keeps all defaults
46+
$ npm install @nomicfoundation/hardhat-ethers ethers
47+
$ npm install hardhat
4648
```
4749

4850
Finish with initializing Hardhat using:
@@ -51,17 +53,19 @@ Finish with initializing Hardhat using:
5153
$ npx hardhat
5254
```
5355

54-
Select to create a JavaScript project. All default values are sufficient for instantiating this project.
56+
Select to create a JavaScript project.
57+
All default values are sufficient for instantiating this project.
5558

5659
Note: This will create new subdirectories and files in this directory.
57-
These can all be overwritten for the purpose of this guide.
60+
These can all be overwritten for the purpose of this guide.
5861
However, to use the Hardhat compiler, all Solidity files should be stored in the
5962
`contracts` subdirectory.
6063

61-
Copy the example [hardhat.config.js](https://github.com/mit-dci/opencbdc-tx/blob/trunk/scripts/hardhat.config.js) into this directory.
64+
Copy the example [hardhat.config.js](../scripts/hardhat.config.js) into this directory.
6265

63-
Edit the `url:` value in the `hardhat.config.js` file to correspond with the url of the agent RPC server.
64-
Using Docker this will be `http://localhost:8080/`. If running outside of Docker, use the IP and port specified when running `./scripts/PArSEC-run-local.sh` (default is `http://localhost:8888/`).
66+
Edit the `url:` value in the `hardhat.config.js` file to correspond with the url of the agent RPC server.
67+
Using Docker this will be `http://localhost:8080/`.
68+
If running outside of Docker, use the IP and port specified when running `./scripts/parsec-run-local.sh` (default is `http://127.0.0.1:8888/`).
6569

6670
Note: the value in the `accounts` array is the private key of one of the hard-coded, pre-minted accounts in PArSEC/EVM.
6771

@@ -77,7 +81,8 @@ browse the [Hardhat getting started guide](https://hardhat.org/hardhat-runner/do
7781

7882
### Using the MetaMask Web3 Client
7983

80-
Install [MetaMask](https://metamask.io/) as a browser add-on. After initialization with seed phrases and all, [add a custom network](https://metamask.zendesk.com/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC).
84+
Install [MetaMask](https://metamask.io/) as a browser add-on.
85+
After initialization with seed phrases and all, [add a custom network](https://metamask.zendesk.com/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC).
8186

8287
| Parameter | Value |
8388
| --------------- | ------------------------------------------|
@@ -86,21 +91,22 @@ Install [MetaMask](https://metamask.io/) as a browser add-on. After initializati
8691
| New RPC URL | `http://<agent IP address>:<agent port>/` |
8792
| Currency symbol | `CBDC` |
8893

89-
The agent IP address and agent port are the IP address and port specified for the agent when spawning the system.
90-
Using Docker, this defaults to {IP: localhost, port: 8080}
94+
The agent IP address and agent port are the IP address and port specified for the agent when spawning the system.
95+
Using Docker, this defaults to {IP: localhost, port: 8080}
9196
Running outside of Docker, this defaults to {IP: localhost, port:8888}.
9297
### Funding MetaMask
9398

94-
Once you have MetaMask set up, there will be "Account 1" with a trucated address up top, with a button to copy the address. You can use that to send yourself some coins:
99+
Once you have MetaMask set up, there will be "Account 1" with a trucated address up top, with a button to copy the address.
100+
You can use that to send yourself some coins:
95101

96-
To issue yourself native tokens, execute the following commands:
102+
To issue yourself native tokens, execute the following commands:
97103
Note: the `>` symbol is the Hardhat prompt.
98104
```console
99105
$ npx hardhat console
100106

101107
> const signers = await ethers.getSigners()
102108
undefined
103-
> await signers[0].sendTransaction({to:"0x08293b196E8F1c5552e455CFD10B642EC7a809A7", value:ethers.utils.parseUnits("500.99").toHexString()});
109+
> await signers[0].sendTransaction({to:"0x08293b196E8F1c5552e455CFD10B642EC7a809A7", value:ethers.toBeHex(ethers.parseUnits("500.99"))});
104110
{
105111
...
106112
}
@@ -111,50 +117,51 @@ You should see the balance appear after a few moments.
111117

112118
### Try deploying en ERC20 token!
113119

114-
An example ERC20 token contract is provided at [opencbdc-tx/contracts/MITCoin.sol](https://github.com/mit-dci/opencbdc-tx/blob/trunk/contracts/MITCoin.sol). Use this file as a basis, or create one [from scratch](https://dev.to/yakult/a-concise-hardhat-tutorial-part-2-writing-erc20-2jpm).
120+
An example ERC20 token contract is provided at [opencbdc-tx/contracts/MITCoin.sol](../contracts/MITCoin.sol).
121+
Use this file as a basis, or create one [from scratch](https://dev.to/yakult/a-concise-hardhat-tutorial-part-2-writing-erc20-2jpm).
115122
Follow the below directions to deploy your token.
116123

117124
Note: To compile the example contract, `@openzeppelin/contracts` is a required install.
118125
```console
119126
$ npm install @openzeppelin/contracts
120127
```
121-
Create a deploy script for the token. An example is provided in [opencbdc-tx/scripts/deploy.js](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docs/PArSEC_user_guide.md).
122-
As written, this script requires the name of the ERC20 token to be changed to match the name of the token which is to be deployed.
128+
Create a deploy script for the token. An example is provided in [opencbdc-tx/scripts/deploy.js](../scripts/deploy.js).
129+
As written, this script requires the name of the ERC20 token to be changed to match the name of the token which is to be deployed.
123130

124131
Note: When the Hardhat project was initialized, a `scripts/deploy.js` file was created.
125132
It corresponds to the file `contracts/Lock.sol` that was also created upon initialization.
126133
For the purposes of this guide, that script can be overwritten, and we do not require `contracts/Lock.sol`.
127134

128-
Spawn the system using above instructions, then run:
135+
To deploy [opencbdc-tx/contracts/MITCoin.sol](../contracts/MITCoin.sol), spawn the system using above instructions, then run:
129136

130137
```console
138+
$ cp <path_to_local_opencbdc-tx_clone>/contracts/MITCoin.sol contracts
131139
$ npx hardhat compile
132-
$ npx hardhat run *deploy-script*.js
140+
$ npx hardhat run <path_to_local_opencbdc-tx_clone>/scripts/deploy.js
133141
Deploying contracts with the account: 0x01A151CC5ED14d110cc0e6b64360913DE9f453F1
134-
Account balance: 1000000.0
135-
Contract Information: {
136-
to: null,
137-
from: '0x01A151CC5ED14d110cc0e6b64360913DE9f453F1'
138-
contractAddress: ...
139-
...
140-
}
142+
Contract Address: 0x610d7e7AF709BA7e235214Bd56af888Cd5FDb477
141143
```
142144

143-
*Take note of the value labeled contractAddress*
145+
*Take note of the Contract Address.*
146+
Unless manually modified, the token name for the provided example contract is `MITCoin`.
144147

145-
The token is now deployed on the network! Issue some to your metamask account:
148+
The token is now deployed on the network!
149+
Issue some to your metamask account:
146150

147151
*The below example assumes that the ERC20 has a function `mint(address, amount)`*
148152

153+
149154
```console
150155
$ npx hardhat console
151-
> const yourToken = await (await ethers.getContractFactory("*yourTokenName*")).attach("*yourContactAddress noted above*");
156+
> const yourToken = await (await ethers.getContractFactory("yourTokenName")).attach("yourContractAddress");
152157
undefined
153-
> await yourToken.mint("*your metamask address*", ethers.utils.parseUnits("5000"))
158+
> await yourToken.mint("your metamask address", ethers.parseUnits("5000"))
154159
{
155160
hash: '0x12056b3043c7201c4475eacfebcb4b7d4a64fba25c3b3e8262dbe5e42d215cd8',
156161
...
157162
}
158-
>
159163
```
164+
165+
In MetaMask, you can now click `Import tokens`, and paste the Contract Address reported above; the other two fields should populate automatically.
166+
160167
This is the end of the guide, but we encourage you to try deploying new and unique contracts to the system!

scripts/deploy.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@ async function main() {
33

44
console.log("Deploying contracts with the account:", deployer.address);
55

6-
const weiAmount = (await deployer.getBalance()).toString();
7-
8-
console.log("Account balance:", (await ethers.utils.formatEther(weiAmount)));
9-
106
// fill in your token name here
11-
const Token = await ethers.getContractFactory("MITCoin");
12-
const token = await Token.deploy();
13-
14-
const info = await token.deployTransaction.wait();
15-
console.log("Contract Information:", info);
7+
const token = await ethers.deployContract("MITCoin", []);
8+
console.log("Contract Address:", await token.getAddress());
169
}
1710

1811
main()
@@ -21,3 +14,4 @@ async function main() {
2114
console.error(error);
2215
process.exit(1);
2316
});
17+

scripts/hardhat.config.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require("@nomiclabs/hardhat-waffle");
1+
require("@nomicfoundation/hardhat-ethers");
22

33
// You need to export an object to set up your config
44
// Go to https://hardhat.org/config/ to learn more
@@ -17,7 +17,10 @@ module.exports = {
1717
defaultNetwork: "opencbdc",
1818
networks: {
1919
opencbdc: {
20-
url: "http://localhost:8888/",
20+
// This URL is the PArSEC agent Node endpoint
21+
// NOTE: "localhost" (instead of 127.0.0.1) may work on some systems
22+
url: "http://127.0.0.1:8888/",
23+
// Private key corresponding to a pre-minted PArSEC account
2124
accounts: ["32a49a8408806e7a2862bca482c7aabd27e846f673edc8fb0000000000000000"]
2225
}
2326
}

src/parsec/agent/runners/lua/server.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace cbdc::parsec::agent::rpc {
2222
/// \param srv pointer to an asynchronous RPC server.
2323
/// \param broker broker instance.
2424
/// \param log log instance.
25-
/// \param cfg system configuration options.
25+
///  \param cfg system configuration options.
2626
server(std::unique_ptr<server_type> srv,
2727
std::shared_ptr<broker::interface> broker,
2828
std::shared_ptr<logging::log> log,

src/uhs/sentinel/interface.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ namespace cbdc::sentinel {
9090
/// \return the response from the sentinel or std::nullopt if
9191
/// processing failed.
9292
virtual auto execute_transaction(transaction::full_tx tx)
93-
-> std::optional<execute_response> = 0;
93+
-> std::optional<execute_response>
94+
= 0;
9495

9596
/// Validate transaction and generate a sentinel attestation if the
9697
/// transaction is valid.
9798
/// \param tx transaction to validate and attest to.
9899
/// \return sentinel attestation for the given transaction, or
99100
/// std::nullopt if the transaction is invalid.
100101
virtual auto validate_transaction(transaction::full_tx tx)
101-
-> std::optional<validate_response> = 0;
102+
-> std::optional<validate_response>
103+
= 0;
102104
};
103105
}
104106

src/uhs/twophase/locking_shard/interface.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ namespace cbdc::locking_shard {
5151
/// txs in the input vector had their relevant input hashes
5252
/// locked by the shard. Otherwise std::nullopt.
5353
virtual auto lock_outputs(std::vector<tx>&& txs, const hash_t& dtx_id)
54-
-> std::optional<std::vector<bool>> = 0;
54+
-> std::optional<std::vector<bool>>
55+
= 0;
5556

5657
/// Completes a previous lock operation by deleting input hashes and
5758
/// creating output hashes, or unlocking input hashes.

src/uhs/twophase/locking_shard/locking_shard.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace cbdc::locking_shard {
8888
/// from the previous lock operation the shard
8989
/// should apply (`true`), and which it should
9090
/// cancel (`false`). Must have the same size and
91-
///  order as txs from lock.
91+
///   order as txs from lock.
9292
/// \param dtx_id distributed transaction ID of the previous lock
9393
/// operation.
9494
/// \return true if the apply operation succeeded.

src/uhs/twophase/locking_shard/status_interface.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ namespace cbdc::locking_shard {
2929
/// \return true if the UHS ID is unspent, or std::nullopt if the query
3030
/// failed.
3131
[[nodiscard]] virtual auto check_unspent(const hash_t& uhs_id)
32-
-> std::optional<bool> = 0;
32+
-> std::optional<bool>
33+
= 0;
3334

3435
/// Queries whether the given TX ID is confirmed in the cache of
3536
/// recently confirmed TX IDs.
3637
/// \param tx_id TX ID to query.
3738
/// \return true if the TX ID is present in the cache, or std::nullopt
3839
/// if the query failed.
3940
[[nodiscard]] virtual auto check_tx_id(const hash_t& tx_id)
40-
-> std::optional<bool> = 0;
41+
-> std::optional<bool>
42+
= 0;
4143
};
4244
}
4345

src/util/raft/index_comparator.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "index_comparator.hpp"
77

8+
#include <cstdint>
89
#include <cstring>
910
#include <leveldb/slice.h>
1011

src/util/rpc/async_server.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ namespace cbdc::rpc {
127127

128128
using server_type = server<Request, Response, InBuffer, OutBuffer>;
129129

130-
static constexpr auto raw_mode
131-
= std::is_same_v<Request,
132-
buffer> && std::is_same_v<Response, buffer>;
130+
static constexpr auto raw_mode = std::is_same_v<Request, buffer>
131+
&& std::is_same_v<Response, buffer>;
133132
};
134133

135134
/// \brief Asynchronous pass-through RPC server.

src/util/rpc/client.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ namespace cbdc::rpc {
115115
virtual auto call_raw(cbdc::buffer request_buf,
116116
request_id_type request_id,
117117
std::chrono::milliseconds timeout)
118-
-> std::optional<response_type> = 0;
118+
-> std::optional<response_type>
119+
= 0;
119120

120121
virtual auto call_raw(cbdc::buffer request_buf,
121122
request_id_type request_id,

src/util/serialization/format.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ namespace cbdc {
365365
-> serializer& {
366366
using S = uint8_t;
367367
static_assert(
368-
std::variant_size_v<std::remove_reference_t<decltype(var)>> < std::
369-
numeric_limits<S>::max());
368+
std::variant_size_v<std::remove_reference_t<decltype(var)>>
369+
< std::numeric_limits<S>::max());
370370
auto idx = static_cast<S>(var.index());
371371
ser << idx;
372372
std::visit(
@@ -385,8 +385,8 @@ namespace cbdc {
385385
serializer&> {
386386
using S = uint8_t;
387387
static_assert(
388-
std::variant_size_v<std::remove_reference_t<decltype(var)>> < std::
389-
numeric_limits<S>::max());
388+
std::variant_size_v<std::remove_reference_t<decltype(var)>>
389+
< std::numeric_limits<S>::max());
390390
S idx{};
391391
deser >> idx;
392392
auto var_idx = static_cast<size_t>(idx);

0 commit comments

Comments
 (0)