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 typeEand can act on that. TheBehavior<E>has two methods:startupandprocess.startupis meant to initialize theBehavior<E>and any context around it. An example could be an agent that deploys token contracts on startup.processis 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: TheEngineis a struct that implements theStateMachinetrait as an entrypoint to runBehaviors.Engine<B,E>is a struct owns aB: Behavior<E>and the event streamStream<Item = E>that theBehavior<E>will use for processing.StateMachineis a trait that reduces the interface toEngine<B,E>to a single method:execute. This trait allowsAgents to have multiple behaviors that may not use the same event type.
Agenta struct that contains an ID, a client (Arc<RevmMiddleware>) that provides means to send calls and transactions to an ArbiterEnvironment, and aMessager.Messageris a struct that owns aSenderandReceiverfor sending and receiving messages. This is a way forAgents to communicate with each other. It can also be streamed and used for processing messages in aBehavior<Message>.Agentalso owns aVec<Box<dyn StateMachine>>which is a list ofStateMachines that theAgentwill run. This is a way forAgents to have multipleBehaviors that may not use the same event type.
Worldis a struct that has an ID, an ArbiterEnvironment, a mapping ofAgents, and aMessager.- The
Worldis tasked with lettingAgents join in, and when they do so, to connect them to theEnvironmentwith a client andMessagerwith theAgent's ID.
- The
Universeis a struct that wraps a mapping ofWorlds.- The
Universeis tasked with lettingWorlds join in and running thoseWorlds in parallel.
- The