Skip to content

Commit

Permalink
Misc. Project Configuration, Apply Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay committed Sep 12, 2024
1 parent dbd58a5 commit d0bc3ef
Show file tree
Hide file tree
Showing 30 changed files with 5,342 additions and 3,437 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 100
tab_width = 2
trim_trailing_whitespace = true
21 changes: 20 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{
"[dockerfile]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[json]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[jsonc]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[markdown]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"editor.formatOnSave": true
"[toml]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[yaml]": {
"editor.defaultFormatter": "dprint.dprint"
},
"editor.formatOnSave": true,
"editor.tabSize": 2
}
51 changes: 36 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,53 @@
## [Post-MIP] as of 2023-Sep-26

### Added
- We streamlined development and deployment using Nix, Just, and Podman: for building, following best open-source practices and enhancements, being able to build with one command, and not reliant on Docker
- Nix ensures reproducibility and isolation by defining precise dependencies
- Just simplifies and automates common tasks with single-command actions
- Podman offers enhanced security and flexibility for containerization
- Updated Results button to be a ternary operator with either Results or Go Vote appearing next to the button icon

- We streamlined development and deployment using Nix, Just, and Podman: for building, following
best open-source practices and enhancements, being able to build with one command, and not reliant
on Docker
- Nix ensures reproducibility and isolation by defining precise dependencies
- Just simplifies and automates common tasks with single-command actions
- Podman offers enhanced security and flexibility for containerization
- Updated Results button to be a ternary operator with either Results or Go Vote appearing next to
the button icon
- Adding corresponding, respective URL links and matching text with the database
- Control log level functionality from an .env file
- Added customized code and fix for the next-router-mock given lack of support from Next 13 and this customization fixes broken tests in CI
- Added customized code and fix for the next-router-mock given lack of support from Next 13 and this
customization fixes broken tests in CI

### Improvements or Migrations

- Clarify and improve build instructions
- Migrated to Next 13's app router with a redesigned UI
- Migrated components to Tailwind & Radix
- Migrated pages to Next 13's app router
- Migrated & extended tests to increase coverage
- Improve precision by extending to 4 decimal places from 2 and remove any unnecessary trailing zeros
- Improve precision by extending to 4 decimal places from 2 and remove any unnecessary trailing
zeros
- Improve Docker build and integration between postgres and server
- Improve .env.example file for better networking options and ports suggested
- Improve various frontend and UI changes regarding filtering and sorting on tables, title, nav bar, footer, coloring, MIP key to be just MIP# vs # - MIP#
- Improve various frontend and UI changes regarding filtering and sorting on tables, title, nav bar,
footer, coloring, MIP key to be just MIP# vs # - MIP#
- Fix graph dates display, order of dates, and overall display
- Update multiple dependencies across the repo (some advised by dependabot)
- Extend README to DEVELOPER docs and splits across the server and web directories
- Improve GitHub CI configuration

### Deprecated or Removed

- Removed unused Playwright functionality
- Remove unused features (MUI - Storybook - Typeshare)

## [Pre-MIP4] - 2023-05-20

### Added

- Database migration script to make global_slot numbers i64 in Mina Proposals
- Updated the OCV app so it supports other networks other than mainnet
- Added rustsec audit-check in github action support
- Updated TTL cache with filtering and whitelisting
- Installed and configured Storybook, Playwright, Jest configurations (and custom jest render utilites), and MUI base tooling
- Installed and configured Storybook, Playwright, Jest configurations (and custom jest render
utilities), and MUI base tooling
- Migrated, converted and refactored tests
- Setup Typeshare CLI to generate TypeScript bindings from Rust types
- Added zod schema validation for frontend as well as queries and store
Expand All @@ -50,34 +61,44 @@
- Create Dockerfile and schema using Diesel ORM

### Improvements

- Sanitize SQL query params in function fetch_transactions using bind
- Improved security with specific CORS origins and preflight
- Improve the Github actions workflows to only build projects that have changed
- Decouple frontend and backend codebases and then migrate and refactor them to NextJS and Vercel deployment as well as refactor and restructure server modules
- Decouple frontend and backend codebases and then migrate and refactor them to NextJS and Vercel
deployment as well as refactor and restructure server modules
- Double precision errors that occur with floating point types by using Decimal type
- Updated README.md files

### Deprecated or Removed

- Removed static page serving
- Removed dummy data and Nix build system
- Deprecated Haskell tools and scripts related to the archive node

## [Pre-MIP1] - 2023-01-04

### Added

