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

Development #10

Merged
merged 17 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
target
.github
.git
.alys
**/assertoor
**/data
**/ethereum-metrics-exporter
**/grafana
**/jwttoken
**/prometheus
**/docker-compose.yml
docs
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: ./etc/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ docs/book/

# Sidechain
/.alys
/data/execution
/data/logs
/etc/data/

# Mac
.DS_Store
Expand Down
35 changes: 34 additions & 1 deletion app/src/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Aura {
let authority = if let Some(signer) = maybe_signer {
let index = authorities
.iter()
.position(|x| signer.pk.eq(x))
.position(|x| signer.pk.eq(&x))
.expect("Authority not found in set") as u8;
Some(Authority { index, signer })
} else {
Expand Down Expand Up @@ -245,6 +245,8 @@ impl<DB: ItemStore<MainnetEthSpec>> AuraSlotWorker<DB> {
#[cfg(test)]
mod test {
use super::*;
use bls::SecretKey;
use hex;

#[test]
fn should_find_slot_author() {
Expand All @@ -255,4 +257,35 @@ mod test {
6
);
}

#[test]
fn should_find_authority() {
// Replace with your secret key
let secret_key_hex = "0000000000000000000000000000000000000000000000000000000000000001";

// Convert the secret key from hex to bytes
let secret_key_bytes = hex::decode(secret_key_hex).unwrap();

// Create a SecretKey instance from the bytes
let aura_sk = SecretKey::deserialize(&secret_key_bytes[..]).unwrap();

let aura_pk = aura_sk.public_key();

let aura_signer = Keypair::from_components(aura_pk, aura_sk);

let aura_authority_key_hex = "97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb";

let aura_authority_key_bytes = hex::decode(aura_authority_key_hex).unwrap();

let aura_authority_key = PublicKey::deserialize(&aura_authority_key_bytes[..]).unwrap();

let authorities = vec![aura_authority_key];

let authority = {
let index = authorities
.iter()
.position(|x| aura_signer.pk.eq(&x))
.expect("Authority not found in set") as u8;
};
}
}
30 changes: 24 additions & 6 deletions crates/federation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod bitcoin_signing;
mod bitcoin_stream;
use thiserror::Error;

use bdk::bitcoin::hashes::hex::FromHex;
pub use bitcoin_stream::bitcoin;

use bitcoin::{Address as BitcoinAddress, BlockHash, Transaction, TxOut, Txid};
Expand Down Expand Up @@ -162,13 +162,31 @@ impl Bridge {
block_height: u32,
) -> Option<PegInInfo> {
fn extract_evm_address(tx_out: &TxOut) -> Option<H160> {
const OP_RETURN: u8 = 0x6a;
match tx_out.script_pubkey.as_bytes() {
&[OP_RETURN, 20, ref addr @ ..] if addr.len() == 20_usize => {
Some(H160::from_slice(addr))
if !tx_out.script_pubkey.is_provably_unspendable() || !tx_out.script_pubkey.is_op_return() {
return None;
}
let opreturn = tx_out.script_pubkey.to_asm_string();
let parts = opreturn.split(' ');
let op_return_parts = parts.collect::<Vec<&str>>();
let op_return_hex_string = op_return_parts[op_return_parts.len() - 1].to_string();
let data = Vec::from_hex(&op_return_hex_string);
if let Err(_e) = data {
return None;
}
let opreturn_data = String::from_utf8(data.clone().unwrap());
if let Err(_e) = opreturn_data.clone() {
let address = H160::from_str(&op_return_hex_string);
if let Err(_e) = address {
return None;
}
_ => None,
return Some(address.unwrap());
}
let address_str = opreturn_data.unwrap();
let address = H160::from_str(&address_str);
if let Err(_e) = address {
return None;
}
Some(address.unwrap())
}

let amount = tx
Expand Down
61 changes: 61 additions & 0 deletions etc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Start from the latest Rust base image
FROM rust:bullseye as builder
#FROM rust:latest

SHELL ["/bin/bash", "-c"]

RUN #cargo install --git https://github.com/foundry-rs/foundry --profile local --locked forge cast chisel anvil

RUN curl -L https://foundry.paradigm.xyz | bash
RUN source ~/.bashrc
ENV PATH="~/.foundry/bin:${PATH}"
RUN foundryup

RUN apt-get update && \
apt-get install -y cmake && \
rm -rf /var/lib/apt/lists/*

# Create a new empty shell project
#WORKDIR /opt
#RUN USER=root cargo new --bin alys
WORKDIR /opt/alys
#
#RUN mkdir app
#RUN mv src app
#
## Copy over your Manifest files
#COPY ./Cargo.lock ./Cargo.lock
#COPY ./Cargo.toml ./Cargo.toml
#
#COPY ./app/Cargo.toml ./app/Cargo.toml
#
#WORKDIR /opt/alys/crates
#
#RUN USER=root cargo new --lib federation
#COPY ./crates/federation/Cargo.toml ./federation/Cargo.toml
#
#RUN USER=root cargo new --bin miner
#COPY ./crates/miner/Cargo.toml ./miner/Cargo.toml
#
#WORKDIR /opt/alys
#
## This build step will cache your dependencies
#RUN cargo build --release
#RUN rm -r app crates

# Copy your source files
COPY . .

# Build for release.
# This will be much slower, but the resulting artifact will be faster.
#RUN rm ./target/release/deps/app*
RUN cargo build --release --bin app
#
## Our second stage will use Debian
FROM debian:bullseye-slim
#
## Copy the build artifact from the builder stage and set the startup command
COPY --from=builder /opt/alys/target/release/app /bin/alys
#
## Set the startup command to run your binary
CMD ["alys --dev"]
18 changes: 18 additions & 0 deletions etc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Miscellaneous

This directory contains miscellaneous files, such as example Grafana dashboards and Prometheus configuration.

The files in this directory may undergo a lot of changes while reth is unstable, so do not expect them to necessarily be up to date.

### Overview

- [**Prometheus**](./prometheus/prometheus.yml): An example Prometheus configuration.
- [**Grafana**](./grafana/): Example Grafana dashboards & data sources.

### Docker Compose

To run Reth, Grafana or Prometheus with Docker Compose, refer to the [docker docs](/book/installation/docker.md#using-docker-compose).

### Import Grafana dashboards

Running Grafana in Docker makes it possible to import existing dashboards, refer to [docs on how to run only Grafana in Docker](/book/installation/docker.md#using-docker-compose#run-only-grafana-in-docker).
45 changes: 45 additions & 0 deletions etc/assertoor/assertoor-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
participants:
- el_type: reth
el_image: ghcr.io/paradigmxyz/reth
cl_type: lighthouse
cl_image: sigp/lighthouse:latest
count: 1
- el_type: reth
el_image: ghcr.io/paradigmxyz/reth
cl_type: teku
cl_image: consensys/teku:latest
count: 1
- el_type: reth
el_image: ghcr.io/paradigmxyz/reth
cl_type: prysm
cl_image: gcr.io/prysmaticlabs/prysm/beacon-chain:stable
vc_type: prysm
vc_image: gcr.io/prysmaticlabs/prysm/validator:stable
count: 1
- el_type: reth
el_image: ghcr.io/paradigmxyz/reth
cl_type: nimbus
cl_image: statusim/nimbus-eth2:amd64-latest
count: 1
- el_type: reth
el_image: ghcr.io/paradigmxyz/reth
cl_type: lodestar
cl_image: chainsafe/lodestar:latest
count: 1
network_params:
genesis_delay: 120
min_validator_withdrawability_delay: 1
shard_committee_period: 1
num_validator_keys_per_node: 250
launch_additional_services: true
additional_services:
- assertoor
snooper_enabled: true
disable_peer_scoring: true
assertoor_params:
image: "ethpandaops/assertoor:master"
run_stability_check: true
run_block_proposal_check: true
run_transaction_test: true
run_blob_transaction_test: false
run_opcodes_transaction_test: true
File renamed without changes.
4 changes: 2 additions & 2 deletions data/chain.json → etc/config/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"
],
"bits": 486604799,
"chainId": 212121,
"maxBlocksWithoutPow": 5,
"chainId": 263634,
"maxBlocksWithoutPow": 10000000000000,
"bitcoinStartHeight": 0,
"retargetParams": {
"powNoRetargeting": false,
Expand Down
6 changes: 6 additions & 0 deletions etc/config/eth-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Eth]
NetworkId = 212121
StateScheme = "hash"

[Node.P2P]
MaxPeers = 0
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions etc/config/jwt/jwt.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
Loading
Loading