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

Absorb reward manager #1726

Merged
merged 11 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,6 @@ workflows:

- test-solana-programs:
name: test-solana-programs
- docker-build-and-push:
dmanjunath marked this conversation as resolved.
Show resolved Hide resolved
name: build-solana-programs
repo: solana-programs
requires:
- test-solana-programs

- test-mad-dog-e2e

Expand Down
6 changes: 3 additions & 3 deletions service-commands/src/commands/service-commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"solana-programs": {
"path": "solana-programs",
"up": [
"docker run -d --name solana --publish 8899:8899/tcp --network audius_dev --entrypoint='' solanalabs/solana:v1.6.10 sh -c 'solana-test-validator --gossip-host solana'",
"docker run -d --name solana --publish 8899:8899/tcp --network audius_dev --entrypoint='' solanalabs/solana:v1.7.1 sh -c 'solana-test-validator --gossip-host solana'",
"docker ps",
"cd solana-programs/; docker run --network audius_dev -e SOLANA_HOST='http://solana:8899' -v \"$PWD:/mnt\" audius/solana-programs > solana-program-config.json",
"cd solana-programs/; cp solana-program-config.json ../identity-service",
"cd solana-programs/; docker run --network audius_dev -e SOLANA_HOST='http://solana:8899' -v \"$PWD:/usr/src/app\" audius/solana-programs:develop > solana-program-config.json",
"cd solana-programs/; cat solana-program-config.json; cp solana-program-config.json ../identity-service",
"mkdir -p ~/.audius; cd solana-programs/; cp solana-program-config.json ~/.audius/solana-program-config.json"
],
"down": [
Expand Down
9 changes: 7 additions & 2 deletions solana-programs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ RUN apt-get update && \
apt-get install -y jq curl build-essential libudev-dev libhidapi-dev pkg-config libssl-dev git python-is-python3 python3-pip && \
pip3 install --no-cache-dir web3 && \
curl -s --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
sh -c "$(curl -sSfL https://release.solana.com/v1.6.1/install)"
sh -c "$(curl -sSfL https://release.solana.com/v1.7.8/install)"

ENV PATH="/root/.cargo/bin:/root/.local/share/solana/install/active_release/bin:${PATH}"

COPY audius_eth_registry audius_eth_registry
COPY track_listen_count track_listen_count
COPY cli cli
COPY claimable-tokens claimable-tokens
COPY reward-manager reward-manager

RUN cd audius_eth_registry && \
cargo build-bpf && \
Expand All @@ -27,8 +28,12 @@ RUN cd audius_eth_registry && \
cd ../claimable-tokens/program && \
cargo build-bpf && \
cd ../cli && \
cargo build && \
cd ../../reward-manager/program && \
cargo build-bpf && \
cd ../cli && \
hareeshnagaraj marked this conversation as resolved.
Show resolved Hide resolved
cargo build

COPY start.sh ./

CMD [ "sh", "-c", "cp -r /mnt/* ./; sh start.sh" ]
CMD [ "bash", "start.sh" ]
35 changes: 35 additions & 0 deletions solana-programs/reward-manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# JetBrains
.idea/

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Misc
.DS_Store
._*
.Spotlight-V100
.Trashes

# ESLint
.eslintcache

# Build and test
dist/
build/
coverage/
target/

# Cache
.cache/

# Env
*keypair.json
*.so
5 changes: 5 additions & 0 deletions solana-programs/reward-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"program",
"cli",
]
13 changes: 13 additions & 0 deletions solana-programs/reward-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# About

Audius Reward Manager will be a program which allows trusted node operators (identified by their Ethereum Addresses) to distribute rewards to the users.

# Operation

Node operators (or senders) will be using their own business logic to identify which users need to be rewarded with tokens. Each reward can be sent to the user only once, so there will be a unique identifier (called `specifier`) ensuring just a single payout. Also the reward payout can happen only if several senders agree on it (3 for example).

There is also a separate type of the sender called `bot oracle`. This will be a sender operated by the Audius and while any 3 senders can sign the reward transfer, all transfers also require a signature by the `bot oracle` and messages from the senders also should specify the same `bot oracle` address.

After signatures from 3 senders and `bot oracle` are verified the tokens are transferred and we create and maintain a `transfer` record which will store an account in the blockchain derived from the `specifier` ensuring no other transfer with the same ID happens again.

All the signatures are verified using secp256k1 instruction (several of them for several signatures).
31 changes: 31 additions & 0 deletions solana-programs/reward-manager/cli/COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Commands
### Init market
```
spl-token create-token t1_keypair.json && \
cargo run init --keypair locnet_keypair.json --token-mint CV3A2AbeKc4CoRRcyWwe96LkPktpaPnUAgnzqJVy6wKf --min-votes 3
```
### Create senders
```
cargo run create-sender --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --eth-sender-address 0xd63cF911A8F8991cA8eFa9De7cCA3d1d370ec60C --eth-operator-address 0xf3a628104B0124b82E3c956Efd6271595E1407e0 && \
cargo run create-sender --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --eth-sender-address 0xdD4B7F49d6392b53b5f1a43Ba4FbFd4617E5016E --eth-operator-address 0xF0BA54Ca13cD89e62Ec2a6B908388A7Ab6C44Ab9 && \
cargo run create-sender --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --eth-sender-address 0x5AB13DCAF366D582FA72322A485BCbc410a8C1e7 --eth-operator-address 0x808a8d9B6D9b28FF0b9b2cfe3fEC47655bEd4463 && \
cargo run create-sender --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --eth-sender-address 0x3cc097d8552B555d93aD9a0f07c1D9922dfa2d70 --eth-operator-address 0x2892e8b9adCd2538e31bF692dB98facfC112178c
```
### Creating bot message
```
cargo run verify-transfer-signature --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --keypair locnet_verify_keypair.json --address 464fNyy1Pc7ovcsmGJynLWU4dxyT7GfyXXhuvrRJSbUB --secret f11081e12549e5f7faddfee0313fb44077fb4a9723a912bbb9fd8a04591d45f0 --transfer-id abc123 --recipient 0xaDf719618118224508c1fC1ef36ca45234B354E6 --amount 0.5
```
### Creating sender messages
```
cargo run verify-transfer-signature --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --pubkey CH3iDZ9jB7T7bXUR2d6u969JV9p9s7BVcAV3baKVaCM8 --address HhiAcsMvXbrxgSMDRQqKFtNgqT3LVEFNgsrQchwJz7tS --secret 9b4f73069739bc1d3f8e5ac54ff814dbad791c04a00762d559bf508d7cb8903b --transfer-id abc123 --recipient 0xaDf719618118224508c1fC1ef36ca45234B354E6 --amount 0.5 --bot-oracle 464fNyy1Pc7ovcsmGJynLWU4dxyT7GfyXXhuvrRJSbUB && \
cargo run verify-transfer-signature --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --pubkey CH3iDZ9jB7T7bXUR2d6u969JV9p9s7BVcAV3baKVaCM8 --address CpWrZv62RFkAH5s9EvWYiNhVnhYxBZHrCQ6TM29hA5NM --secret df41e24a223c51dcaaa28199473fff3c7eabf6e7150b9e242c078f5772a36bf8 --transfer-id abc123 --recipient 0xaDf719618118224508c1fC1ef36ca45234B354E6 --amount 0.5 --bot-oracle 464fNyy1Pc7ovcsmGJynLWU4dxyT7GfyXXhuvrRJSbUB && \
cargo run verify-transfer-signature --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --pubkey CH3iDZ9jB7T7bXUR2d6u969JV9p9s7BVcAV3baKVaCM8 --address FmDEPVLbmCPMLzhkwivsg2r3aGeWJWjaaBht3Ymd8Hhd --secret 5a8cb969f93f541bbe3ed34dfcc4a74cb13a9a07ad4b23be29d266edae12afa0 --transfer-id abc123 --recipient 0xaDf719618118224508c1fC1ef36ca45234B354E6 --amount 0.5 --bot-oracle 464fNyy1Pc7ovcsmGJynLWU4dxyT7GfyXXhuvrRJSbUB
```
### Mint
```
spl-token mint CV3A2AbeKc4CoRRcyWwe96LkPktpaPnUAgnzqJVy6wKf 100000000 7EtBB4PYBvvRvRDXXXfEEYrJNkU47m1o8B7XNw6Sw5dP
```
### Complete transfer
```
cargo run transfer --reward-manager 4P2WtU2RayKhRc1pfjJP5M9JmVVWZQi91za2ugJvHumG --verified-messages CH3iDZ9jB7T7bXUR2d6u969JV9p9s7BVcAV3baKVaCM8 --transfer-id abc123 --recipient 0xaDf719618118224508c1fC1ef36ca45234B354E6 --amount 0.5 --bot-oracle 464fNyy1Pc7ovcsmGJynLWU4dxyT7GfyXXhuvrRJSbUB
```
32 changes: 32 additions & 0 deletions solana-programs/reward-manager/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "audius-cli"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "2.33.3"
serde_json = "1.0.61"
solana-account-decoder = "1.7.3"
solana-clap-utils = "1.7.3"
solana-cli-config = "1.7.3"
solana-client = "1.7.3"
solana-logger = "1.7.3"
solana-sdk = "1.7.3"
solana-program = "1.7.3"
borsh = "0.8.2"
regex = "1.5.4"
bincode = "1.3.1"
serde = "1.0.55"
csv = "1.1.6"
hex = "0.4.3"
sha3 = "0.9.1"
libsecp256k1 = "0.5.0"
audius-reward-manager = { path="../program", features = [ "no-entrypoint" ] }
spl-token = { git = "https://github.com/solana-labs/solana-program-library.git", features = [ "no-entrypoint" ] }
claimable-tokens = { path = "../../claimable-tokens/program", features = [ "no-entrypoint" ] }

[[bin]]
name = "audius-cli"
path = "src/main.rs"
Loading