- Created FAQs and feedback forms
- New feature and support for pagination of results
- Archive node missing blocks script and runbook to check and patch missing blocks when needed
- Create tests (unit, functional, etc.) for server and client
- Added timestamp checking to the canonical OCV query so as to avoid votes being counted that were cast before the start of the voting period
- Created Haskell scripts to download, clean and run archive dumps and connect to the archive node's PostgreSQL database
- Ability for users explore a tx hash instead of copying and manually going to verify the transaction with a third-party
- Updated the SQL query, sqlx uses github workflows to determine query validity, and LedgerAccount changed to an array from a vector and begins empty rather than zero
- Added timestamp checking to the canonical OCV query so as to avoid votes being counted that were
cast before the start of the voting period
- Created Haskell scripts to download, clean and run archive dumps and connect to the archive node's
PostgreSQL database
- Ability for users explore a tx hash instead of copying and manually going to verify the
transaction with a third-party
- Updated the SQL query, sqlx uses github workflows to determine query validity, and LedgerAccount
changed to an array from a vector and begins empty rather than zero
- Created a progress bar to display the progress of the voting time period
- Memo all lowercase to avoid case sensitivity
- Delegating stake is clearly expressed in browser
- Maintain certain version of tokio and axum to avoid security issue
- Created tooltips, such as for total votes calculations

### Deprecated or Removed
- Deprecated feature to count valid signals from accounts not on the Staking Ledger in the total number of signals, but not for the total stake

- Deprecated feature to count valid signals from accounts not on the Staking Ledger in the total
number of signals, but not for the total stake
51 changes: 24 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
# Mina On-Chain Voting

On-Chain Voting is a protocol developed to help with governing the Mina L1
blockchain.
On-Chain Voting is a protocol developed to help with governing the Mina L1 blockchain.

## Vote With [Auro Wallet](https://www.aurowallet.com/)

