mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-22 07:18:25 +00:00
Enable Compatibility with Windows (#2333)
## Issue Addressed Windows incompatibility. ## Proposed Changes On windows, lighthouse needs to default to STDIN as tty doesn't exist. Also Windows uses ACLs for file permissions. So to mirror chmod 600, we will remove every entry in a file's ACL and add only a single SID that is an alias for the file owner. Beyond that, there were several changes made to different unit tests because windows has slightly different error messages as well as frustrating nuances around killing a process :/ ## Additional Info Tested on my Windows VM and it appears to work, also compiled & tested on Linux with these changes. Permissions look correct on both platforms now. Just waiting for my validator to activate on Prater so I can test running full validator client on windows. Co-authored-by: ethDreamer <37123614+ethDreamer@users.noreply.github.com> Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
@@ -10,6 +10,13 @@ pub const DEFAULT_UPDATE_PERIOD: u64 = 12;
|
||||
pub const DEFAULT_MAX_DB_SIZE: usize = 256 * 1024; // 256 GiB
|
||||
pub const DEFAULT_BROADCAST: bool = false;
|
||||
|
||||
/// Database size to use for tests.
|
||||
///
|
||||
/// Mostly a workaround for Windows due to a bug in LMDB, see:
|
||||
///
|
||||
/// https://github.com/sigp/lighthouse/issues/2342
|
||||
pub const TESTING_MAX_DB_SIZE: usize = 16; // MiB
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub database_path: PathBuf,
|
||||
@@ -38,6 +45,12 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
/// Use a smaller max DB size for testing.
|
||||
pub fn for_testing(mut self) -> Self {
|
||||
self.max_db_size_mbs = TESTING_MAX_DB_SIZE;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> Result<(), Error> {
|
||||
if self.chunk_size == 0
|
||||
|| self.validator_chunk_size == 0
|
||||
|
||||
@@ -195,6 +195,15 @@ impl<E: EthSpec> SlasherDB<E> {
|
||||
let proposers_db = env.create_db(Some(PROPOSERS_DB), Self::db_flags())?;
|
||||
let metadata_db = env.create_db(Some(METADATA_DB), Self::db_flags())?;
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use filesystem::restrict_file_permissions;
|
||||
let data = config.database_path.join("data.mdb");
|
||||
let lock = config.database_path.join("lock.mdb");
|
||||
restrict_file_permissions(data).map_err(Error::DatabasePermissionsError)?;
|
||||
restrict_file_permissions(lock).map_err(Error::DatabasePermissionsError)?;
|
||||
}
|
||||
|
||||
let db = Self {
|
||||
env,
|
||||
indexed_attestation_db,
|
||||
|
||||
@@ -6,6 +6,7 @@ use types::{Epoch, Hash256};
|
||||
pub enum Error {
|
||||
DatabaseError(lmdb::Error),
|
||||
DatabaseIOError(io::Error),
|
||||
DatabasePermissionsError(filesystem::Error),
|
||||
SszDecodeError(ssz::DecodeError),
|
||||
BincodeError(bincode::Error),
|
||||
ArithError(safe_arith::ArithError),
|
||||
|
||||
Reference in New Issue
Block a user