-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2b19a22
Showing
96 changed files
with
8,139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
# RustRover | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# Added by cargo | ||
|
||
/target | ||
|
||
.vscode/ | ||
|
||
package-lock.json | ||
package.json | ||
node_modules/ | ||
|
||
contracts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci-workflow | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
contract-test: | ||
name: "Contract Test" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Show Forge version | ||
run: | | ||
forge --version | ||
- name: Run Forge fmt | ||
run: | | ||
forge fmt --check | ||
id: fmt | ||
working-directory: contracts | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge build --sizes | ||
id: build | ||
working-directory: contracts | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test | ||
working-directory: contracts | ||
|
||
server-test: | ||
name: "Server Test" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: cargo build | ||
- name: Run tests | ||
run: cargo test | ||
|
||
push-reg: | ||
name: "Push Registry" | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run script | ||
run: | | ||
docker login $REGISTRY -u $REGISTRY_USER -p $REGISTRY_PASSWORD | ||
docker build -t "$IMAGE:${GITHUB_SHA:0:7}" . | ||
docker push "$IMAGE:${GITHUB_SHA:0:7}" | ||
env: | ||
REGISTRY: ${{ vars.REGISTRY }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
APP_NAME: ${{ vars.APP_NAME }} | ||
IMAGE: ${{ vars.REGISTRY }}/${{ vars.APP_NAME }} | ||
|
||
deploy-server: | ||
name: "Deploy DARKUBE" | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
|
||
needs: | ||
- push-reg | ||
- server-test | ||
|
||
container: hamravesh.hamdocker.ir/public/darkube-cli:v1.1 | ||
steps: | ||
- name: Run script | ||
run: darkube deploy --ref master --token ${DARKUBE_DEPLOY_TOKEN} --app-id ${DARKUBE_APP_ID} --image-tag "${GITHUB_SHA:0:7}" --job-id "$GITHUB_RUN_ID" --stateless-app true | ||
env: | ||
DARKUBE_DEPLOY_TOKEN: ${{ secrets.DARKUBE_DEPLOY_TOKEN }} | ||
DARKUBE_APP_ID: ${{ vars.DARKUBE_APP_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
.env | ||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
# RustRover | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# Added by cargo | ||
|
||
/target | ||
|
||
.vscode/ | ||
|
||
package-lock.json | ||
package.json | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[submodule "contracts/lib/forge-std"] | ||
path = contracts/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "contracts/lib/openzeppelin-foundry-upgrades"] | ||
path = contracts/lib/openzeppelin-foundry-upgrades | ||
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades | ||
[submodule "contracts/lib/openzeppelin-contracts-upgradeable"] | ||
path = contracts/lib/openzeppelin-contracts-upgradeable | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable | ||
[submodule "misc/foundry-project/lib/forge-std"] | ||
path = misc/foundry-project/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
[package] | ||
name = "owshen" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
alloy = { version = "0.3", features = ["full", "rlp"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
bincode = "1.3.3" | ||
rlp = "0.5.2" | ||
tokio = { version = "1.39.2", features = ["full"] } | ||
rand = "0.8.5" | ||
async-trait = "0.1.81" | ||
ff = { version = "0.13", features = ["derive", "derive_bits"] } | ||
lazy_static = "1.5.0" | ||
num-bigint = "0.4" | ||
num-integer = "0.1" | ||
leveldb = "0.8.6" | ||
db-key = "0.0.5" | ||
axum = "0.6" | ||
hyper = "0.14" | ||
eyre = "0.6.12" | ||
reqwest = "0.12.7" | ||
log = "0.4" | ||
serde_json = "1.0.125" | ||
jsonrpsee = { version = "0.24.3", features = [ | ||
"server", | ||
"http-client", | ||
"ws-client", | ||
"macros", | ||
"client-ws-transport-tls", | ||
] } | ||
tower = { version = "0.4.13", features = ["full"] } | ||
tower-http = { version = "0.5.2", features = ["full"] } | ||
tower_http_cors = { package = "tower-http", version = "0.4.4", features = ["full"] } | ||
env_logger = "0.11" | ||
structopt = { version = "0.3", default-features = false } | ||
webbrowser = "0.6" | ||
ethereum-types = "0.14.1" | ||
sha3 = "0.10.8" | ||
hex = "0.4.3" | ||
evm = "0.41" | ||
primitive-types = "0.12" | ||
tinytemplate = "1.2.1" | ||
criterion = "0.5.1" | ||
css-style = "0.14.1" | ||
mime_guess = "2.0.5" | ||
once_cell = "1.19.0" | ||
tracing-subscriber = "0.3.18" | ||
alloy-sol-types = "0.8.3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM rust:1.80-slim-bullseye AS base | ||
|
||
WORKDIR /code | ||
RUN cargo init | ||
COPY Cargo.toml /code/Cargo.toml | ||
RUN cargo fetch | ||
COPY . /code | ||
|
||
FROM base AS builder | ||
|
||
RUN apt update && apt-get install -y pkg-config libudev-dev libssl-dev cmake gcc g++ | ||
RUN cargo build --release --offline | ||
|
||
FROM debian:11.10-slim | ||
|
||
COPY --from=builder /code/target/release/owshen /owshen | ||
COPY --from=builder /code/GENESIS.json /GENESIS.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"token_type": "Native", | ||
"balances": [ | ||
{ | ||
"address": "0x0202020202020202020202020202020202020202", | ||
"amount": "2" | ||
} | ||
] | ||
}, | ||
{ | ||
"token_type": "Erc20", | ||
"contract_address": "0x0303030303030303030303030303030303030303", | ||
"decimal": "18", | ||
"symbol": "USDT", | ||
"balances": [ | ||
{ | ||
"address": "0x0202020202020202020202020202020202020202", | ||
"amount": "200" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Owshen Network 🤏⛓️ | ||
|
||
- A minimalistic ***imaginary*** blockchain, controlled by a centralized party. | ||
- Listens to the deposits that happen on the network's smart-contract. | ||
- Implements Ethereum RPC endpoints, and the centralized owner may mint/burn tokens as he wish. | ||
- Mints when someone deposits, and burns when someone withdraws. | ||
- Zero fees! | ||
- Literally a ***fake layer-2*** with ***super-cheap transactions***! | ||
|
||
## Vision | ||
|
||
|
||
### Phase 1 | ||
- Imagine there is a smart-contract hosted on the Ethereum blockchain, owned by the Owshen Network's maintainer (E.g Nobitex). | ||
- The smart-contract has a very simple structure: | ||
```solidity= | ||
contract OwshenEx { | ||
address owner; | ||
constructor() { | ||
owner = msg.sender; | ||
} | ||
function withdraw_native(uint256 amount, uint8 v, bytes32 r, bytes32 s) {} | ||
function withdraw_token(address token, uint256 amount, uint8 v, bytes32 r, bytes32 s) {} | ||
} | ||
``` | ||
- When someone deposits to that smart-contract, the Owshen Network's maintainer (The core application) will detect it, and will ***mint*** the amount deposited on the Owshen Network's imaginary blockchain. (No interactions with the smart-contract is needed). The user himself may let the Owshen Network's maintainer know that he has deposited some amount to the contract, by reporting his transaction-hash through a POST method: `https://api.owshen.io/deposit` | ||
- Owshen Network's core application hosts RPC endpoints on: `https://rpc.owshen.io` | ||
- Users may add Owshen Network's Network on their wallet (E.g Metamask) given the RPC endpoint and chain-id, and may see their minted balances. | ||
- Users should be able to see their deposited tokens on their Metamask wallets when they migrate their funds. | ||
- Users should be able to transfer their tokens to other users of the Owshen Network Network, using the Metamask wallet. The transfer requests are sent from Metamask, as signed Ethereum transactions, to the RPC endpoints, and ***the maintainer may verify the signature of the transaction himself***, and then apply it on the next block. User's should be able to transfer both native and erc-20 tokens. | ||
- There are two kinds of transactions that can be executed on Owshen Network blockchain. The transactions are either: | ||
1. Regular Ethereum transactions: Transactions that are created/signed by an Ethereum wallet (E.g Metamask) | ||
2. Owshen Network's custom transactions: Customized operations that are only valid on Owshen Network (E.g when the Owshen Network's maintainer wants to mint some tokens for some user, he may create and sign a Owshen Network ***mint*** transaction) | ||
- Owshen Network has a block explorer too, people may actually see their operations and verify Owshen Network maintainer's legitimate behavior. | ||
- Whenever someone wants to migrate his tokens back to the Ethereum blockchain, he may ask the Owshen Network maintainer to give him a signature, allowing him to call `withdraw_*` functions. The users may request their withdrawals through a POST endpoint: `https://api.owshen.io/withdraw`. The output of this endpoint is a signature that may be submitted on the network's Ethereum smart-contract and funds can be withdrawn. | ||
API Summary / Definition of Done: | ||
- `POST https://api.owshen.io/deposit`: Letting the core software know that a deposit has happened, minting the appropriate amount on the Owshen Network's imaginary blockchain. | ||
- `POST https://api.owshen.io/withdraw`: Asking the core software to sign a message that let's the user withdraw his tokens to the mainnet. | ||
- `GET https://api.owshen.io/explore?since=&count=`: Get JSON list of `count` blocks starting from `since` index. Used by the explorer software. | ||
- `https://rpc.owshen.io`: Metamask RPC endpoint that implements `eth_getBalance`, `eth_call`, `eth_sendRawTransaction` and etc. allowing the users to see his balances on Metamask, and send both native and etc-20 coins. | ||
### Phase 2 | ||
- We may add a new Owshen Network custom transaction, used for putting spot buy/sell orders on Owshen Network's internal matching engine. They may sign their orders through RLP encoded messages via Metamask, and submit them through a POST endpoint: `https://api.owshen.io/deposit` | ||
- We may add a rewarding system: according to the USD value you own on the network, you may receive DIVE amounts per block. | ||
- Users may deploy smart-contracts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
broadcast | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
# Targets | ||
.PHONY: deploy verify upgrade | ||
|
||
deploy: | ||
|
||
@echo "Deploying Owshen contract..." | ||
PRIVATE_KEY=$(PRIVATE_KEY) forge script script/Owshen.s.sol:DeployOwshen --broadcast --fork-url $(PROVIDER) | tee deploy_output.txt | ||
cat deploy_output.txt | grep "Transactions saved to:" | xargs -I @ python -c "print('@'.split(' ')[-1])" | xargs -I @ python -c "import json; d=json.load(open('@'));dt={'implementation_address': d['returns']['0']['value'], 'proxy_address': d['returns']['1']['value']}; dt.update({'abi': json.load(open('out/Owshen.sol/Owshen.json'))['abi']}); json.dump(dt, open('../config.json', 'w'), indent=4);" | ||
|
||
verify: | ||
@echo "verifying logic contract ..." | ||
forge verify-contract --chain-id $(CHAIN_ID) --etherscan-api-key $(ETHERSCAN_API) $(CONTRACT_ADDRESS) Owshen | ||
|
||
|
||
upgrade: | ||
@echo "upgrading owshen ... " | ||
PRIVATE_KEY=$(PRIVATE_KEY) PROXY_ADDRESS=$(PROXY_ADDRESS) forge script script/UpgradeOwshen.s.sol:UpgradeOwshen --broadcast --fork-url $(PROVIDER) | tee upgrade_output.txt | ||
|
||
|
||
clean: | ||
@echo "Cleaning build artifacts..." | ||
forge clean | ||
|
||
build: | ||
@echo "Compiling contracts..." | ||
forge build | ||
|
||
|
||
|
||
PRIVATE_KEY := | ||
PROVIDER := https://ethereum-sepolia-rpc.publicnode.com | ||
ETHERSCAN_API := | ||
PROXY_ADDRESS := | ||
CONTRACT_ADDRESS := | ||
CHAIN_ID := 11155111 |
Oops, something went wrong.