Skip to content

Commit

Permalink
RPC456 adding errors when incorrect parameter is passed on API and ad…
Browse files Browse the repository at this point in the history
…ding support to run tests in github
  • Loading branch information
dmitriy-helius committed Aug 22, 2024
1 parent fe95448 commit 3606eac
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 46 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Overview

- Summary of changes

## Testing

- Testing performed to validate the changes
54 changes: 54 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
pull_request:
branches: [main]

jobs:

changes:
runs-on: ubuntu-latest
outputs:
fee-estimator: ${{ steps.filter.outputs.fee-estimator}}
steps:
- uses: actions/checkout@v3
- uses: dorny/[email protected]
id: filter
with:
filters: |
fee-estimator:
- '*/**'
fee-estimator-tests:
needs: changes
if: ${{ needs.changes.outputs.fee-estimator == 'true' }}
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: stable
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: 'true'
RUSTC_WRAPPER: 'sccache'
ENV: 'test'
steps:
- uses: actions/checkout@v4
- name: Cleanup Apt
run: sudo find /var/lib/apt/lists/ -type 'f' -name 'archive*' -delete && sudo apt-get update
- uses: rui314/setup-mold@v1
with:
mold-version: 1.1.1
make-default: true
- name: Ensure we use Mold
run: sudo ln -s /usr/local/bin/ld.mold /usr/bin/ld.lld
- name: Install rust + caching
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: '-C link-arg=-fuse-ld=lld'
components: rustfmt, clippy
- name: Set up sccache
uses: mozilla-actions/[email protected]
- name: Clear sccache stats
run: sccache --zero-stats
- name: Run Tests
run: |
cargo test -- --nocapture
74 changes: 72 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,72 @@
.vscode/
target/
# Javascript/Typescript
node_modules/
dist/
build/
coverage/
vendor/

# Node Logs
logs
*.log
npm-debug.log*
AWSCLIV2.pkg

# Mac
**/.DS_Store

# IDEs
**/.vscode
**/.idea/

# Services
ts-services/parser-lambda/parser/test/data/local/*
ts-services/parser-lambda/parser/test/output/*
ts-services/parser-lambda/parser/playground.ts

# Secrets
ts-services/dev-api-lambda/crypto-billing/*_secrets.ts
infra/ansible/vars/**/*-secrets.yaml
infra/ansible/vars/**/*-secrets.yml
infra/ansible/photon/vars/*-secrets.yaml
infra/ansible/photon/vars/*-secrets.yml
infra/ansible/rpc/templates/bt-creds*.json

# Rust
**/target/

# CPU profiles
*.cpuprofile

# Built helm charts
infra/**/*.tgz

.gradle
.m2
bin

# Build output directies
/target
*/target
/build
*/build

# Local Redis
dump.rdb

infra/ansible/roles/Datadog.datadog
infra/ansible/photon/roles/datadog.datadog


scripts/data

# Jupyter notebooks
*.ipynb

# Personal Playground
personal_playground


# Used for local deployments of RPC operator
/rpc-operator/
**/systest/*.json
**/router-benchmarks/*.json
4 changes: 1 addition & 3 deletions src/grpc_geyser.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::Instant;
use std::{collections::HashMap, time::Duration};

use cadence_macros::statsd_count;
use futures::{future::TryFutureExt, sink::SinkExt, stream::StreamExt};
use futures::{sink::SinkExt, stream::StreamExt};
use rand::distributions::Alphanumeric;
use rand::Rng;
use tokio::time::sleep;
Expand Down
13 changes: 6 additions & 7 deletions src/priority_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use solana_sdk::{pubkey::Pubkey, slot_history::Slot};
use tracing::error;
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
use yellowstone_grpc_proto::geyser::SubscribeUpdate;

use crate::grpc_consumer::GrpcConsumer;
use crate::rpc_server::get_recommended_fee;
use crate::slot_cache::SlotCache;

#[derive(Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum PriorityLevel {
Min, // 0th percentile
Low, // 25th percentile
Expand Down Expand Up @@ -244,7 +243,7 @@ impl PriorityFeeTracker {
});
}

fn push_priority_fee_for_txn(
pub fn push_priority_fee_for_txn(
&self,
slot: Slot,
accounts: Vec<Pubkey>,
Expand Down Expand Up @@ -279,7 +278,7 @@ impl PriorityFeeTracker {
&self,
accounts: Vec<Pubkey>,
include_vote: bool,
lookback_period: Option<usize>,
lookback_period: Option<u32>,
) -> MicroLamportPriorityFeeEstimates {
let start = std::time::Instant::now();
let mut account_fees = vec![];
Expand Down Expand Up @@ -403,7 +402,7 @@ mod tests {
set_global_default(client)
}

#[tokio::test]
#[tokio::test(flavor = "current_thread")]
async fn test_specific_fee_estimates() {
init_metrics();
let tracker = PriorityFeeTracker::new(10);
Expand Down Expand Up @@ -442,7 +441,7 @@ mod tests {
assert_eq!(estimates.unsafe_max, expected_max_fee);
}

#[tokio::test]
#[tokio::test(flavor = "current_thread")]
async fn test_with_many_slots() {
init_metrics();
let tracker = PriorityFeeTracker::new(101);
Expand Down Expand Up @@ -482,7 +481,7 @@ mod tests {
assert_eq!(estimates.unsafe_max, expected_max_fee);
}

#[tokio::test]
#[tokio::test(flavor = "current_thread")]
async fn test_with_many_slots_broken() {
// same test as above but with an extra slot to throw off the value
init_metrics();
Expand Down
Loading

0 comments on commit 3606eac

Please sign in to comment.