Skip to content

Commit

Permalink
auctioneer binary scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarreif committed Sep 25, 2024
1 parent 2da3a48 commit 4b85dbe
Show file tree
Hide file tree
Showing 16 changed files with 660 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
exclude = ["tools/protobuf-compiler", "tools/solidity-compiler"]

members = [
"crates/astria-auctioneer",
"crates/astria-bridge-contracts",
"crates/astria-bridge-withdrawer",
"crates/astria-build-info",
Expand Down
60 changes: 60 additions & 0 deletions crates/astria-auctioneer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[package]
name = "astria-auctioneer"
version = "0.0.1"
edition = "2021"
rust-version = "1.76"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/astriaorg/astria"
homepage = "https://astria.org"

[[bin]]
name = "astria-auctioneer"

[dependencies]
astria-build-info = { path = "../astria-build-info", features = ["runtime"] }
astria-core = { path = "../astria-core", features = ["serde", "server"] }
astria-eyre = { path = "../astria-eyre" }
config = { package = "astria-config", path = "../astria-config" }
telemetry = { package = "astria-telemetry", path = "../astria-telemetry", features = [
"display",
] }

async-trait = { workspace = true }
axum = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
pin-project-lite = { workspace = true }
prost = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true }
tokio = { workspace = true, features = [
"macros",
"rt-multi-thread",
"sync",
"time",
"signal",
] }
tokio-util = { workspace = true, features = ["rt"] }
tracing = { workspace = true, features = ["attributes"] }
tryhard = { workspace = true }
tonic = { workspace = true }
tokio-stream = { workspace = true, features = ["net"] }

[dev-dependencies]
astria-core = { path = "../astria-core", features = ["client"] }
config = { package = "astria-config", path = "../astria-config", features = [
"tests",
] }
insta = { workspace = true, features = ["json"] }
tempfile = { workspace = true }
test_utils = { package = "astria-test-utils", path = "../astria-test-utils", features = [
"geth",
] }
tokio-test = { workspace = true }
wiremock = { workspace = true }

[build-dependencies]
astria-build-info = { path = "../astria-build-info", features = ["build"] }
35 changes: 35 additions & 0 deletions crates/astria-auctioneer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Astria Auctioneer

TODO: Add a description of the binary.

## Running The Auctioneer

### Dependencies

We use [just](https://just.systems/man/en/chapter_4.html) for convenient project
specific commands.

### Configuration

The Auctioneer is configured via environment variables. An example configuration
can be seen in `local.env.example`.

To copy a configuration to your `.env` file run:

```sh

# Can specify an environment
just copy-env <ENVIRONMENT>

# By default will copy `local.env.example`
just copy-env
```

### Running locally

After creating a `.env` file either manually or by copying as above, `just` will
load it and run locally:

```bash
just run
```
4 changes: 4 additions & 0 deletions crates/astria-auctioneer/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
astria_build_info::emit("auctioneer-v")?;
Ok(())
}
12 changes: 12 additions & 0 deletions crates/astria-auctioneer/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default:
@just --list

set dotenv-load
set fallback

default_env := 'local'
copy-env type=default_env:
cp {{ type }}.env.example .env

run:
cargo run
91 changes: 91 additions & 0 deletions crates/astria-auctioneer/local.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Configuration options of Astria AUCTIONEER.

# Log level. One of debug, info, warn, or error
ASTRIA_AUCTIONEER_LOG="astria_AUCTIONEER=info"

# If true disables writing to the opentelemetry OTLP endpoint.
ASTRIA_AUCTIONEER_NO_OTEL=false

# If true disables tty detection and forces writing telemetry to stdout.
# If false span data is written to stdout only if it is connected to a tty.
ASTRIA_AUCTIONEER_FORCE_STDOUT=false

# If true uses an exceedingly pretty human readable format to write to stdout.
# If false uses JSON formatted OTEL traces.
# This does nothing unless stdout is connected to a tty or
# `ASTRIA_AUCTIONEER_FORCE_STDOUT` is set to `true`.
ASTRIA_AUCTIONEER_PRETTY_PRINT=false

# If set to any non-empty value removes ANSI escape characters from the pretty
# printed output. Note that this does nothing unless `ASTRIA_AUCTIONEER_PRETTY_PRINT`
# is set to `true`.
NO_COLOR=

# Address of the API server
ASTRIA_AUCTIONEER_API_ADDR="0.0.0.0:0"

# Address of the RPC server for the sequencer chain
ASTRIA_AUCTIONEER_SEQUENCER_URL="http://127.0.0.1:26657"

# Chain ID of the sequencer chain which transactions are submitted to.
ASTRIA_AUCTIONEER_SEQUENCER_CHAIN_ID="astria-dev-1"

