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

Refactor/test/behaviors #137

Merged
merged 14 commits into from
Apr 26, 2024
6 changes: 3 additions & 3 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
toolchain: nightly
- name: test
run: cargo test --workspace --all-features
run: cargo +nightly test --workspace --all-features

clippy:
name: clippy
Expand All @@ -28,10 +28,10 @@ jobs:
- name: install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.75.0
toolchain: nightly
components: clippy
- name: cargo clippy
run: cargo clippy --workspace --all-features -- -D warnings
run: cargo +nightly clippy --workspace --all-features -- -D warnings

udeps:
name: udeps
Expand Down
125 changes: 6 additions & 119 deletions Cargo.lock

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

13 changes: 6 additions & 7 deletions kit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ keywords = ["ethereum", "smart-contracts", "automated market makers"]
readme = "../README.md"

[dependencies]
arbiter-core = { git = "https://github.com/primitivefinance/arbiter.git", rev = "aff29d30" }
arbiter-engine = { git = "https://github.com/primitivefinance/arbiter.git", rev = "aff29d30" }
arbiter-macros = { git = "https://github.com/primitivefinance/arbiter.git", rev = "aff29d30" }
arbiter-bindings = { git = "https://github.com/primitivefinance/arbiter.git", rev = "aff29d30" }
arbiter-core = { git = "https://github.com/primitivefinance/arbiter.git", rev = "d5bc1bb3" }
arbiter-engine = { git = "https://github.com/primitivefinance/arbiter.git", rev = "d5bc1bb3" }
arbiter-macros = { git = "https://github.com/primitivefinance/arbiter.git", rev = "d5bc1bb3" }
arbiter-bindings = { git = "https://github.com/primitivefinance/arbiter.git", rev = "d5bc1bb3" }

# Ethereum
ethers = "2.0.13"
Expand All @@ -29,10 +29,9 @@ serde_json = "1.0.114"
# Errors and tracing
anyhow = "1.0.81"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

# CLI
clap = { version = "4.5.1", features = ["derive"] }
[dev-dependencies]
tracing-subscriber = "0.3.18"

[[bin]]
name = "kit"
Expand Down
37 changes: 14 additions & 23 deletions kit/src/behaviors/allocate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use super::*;

pub trait AllocateType<E>: Debug + Serialize + Clone
pub trait AllocateType<E>
where
E: Send + 'static,
{
// TODO: This should probably be how we do it, but this generic `P` gets
// annoying fn change_allocation_amount(&mut self, event: E) ->
// Option<P::AllocationData>;
fn change_allocation_amount(&mut self, event: E) -> Option<Vec<eI256>>;
fn get_stream(&self) -> Pin<Box<dyn Stream<Item = E> + Send + Sync>>;
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand All @@ -24,11 +23,12 @@ where
_phantom_e: PhantomData<E>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, State)]
pub struct Config<P: PoolType> {
pub allocation_data: P::AllocationData,
}

#[derive(State)]
pub struct Processing<P, E>
where
P: PoolType,
Expand All @@ -40,43 +40,34 @@ where
_phantom: PhantomData<E>,
}

impl<P: PoolType> State for Config<P> {
type Data = Self;
}

impl<P, E> State for Processing<P, E>
where
P: PoolType,
E: Send + 'static,
{
type Data = Self;
}

#[allow(unused_variables)]
#[async_trait::async_trait]
impl<A, P, E> Behavior<E> for Allocate<A, E, Config<P>>
where
A: AllocateType<E> + Debug + Send + Sync + 'static + for<'a> Deserialize<'a>,
P: PoolType + Debug + Send + Sync + 'static,
E: Debug + Send + Sync + 'static,
A: AllocateType<E> + Send,
P: PoolType + Send,
E: Send + 'static,
{
type Processor = Allocate<A, E, Processing<P, E>>;
async fn startup(
&mut self,
mut self,
client: Arc<ArbiterMiddleware>,
messager: Messager,
) -> Result<Option<(Self::Processor, EventStream<E>)>> {
) -> Result<Self::Processor> {
todo!();
}
}

#[async_trait::async_trait]
impl<A, P, E> Processor<E> for Allocate<A, E, Processing<P, E>>
where
A: AllocateType<E> + Debug + Send + Sync + 'static,
P: PoolType + Debug + Send + Sync + 'static,
E: Debug + Send + Sync + 'static,
A: AllocateType<E> + Send,
P: PoolType + Send,
E: Send + 'static,
{
async fn get_stream(&mut self) -> Result<Option<EventStream<E>>> {
todo!("We have not implemented the 'get_stream' method yet for the 'Allocate' behavior.");
}
async fn process(&mut self, _event: E) -> Result<ControlFlow> {
Ok(ControlFlow::Halt)
}
Expand Down
Loading
Loading