Merge branch 'eip4844' into deneb-free-blobs

This commit is contained in:
Diva M 2023-04-10 10:47:43 -05:00
commit f6f63b18ed
No known key found for this signature in database
GPG Key ID: 1BAE5E01126680FE
4 changed files with 38 additions and 22 deletions

2
Cargo.lock generated
View File

@ -9264,6 +9264,8 @@ dependencies = [
"eth2_network_config",
"exit-future",
"futures",
"lazy_static",
"parking_lot 0.12.1",
"reqwest",
"serde",
"serde_derive",

View File

@ -3,8 +3,6 @@ name = "web3signer_tests"
version = "0.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -27,9 +25,7 @@ serde = "1.0.116"
serde_derive = "1.0.116"
serde_yaml = "0.8.13"
eth2_network_config = { path = "../../common/eth2_network_config" }
[build-dependencies]
tokio = { version = "1.14.0", features = ["rt-multi-thread", "macros"] }
reqwest = { version = "0.11.0", features = ["json","stream"] }
serde_json = "1.0.58"
zip = "0.5.13"
lazy_static = "1.4.0"
parking_lot = "0.12.0"

View File

@ -15,17 +15,6 @@ use zip::ZipArchive;
/// Use `Some("21.8.1")` to download a specific version.
const FIXED_VERSION_STRING: Option<&str> = None;
#[tokio::main]
async fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
// Read a Github API token from the environment. This is intended to prevent rate-limits on CI.
// We use a name that is unlikely to accidentally collide with anything the user has configured.
let github_token = env::var("LIGHTHOUSE_GITHUB_TOKEN");
download_binary(out_dir.into(), github_token.as_deref().unwrap_or("")).await;
}
pub async fn download_binary(dest_dir: PathBuf, github_token: &str) {
let version_file = dest_dir.join("version");

View File

@ -9,16 +9,21 @@
//! - Lighthouse can issue valid requests to Web3Signer.
//! - The signatures generated by Web3Signer are identical to those which Lighthouse generates.
//!
//! There is a build script in this crate which obtains the latest version of Web3Signer and makes
//! it available via the `OUT_DIR`.
//! There is a `download_binary` function in the `get_web3signer` module which obtains the latest version of Web3Signer and makes
//! it available via the `TEMP_DIR`.
#![cfg(all(test, unix, not(debug_assertions)))]
mod get_web3signer;
#[cfg(all(test, unix, not(debug_assertions)))]
mod tests {
use crate::get_web3signer::download_binary;
use account_utils::validator_definitions::{
SigningDefinition, ValidatorDefinition, ValidatorDefinitions, Web3SignerDefinition,
};
use eth2_keystore::KeystoreBuilder;
use eth2_network_config::Eth2NetworkConfig;
use lazy_static::lazy_static;
use parking_lot::Mutex;
use reqwest::Client;
use serde::Serialize;
use slot_clock::{SlotClock, TestingSlotClock};
@ -31,7 +36,8 @@ mod tests {
use std::sync::Arc;
use std::time::{Duration, Instant};
use task_executor::TaskExecutor;
use tempfile::TempDir;
use tempfile::{tempdir, TempDir};
use tokio::sync::OnceCell;
use tokio::time::sleep;
use types::*;
use url::Url;
@ -51,6 +57,13 @@ mod tests {
/// debugging.
const SUPPRESS_WEB3SIGNER_LOGS: bool = true;
lazy_static! {
static ref TEMP_DIR: Arc<Mutex<TempDir>> = Arc::new(Mutex::new(
tempdir().expect("Failed to create temporary directory")
));
static ref GET_WEB3SIGNER_BIN: OnceCell<()> = OnceCell::new();
}
type E = MainnetEthSpec;
/// This marker trait is implemented for objects that we wish to compare to ensure Web3Signer
@ -99,7 +112,10 @@ mod tests {
/// The location of the Web3Signer binary generated by the build script.
fn web3signer_binary() -> PathBuf {
PathBuf::from(env::var("OUT_DIR").unwrap())
TEMP_DIR
.lock()
.path()
.to_path_buf()
.join("web3signer")
.join("bin")
.join("web3signer")
@ -143,6 +159,19 @@ mod tests {
impl Web3SignerRig {
pub async fn new(network: &str, listen_address: &str, listen_port: u16) -> Self {
GET_WEB3SIGNER_BIN
.get_or_init(|| async {
// Read a Github API token from the environment. This is intended to prevent rate-limits on CI.
// We use a name that is unlikely to accidentally collide with anything the user has configured.
let github_token = env::var("LIGHTHOUSE_GITHUB_TOKEN");
download_binary(
TEMP_DIR.lock().path().to_path_buf(),
github_token.as_deref().unwrap_or(""),
)
.await;
})
.await;
let keystore_dir = TempDir::new().unwrap();
let keypair = testing_keypair();
let keystore =