Arbiter Engine
arbiter-engine
provides the machinery to build agent based / event driven simulations and should be the primary entrypoint for using Arbiter.
The goal of this crate is to abstract away the work required to set up agents, their behaviors, and the worlds they live in.
At the moment, all interaction of agents is done through the arbiter-core
crate and is meant to be for local simulations and it is not yet generalized for the case of live network automation.
Hierarchy
The primary components of arbiter-engine
are, from the bottom up:
Behavior<E>
: This is an event-driven behavior that takes in some item of typeE
and can act on that. TheBehavior<E>
has two methods:startup
andprocess
.startup
is meant to initialize theBehavior<E>
and any context around it. An example could be an agent that deploys token contracts on startup.process
is meant to be a stage that runs on every event that comes in. An example could be an agent that deployed token contracts on startup, and now wants to process queries about the tokens deployed in the simulation (e.g., what their addresses are).
Engine<B,E>
andStateMachine
: TheEngine
is a struct that implements theStateMachine
trait as an entrypoint to runBehavior
s.Engine<B,E>
is a struct owns aB: Behavior<E>
and the event streamStream<Item = E>
that theBehavior<E>
will use for processing.StateMachine
is a trait that reduces the interface toEngine<B,E>
to a single method:execute
. This trait allowsAgent
s to have multiple behaviors that may not use the same event type.
Agent
a struct that contains an ID, a client (Arc<RevmMiddleware>
) that provides means to send calls and transactions to an ArbiterEnvironment
, and aMessager
.Messager
is a struct that owns aSender
andReceiver
for sending and receiving messages. This is a way forAgent
s to communicate with each other. It can also be streamed and used for processing messages in aBehavior<Message>
.Agent
also owns aVec<Box<dyn StateMachine>>
which is a list ofStateMachine
s that theAgent
will run. This is a way forAgent
s to have multipleBehavior
s that may not use the same event type.
World
is a struct that has an ID, an ArbiterEnvironment
, a mapping ofAgent
s, and aMessager
.- The
World
is tasked with lettingAgent
s join in, and when they do so, to connect them to theEnvironment
with a client andMessager
with theAgent
's ID.
- The
Universe
is a struct that wraps a mapping ofWorld
s.- The
Universe
is tasked with lettingWorld
s join in and running thoseWorld
s in parallel.
- The