# A list of execution `<rollup_name_1>::<rpc_server_1>,<rollup_name_2>::<rpc_server_2>`.
# Rollup names are not case sensitive. If a name is repeated, the last list item is used.
# names are sha256 hashed and used as the `rollup_id` in `SequenceAction`s
ASTRIA_AUCTIONEER_ROLLUPS="astriachain::ws://127.0.0.1:8545"

# The path to the file storing the private key for the sequencer account used for signing
# transactions. The file should contain a hex-encoded Ed25519 secret key.
ASTRIA_AUCTIONEER_PRIVATE_KEY_FILE=/path/to/priv_sequencer_key.json

# The prefix that will be used to construct bech32m sequencer addresses.
ASTRIA_AUCTIONEER_SEQUENCER_ADDRESS_PREFIX=astria

# Block time in milliseconds, used to force submitting of finished bundles.
# Should match the sequencer node configuration for 'timeout_commit', as
# specified in https://docs.tendermint.com/v0.34/tendermint-core/configuration.html
ASTRIA_AUCTIONEER_MAX_SUBMIT_INTERVAL_MS=2000

# Max bytes to encode into a single sequencer `SignedTransaction`, not including signature,
# public key, nonce. This is the sum of the sizes of all the `SequenceAction`s. Should be
# set below the sequencer's max block size to allow space for encoding, signature, public
# key and nonce bytes
ASTRIA_AUCTIONEER_MAX_BYTES_PER_BUNDLE=200000

# Max amount of finished bundles that can be in the submission queue.
# ASTRIA_AUCTIONEER_BUNDLE_QUEUE_CAPACITY * ASTRIA_AUCTIONEER_MAX_BYTES_PER_BUNDLE (e.g.
# 40000 * 200KB=8GB) is the limit on how much memory the finished bundle queue can consume.
# This should be lower than the resource limit enforced by Kubernetes on the pod, defined here:
# https://github.com/astriaorg/astria/blob/622d4cb8695e4fbcd86456bd16149420b8acda79/charts/evm-rollup/values.yaml#L276
ASTRIA_AUCTIONEER_BUNDLE_QUEUE_CAPACITY=40000

# Set to true to enable prometheus metrics.
ASTRIA_AUCTIONEER_NO_METRICS=true

# The address at which the prometheus HTTP listener will bind if enabled.
ASTRIA_AUCTIONEER_METRICS_HTTP_LISTENER_ADDR="127.0.0.1:9000"

# The address at which the gRPC collector and health services are listening.
ASTRIA_AUCTIONEER_GRPC_ADDR="0.0.0.0:0"

# The asset to use for paying for transactions submitted to sequencer.
ASTRIA_AUCTIONEER_FEE_ASSET="nria"

# The OTEL specific config options follow the OpenTelemetry Protocol Exporter v1
# specification as defined here:
# https://github.com/open-telemetry/opentelemetry-specification/blob/e94af89e3d0c01de30127a0f423e912f6cda7bed/specification/protocol/exporter.md

# Sets the general OTLP endpoint.
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
# Sets the OTLP endpoint for trace data. This takes precedence over `OTEL_EXPORTER_OTLP_ENDPOINT` if set.
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://localhost:4317/v1/traces"
# The duration in seconds that the OTEL exporter will wait for each batch export.
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT=10
# The compression format to use for exporting. Only `"gzip"` is supported.
# Don't set the env var if no compression is required.
OTEL_EXPORTER_OTLP_TRACES_COMPRESSION="gzip"
# The HTTP headers that will be set when sending gRPC requests.
OTEL_EXPORTER_OTLP_HEADERS="key1=value1,key2=value2"
# The HTTP headers that will be set when sending gRPC requests. This takes precedence over `OTEL_EXPORTER_OTLP_HEADERS` if set.
OTEL_EXPORTER_OTLP_TRACE_HEADERS="key1=value1,key2=value2"
20 changes: 20 additions & 0 deletions crates/astria-auctioneer/src/auction_driver/builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use astria_eyre::eyre;

use super::AuctionDriver;
use crate::Metrics;

pub(crate) struct Builder {
pub(crate) metrics: &'static Metrics,
}

impl Builder {
pub(crate) fn build(self) -> eyre::Result<AuctionDriver> {
let Self {
metrics,
} = self;

Ok(AuctionDriver {
metrics,
})
}
}
17 changes: 17 additions & 0 deletions crates/astria-auctioneer/src/auction_driver/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use astria_eyre::eyre;

use crate::Metrics;

mod builder;
pub(crate) use builder::Builder;

pub(crate) struct AuctionDriver {
#[allow(dead_code)]
metrics: &'static Metrics,
}

impl AuctionDriver {
pub(crate) async fn run(self) -> eyre::Result<()> {
todo!("implement me")
}
}
Loading

0 comments on commit 4b85dbe

Please sign in to comment.