Skip to content

Commit

Permalink
Consensus Module (#15)
Browse files Browse the repository at this point in the history
meta merkle root code is inspired from
https://github.com/jito-foundation/distributor/tree/master

Note that generated_merkle_root code should be replaced by the incoming
Operator module

Still missing: ability to set epochs_before_stall and
valid_slots_after_consensus
  • Loading branch information
ebatsell authored Dec 5, 2024
1 parent 4f4db15 commit 022fee7
Show file tree
Hide file tree
Showing 64 changed files with 8,395 additions and 96 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ jobs:
crate: cargo-sort
- run: cargo sort --workspace --check
- run: cargo fmt --all --check
- run: cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf
- run: |
cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf
build:
name: build
Expand All @@ -105,11 +106,12 @@ jobs:
run: cargo-build-sbf
env:
TIP_ROUTER_PROGRAM_ID: ${{ env.TIP_ROUTER_PROGRAM_ID }}
SBF_OUT_DIR: ${{ github.workspace }}/target/sbf-solana-solana/release
- name: Upload MEV Tip Distribution NCN program
uses: actions/upload-artifact@v4
with:
name: jito_tip_router_program.so
path: target/sbf-solana-solana/release/jito_tip_router_program.so
path: target/sbf-solana-solana/release/
if-no-files-found: error

# coverage:
Expand Down Expand Up @@ -150,11 +152,13 @@ jobs:
uses: actions/download-artifact@v4
with:
name: jito_tip_router_program.so
path: target/sbf-solana-solana/release/
path: integration_tests/tests/fixtures/
- uses: taiki-e/install-action@nextest
- run: cargo nextest run --all-features
# Test the non-BPF tests and the BPF tests separately
- run: cargo nextest run --all-features -E 'not test(bpf)'
- run: cargo nextest run --all-features -E 'test(bpf)'
env:
SBF_OUT_DIR: ${{ github.workspace }}/target/sbf-solana-solana/release
SBF_OUT_DIR: ${{ github.workspace }}/integration_tests/tests/fixtures

# create_release:
# name: Create Release
Expand Down
67 changes: 61 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ members = [
"clients/rust/jito_tip_router",
"core",
"integration_tests",
"meta_merkle_tree",
"program",
"shank_cli"
"shank_cli",
"tip_distribution_sdk",
]

resolver = "2"
Expand All @@ -30,7 +32,7 @@ edition = "2021"
readme = "README.md"

[workspace.dependencies]
anchor-lang = { version = "0.30.1", features = ["idl-build"] }
anchor-lang = { version = "0.30.1" }
anyhow = "1.0.86"
assert_matches = "1.5.0"
borsh = { version = "0.10.3" }
Expand All @@ -41,13 +43,19 @@ clap = { version = "4.5.16", features = ["derive"] }
const_str_to_pubkey = "0.1.1"
envfile = "0.2.1"
env_logger = "0.10.2"
fast-math = "0.1"
getrandom = { version = "0.1.16", features = ["custom"] }

hex = "0.4.3"
log = "0.4.22"
matches = "0.1.10"
num-derive = "0.4.2"
num-traits = "0.2.19"
proc-macro2 = "1.0.86"
quote = "1.0.36"
rand = "0.8.5"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "1.0.102"
serde_with = "3.9.0"
shank = "0.4.2"
shank_idl = "0.4.2"
Expand All @@ -65,6 +73,9 @@ spl-token = { version = "4.0.0", features = ["no-entrypoint"] }
syn = "2.0.72"
thiserror = "1.0.57"
tokio = { version = "1.36.0", features = ["full"] }
meta-merkle-tree = { path = "./meta_merkle_tree", version = "=0.0.1" }
jito-tip-distribution-sdk = { path = "./tip_distribution_sdk", version = "=0.0.1" }
# jito-tip-distribution = { default-features = false, features = ["no-entrypoint", "no-idl"], git = "https://github.com/jito-foundation/jito-programs", rev = "2849874101336e7ef6ee93bb64b1354d5e682bb9" }
jito-tip-router-client = { path = "./clients/rust/jito_tip_router", version = "0.0.1" }
jito-tip-router-core = { path = "./core", version = "=0.0.1" }
jito-tip-router-program = { path = "./program", version = "=0.0.1" }
Expand Down
8 changes: 4 additions & 4 deletions clients/js/jito_tip_router/accounts/ballotBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
export type BallotBox = {
discriminator: bigint;
ncn: Address;
ncnEpoch: bigint;
epoch: bigint;
bump: number;
slotCreated: bigint;
slotConsensusReached: bigint;
Expand All @@ -67,7 +67,7 @@ export type BallotBox = {
export type BallotBoxArgs = {
discriminator: number | bigint;
ncn: Address;
ncnEpoch: number | bigint;
epoch: number | bigint;
bump: number;
slotCreated: number | bigint;
slotConsensusReached: number | bigint;
Expand All @@ -83,7 +83,7 @@ export function getBallotBoxEncoder(): Encoder<BallotBoxArgs> {
return getStructEncoder([
['discriminator', getU64Encoder()],
['ncn', getAddressEncoder()],
['ncnEpoch', getU64Encoder()],
['epoch', getU64Encoder()],
['bump', getU8Encoder()],
['slotCreated', getU64Encoder()],
['slotConsensusReached', getU64Encoder()],
Expand All @@ -100,7 +100,7 @@ export function getBallotBoxDecoder(): Decoder<BallotBox> {
return getStructDecoder([
['discriminator', getU64Decoder()],
['ncn', getAddressDecoder()],
['ncnEpoch', getU64Decoder()],
['epoch', getU64Decoder()],
['bump', getU8Decoder()],
['slotCreated', getU64Decoder()],
['slotConsensusReached', getU64Decoder()],
Expand Down
8 changes: 8 additions & 0 deletions clients/js/jito_tip_router/accounts/ncnConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type NcnConfig = {
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
validSlotsAfterConsensus: bigint;
epochsBeforeStall: bigint;
fees: Fees;
bump: number;
reserved: Array<number>;
Expand All @@ -56,6 +58,8 @@ export type NcnConfigArgs = {
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
validSlotsAfterConsensus: number | bigint;
epochsBeforeStall: number | bigint;
fees: FeesArgs;
bump: number;
reserved: Array<number>;
Expand All @@ -67,6 +71,8 @@ export function getNcnConfigEncoder(): Encoder<NcnConfigArgs> {
['ncn', getAddressEncoder()],
['tieBreakerAdmin', getAddressEncoder()],
['feeAdmin', getAddressEncoder()],
['validSlotsAfterConsensus', getU64Encoder()],
['epochsBeforeStall', getU64Encoder()],
['fees', getFeesEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 127 })],
Expand All @@ -79,6 +85,8 @@ export function getNcnConfigDecoder(): Decoder<NcnConfig> {
['ncn', getAddressDecoder()],
['tieBreakerAdmin', getAddressDecoder()],
['feeAdmin', getAddressDecoder()],
['validSlotsAfterConsensus', getU64Decoder()],
['epochsBeforeStall', getU64Decoder()],
['fees', getFeesDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 127 })],
Expand Down
Loading

0 comments on commit 022fee7

Please sign in to comment.