1. Ensure you're on the correct network (in this case devnet).
2. Click on your address to copy it to the clipboard (we'll be using it in the next step).
> Note: you must use an account which exists in the accounts ledger for the previous epoch. If you create and utilize a brand new account, your vote will not be counted.

> Note: you must use an account which exists in the accounts ledger for the previous epoch. If you
> create and utilize a brand new account, your vote will not be counted.
3. Click on "Send."

![Ouro Home](./ouro_screens/1.home.png)

4. Paste your address into `To`.
5. Add `1` in the `Amount` field.
6. Depending on how you want to cast your vote, enter either `MIP#` or `no MIP#` where `#` is substituted with the actual MIP number.
6. Depending on how you want to cast your vote, enter either `MIP#` or `no MIP#` where `#` is
substituted with the actual MIP number.

![Vote Details](./ouro_screens/2.vote_details.png)

7. Confirm the transaction.

![Vote Confirmation](./ouro_screens/3.confirmation.png)


## Protocol Specifications

The On-Chain Voting Protocol is designed to provide community members with a
transparent and secure method of participating in the decision-making process
for the Mina blockchain. The aim for this protocol is to provide stakeholders
with the ability to vote on MIPs (Mina Improvement Proposals) with ease.
The On-Chain Voting Protocol is designed to provide community members with a transparent and secure
method of participating in the decision-making process for the Mina blockchain. The aim for this
protocol is to provide stakeholders with the ability to vote on MIPs (Mina Improvement Proposals)
with ease.

(Individual MIPs should be created by following the process described on the
[GitHub repository](https://github.com/MinaProtocol/MIPs).)


### Voting on a MIP

To cast a vote on a particular MIP, a user must send a transaction to
**themselves** with a specially-constructed memo field. The memo field must
adhere to the following convention.
To cast a vote on a particular MIP, a user must send a transaction to **themselves** with a
specially-constructed memo field. The memo field must adhere to the following convention.

**For example:**

Expand All @@ -48,20 +48,19 @@ Similarly, if the intent is to vote against 'MIP1', the memo field must
contain: 'no MIP1'.
```

**The transaction amount must be 0, with the user only paying for the
transaction fee.**
**The transaction amount must be 0, with the user only paying for the transaction fee.**

For more details, see:

- The [article by Granola](https://granola.team/blog/mina-on-chain-voting-results-instructions/)
- The [FAQ](https://forums.minaprotocol.com/t/on-chain-voting-frequently-asked-questions-faq/5959)


## Software Development

Install [Nix](https://nixos.org/download) and [direnv](https://direnv.net/docs/installation.html).

The `.envrc` will instruct `direnv` to use Nix to install the prerequisites for development on this repo.
The `.envrc` will instruct `direnv` to use Nix to install the prerequisites for development on this
repo.

Without Nix, you will need to install, most notably:

Expand All @@ -79,21 +78,19 @@ Configure your `.env` file. See the [`.env.example`](./.env.example).

Optionally issue `just install` to install yet more dependencies.

Issue `just` to see the possible development actions. Examine
[Justfile](./Justfile) to see how they work.

For more information about Diesel and database migrations, see [the official
docs.](https://crates.io/crates/diesel_cli).
Issue `just` to see the possible development actions. Examine [Justfile](./Justfile) to see how they
work.

For more information about Diesel and database migrations, see
[the official docs.](https://crates.io/crates/diesel_cli).

## Contributing

Contributions are welcome! This project uses the
[C4 (Collective Code Construction Contract)](https://rfc.zeromq.org/spec/42/)
process for contributions.

[C4 (Collective Code Construction Contract)](https://rfc.zeromq.org/spec/42/) process for
contributions.

## License

This project is licensed under the Mozilla Public License 2.0. See the
[LICENSE](./LICENSE) file for the full license text.
This project is licensed under the Mozilla Public License 2.0. See the [LICENSE](./LICENSE) file for
the full license text.
13 changes: 13 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"dictionaryDefinitions": [
{
"name": "project-words",
"path": "words.txt"
}
],
"enableGlobDot": true,
"dictionaries": ["project-words", "rust"],
"ignorePaths": [".git", "server/target"]
}
8 changes: 4 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3.8'
version: "3.8"
services:
web:
container_name: web
profiles: ['all', 'web']
profiles: ["all", "web"]
build:
context: ./web
dockerfile: Dockerfile
Expand All @@ -15,7 +15,7 @@ services:
- 3000:3000
server:
container_name: server
profiles: ['all', 'server-db', 'server']
profiles: ["all", "server-db", "server"]
build:
context: ./server
dockerfile: Dockerfile
Expand All @@ -29,7 +29,7 @@ services:
- db
db:
container_name: postgres
profiles: ['all', 'server-db', 'db']
profiles: ["all", "server-db", "db"]
image: postgres:15.2
ports:
- 5432:5432
Expand Down
16 changes: 16 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"incremental": true,
"indentWidth": 2,
"lineWidth": 100,
"markdown": {
"textWrap": "always"
},
"excludes": ["web/pnpm-lock.yaml", "web/node_modules"],
"plugins": [
"https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.4.0.wasm",
"https://plugins.dprint.dev/json-0.19.2.wasm",
"https://plugins.dprint.dev/markdown-0.16.4.wasm",
"https://plugins.dprint.dev/toml-0.6.2.wasm"
]
}
6 changes: 4 additions & 2 deletions ops/ManualTestingRoutine.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- Log into the Archive Node DB with your tool of choice. (Postico, PGAdmin etc.)
- Go to the "mainnet" database.
- On the "blocks" table get the most recent block by height.
- Go to Mina Explorer (https://minaexplorer.com/) & compare the most recent block with Mina Explorer.
- Go to Mina Explorer (https://minaexplorer.com/) & compare the most recent block with Mina
Explorer.
- If they match up - we're still synced.

- From your tool of choice run the following queries:
Expand Down Expand Up @@ -41,7 +42,8 @@ Select count(*) from blocks where parent_id is null
##### If there are any missing blocks, use the following tools and commands in your archive node instance to check and add blocks:

- mina-missing-blocks-auditor -- returns state hashes of missing blocks from the archive database.
- mina-extract-blocks -- extracts all blocks from said database or a chain if the command is provided with `--start-state-hash` and or `--end-state-hash`.
- mina-extract-blocks -- extracts all blocks from said database or a chain if the command is
provided with `--start-state-hash` and or `--end-state-hash`.
- mina-archive-blocks -- writes blocks to the database.
- mina-replayer -- replays transactions from the archive node.

Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
11 changes: 11 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
edition = "2021"
imports_granularity = "Crate"
max_width = 120
newline_style = "Unix"
overflow_delimited_expr = true
spaces_around_ranges = true
tab_spaces = 2
use_field_init_shorthand = true
use_try_shorthand = true
version = "Two"
wrap_comments = true
8 changes: 4 additions & 4 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
# Core dependencies
axum = { version = "0.6.4", features = ["tower-log"] }
bs58 = { version = "0.4.0", features = ["check"] }
clap = { version = "4.1.4", features = ["derive", "env"] }
diesel = { version = "2.0.3", features = ["postgres", "r2d2", "numeric"] }
diesel-derive-enum = { version = "2.0.0", features = ["postgres"] }
clap = { version = "4.1.4", features = ["derive", "env"] }
moka = { version = "0.12.0", features = ["future"] }
reqwest = { version = "0.11.14", features = ["json", "blocking"] }
serde = { version = "1.0.152", features = ["derive"] }
Expand All @@ -23,10 +23,10 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }

# Utility dependencies
anyhow = "1.0.69"
bigdecimal = "0.4.5"
bytes = "1.4.0"
flate2 = "1.0.33"
futures-util = "0.3"
rust_decimal = "1.28.0"
r2d2 = "0.8.10"
flate2 = "1.0.33"
rust_decimal = "1.28.0"
tar = "0.4.41"
bigdecimal = "0.4.5"
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### build server
FROM rust:bullseye as builder
FROM rust:bullseye AS builder
ENV USER=mina
ENV UID=1001
RUN adduser \
Expand Down
Loading

0 comments on commit d0bc3ef

Please sign in to comment.