Skip to content

Commit

Permalink
electra, but no connection
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFlicker committed Jan 16, 2024
1 parent d5c9b77 commit a1f2e61
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 19 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cblock",
"cbor",
"Claimables",
"electrs",
"fundings",
"inscriptor",
"localstack",
Expand Down
8 changes: 8 additions & 0 deletions deploy/bitcoin/config.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ BITCOIN_FOLDER=dirname $BITCOIN_ARCHIVE
DATA_DIR_S3={{data_dir_s3}}
DATA_DIR={{data_dir}}
BLOCKCHAIN_DATA={{blockchain_data}}
ELECTRS_INDEX_DATA_S3={{electrs_index_data_s3}}
ELECTRS_INDEX_DATA={{electrs_index_data}}

# extract node
cd $NODE_FOLDER
tar -xJf $NODE_ARCHIVE
mv node*/bin/* /usr/local/bin
rm -rf node-*

# extract electrs index
mkdir -p $ELECTRS_INDEX_DATA
cd $ELECTRS_INDEX_DATA
aws s3 cp $ELECTRS_INDEX_DATA_S3 - | tar xzf -

# extract bitcoin
cd $BITCOIN_FOLDER
tar xzf $BITCOIN_ARCHIVE
Expand All @@ -27,3 +34,4 @@ aws s3 cp $DATA_DIR_S3 - | tar xzf -

# assign ownership to ec2-user
chown -R ec2-user:ec2-user $BLOCKCHAIN_DATA
chown -R ec2-user:ec2-user $ELECTRS_INDEX_DATA
10 changes: 10 additions & 0 deletions deploy/bitcoin/testnet/cloudwatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
"file_path": "/home/ec2-user/bitcoin.stdout.log",
"log_group_name": "bitcoin-testnet-stdout-log",
"log_stream_name": "{instance_id}"
},
{
"file_path": "/home/ec2-user/electrs.stderr.log",
"log_group_name": "electrs-testnet-stderr-log",
"log_stream_name": "{instance_id}"
},
{
"file_path": "/home/ec2-user/electrs.stdout.log",
"log_group_name": "electrs-testnet-stdout-log",
"log_stream_name": "{instance_id}"
}
]
}
Expand Down
22 changes: 22 additions & 0 deletions deploy/electrs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use Amazon Linux 2023 as the base image
FROM public.ecr.aws/amazonlinux/amazonlinux:2023

# Install Rust and cross-compilation dependencies
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN yum update -y
RUN yum install -y gcc gcc-c++ openssl-devel
RUN rustup target add aarch64-unknown-linux-gnu

# Install cross-compilation tools
RUN yum install -y gcc-aarch64-linux-gnu glibc-static

# Copy the Rust project files to the container
WORKDIR /usr/src/myapp
COPY . .

# Build the project for aarch64
RUN cargo build --release --target=aarch64-unknown-linux-gnu

# The binary will be at /usr/src/myapp/target/aarch64-unknown-linux-gnu/release
CMD ["./target/aarch64-unknown-linux-gnu/release/myapp"]
Binary file added deploy/electrs/electrs
Binary file not shown.
5 changes: 5 additions & 0 deletions deploy/electrs/testnet/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cookie_file = "/home/ec2-user/.bitcoin/testnet3/.cookie"
db_dir = "/home/ec2-user/db"
network = "testnet"
electrum_rpc_addr = "0.0.0.0:60001"
log_filters = "DEBUG"
8 changes: 8 additions & 0 deletions deploy/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from "path";
import { fileURLToPath } from "url";
import { BackendStack } from "./stack.js";
import { BitcoinExeStack, BitcoinStack } from "./bitcoin/stack.js";
import { ElectrsDeploymentStack } from "./bitcoin/electrs-build.js";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -40,3 +41,10 @@ new BitcoinStack(app, "bitcoin-testnet", {
region: "us-west-2",
},
});

new ElectrsDeploymentStack(app, "electrs-build", {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: "us-west-2",
},
});
Loading

0 comments on commit a1f2e61

Please sign in to comment.