merge upstream/unstable
This commit is contained in:
commit
c188cde034
2
.github/workflows/local-testnet.yml
vendored
2
.github/workflows/local-testnet.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
|
27
.github/workflows/release.yml
vendored
27
.github/workflows/release.yml
vendored
@ -8,8 +8,8 @@ on:
|
||||
env:
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
REPO_NAME: sigp/lighthouse
|
||||
IMAGE_NAME: sigp/lighthouse
|
||||
REPO_NAME: ${{ github.repository_owner }}/lighthouse
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/lighthouse
|
||||
|
||||
jobs:
|
||||
extract-version:
|
||||
@ -63,12 +63,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Build toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
|
||||
# ==============================
|
||||
# Windows dependencies
|
||||
@ -88,7 +84,7 @@ jobs:
|
||||
# ==============================
|
||||
- name: Install Protoc
|
||||
if: contains(matrix.arch, 'darwin') || contains(matrix.arch, 'windows')
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@ -179,13 +175,13 @@ jobs:
|
||||
# =======================================================================
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: lighthouse-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
|
||||
path: lighthouse-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
|
||||
|
||||
- name: Upload signature
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: lighthouse-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc
|
||||
path: lighthouse-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz.asc
|
||||
@ -208,7 +204,7 @@ jobs:
|
||||
# ==============================
|
||||
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
# ==============================
|
||||
# Create release draft
|
||||
@ -216,11 +212,14 @@ jobs:
|
||||
|
||||
- name: Generate Full Changelog
|
||||
id: changelog
|
||||
run: echo "CHANGELOG=$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT
|
||||
run: |
|
||||
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release Draft
|
||||
env:
|
||||
GITHUB_USER: sigp
|
||||
GITHUB_USER: ${{ github.repository_owner }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# The formatting here is borrowed from OpenEthereum: https://github.com/openethereum/openethereum/blob/main/.github/workflows/build.yml
|
||||
|
36
.github/workflows/test-suite.yml
vendored
36
.github/workflows/test-suite.yml
vendored
@ -13,6 +13,8 @@ env:
|
||||
RUSTFLAGS: "-D warnings"
|
||||
# The Nightly version used for cargo-udeps, might need updating from time to time.
|
||||
PINNED_NIGHTLY: nightly-2022-05-20
|
||||
# Prevent Github API rate limiting.
|
||||
LIGHTHOUSE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
jobs:
|
||||
target-branch-check:
|
||||
name: target-branch-check
|
||||
@ -51,7 +53,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -95,7 +97,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run beacon_chain tests for all known forks
|
||||
@ -109,7 +111,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run operation_pool tests for all known forks
|
||||
@ -133,7 +135,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -149,7 +151,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run state_transition_vectors in release.
|
||||
@ -163,7 +165,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run consensus-spec-tests with blst, milagro and fake_crypto
|
||||
@ -189,7 +191,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -205,7 +207,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -221,7 +223,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -237,7 +239,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -253,7 +255,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install ganache
|
||||
@ -285,7 +287,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run exec engine integration tests in release
|
||||
@ -299,7 +301,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Typecheck benchmark code without running it
|
||||
@ -323,7 +325,7 @@ jobs:
|
||||
- name: Get latest version of stable Rust
|
||||
run: rustup update stable
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Lint code for quality and style with Clippy
|
||||
@ -346,7 +348,7 @@ jobs:
|
||||
cargo build --release --bin cargo-clippy --bin clippy-driver
|
||||
cargo build --release --bin cargo-clippy --bin clippy-driver -Zunstable-options --out-dir $(rustc --print=sysroot)/bin
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run Clippy with the disallowed-from-async lint
|
||||
@ -360,7 +362,7 @@ jobs:
|
||||
- name: Install Rust @ MSRV (${{ needs.extract-msrv.outputs.MSRV }})
|
||||
run: rustup override set ${{ needs.extract-msrv.outputs.MSRV }}
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run cargo check
|
||||
@ -404,7 +406,7 @@ jobs:
|
||||
# NOTE: cargo-udeps version is pinned until this issue is resolved:
|
||||
# https://github.com/est31/cargo-udeps/issues/135
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v1
|
||||
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install cargo-udeps
|
||||
|
@ -10,7 +10,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
}
|
||||
|
||||
pub fn cli_run(wallet_base_dir: PathBuf) -> Result<(), String> {
|
||||
let mgr = WalletManager::open(&wallet_base_dir)
|
||||
let mgr = WalletManager::open(wallet_base_dir)
|
||||
.map_err(|e| format!("Unable to open --{}: {:?}", WALLETS_DIR_FLAG, e))?;
|
||||
|
||||
for (name, _uuid) in mgr
|
||||
|
@ -402,7 +402,7 @@ impl<T: AggregateMap> NaiveAggregationPool<T> {
|
||||
|
||||
/// Returns the total number of items stored in `self`.
|
||||
pub fn num_items(&self) -> usize {
|
||||
self.maps.iter().map(|(_, map)| map.len()).sum()
|
||||
self.maps.values().map(T::len).sum()
|
||||
}
|
||||
|
||||
/// Returns an aggregated `T::Value` with the given `T::Data`, if any.
|
||||
@ -448,11 +448,7 @@ impl<T: AggregateMap> NaiveAggregationPool<T> {
|
||||
// If we have too many maps, remove the lowest amount to ensure we only have
|
||||
// `SLOTS_RETAINED` left.
|
||||
if self.maps.len() > SLOTS_RETAINED {
|
||||
let mut slots = self
|
||||
.maps
|
||||
.iter()
|
||||
.map(|(slot, _map)| *slot)
|
||||
.collect::<Vec<_>>();
|
||||
let mut slots = self.maps.keys().copied().collect::<Vec<_>>();
|
||||
// Sort is generally pretty slow, however `SLOTS_RETAINED` is quite low so it should be
|
||||
// negligible.
|
||||
slots.sort_unstable();
|
||||
|
@ -1459,7 +1459,7 @@ where
|
||||
let proposer_index = state.get_beacon_proposer_index(slot, &self.spec).unwrap();
|
||||
|
||||
let signed_block = block.sign(
|
||||
&self.validator_keypairs[proposer_index as usize].sk,
|
||||
&self.validator_keypairs[proposer_index].sk,
|
||||
&state.fork(),
|
||||
state.genesis_validators_root(),
|
||||
&self.spec,
|
||||
|
@ -631,10 +631,7 @@ impl<T: EthSpec> ValidatorMonitor<T> {
|
||||
|
||||
// Return the `id`'s of all monitored validators.
|
||||
pub fn get_all_monitored_validators(&self) -> Vec<String> {
|
||||
self.validators
|
||||
.iter()
|
||||
.map(|(_, val)| val.id.clone())
|
||||
.collect()
|
||||
self.validators.values().map(|val| val.id.clone()).collect()
|
||||
}
|
||||
|
||||
/// If `self.auto_register == true`, add the `validator_index` to `self.monitored_validators`.
|
||||
|
@ -675,7 +675,7 @@ pub mod tests {
|
||||
#[test]
|
||||
fn test_finalization_boundaries() {
|
||||
let n = 8;
|
||||
let half = (n / 2) as usize;
|
||||
let half = n / 2;
|
||||
|
||||
let mut deposit_cache = get_cache_with_deposits(n as u64);
|
||||
|
||||
@ -828,9 +828,9 @@ pub mod tests {
|
||||
// get_log(half+quarter) should return log with index `half+quarter`
|
||||
assert_eq!(
|
||||
q3_log_before_finalization.index,
|
||||
(half + quarter) as u64,
|
||||
half + quarter,
|
||||
"log index should be {}",
|
||||
(half + quarter),
|
||||
half + quarter,
|
||||
);
|
||||
|
||||
// get lower quarter of deposits with max deposit count
|
||||
|
@ -27,7 +27,7 @@ impl From<jsonwebtoken::errors::Error> for Error {
|
||||
/// Provides wrapper around `[u8; JWT_SECRET_LENGTH]` that implements `Zeroize`.
|
||||
#[derive(Zeroize, Clone)]
|
||||
#[zeroize(drop)]
|
||||
pub struct JwtKey([u8; JWT_SECRET_LENGTH as usize]);
|
||||
pub struct JwtKey([u8; JWT_SECRET_LENGTH]);
|
||||
|
||||
impl JwtKey {
|
||||
/// Wrap given slice in `Self`. Returns an error if slice.len() != `JWT_SECRET_LENGTH`.
|
||||
|
@ -2921,7 +2921,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let is_live =
|
||||
chain.validator_seen_at_epoch(index as usize, request_data.epoch);
|
||||
api_types::LivenessResponseData {
|
||||
index: index as u64,
|
||||
index,
|
||||
epoch: request_data.epoch,
|
||||
is_live,
|
||||
}
|
||||
@ -2957,7 +2957,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and_then(
|
||||
|sysinfo, app_start: std::time::Instant, data_dir, network_globals| {
|
||||
blocking_json_task(move || {
|
||||
let app_uptime = app_start.elapsed().as_secs() as u64;
|
||||
let app_uptime = app_start.elapsed().as_secs();
|
||||
Ok(api_types::GenericResponse::from(observe_system_health_bn(
|
||||
sysinfo,
|
||||
data_dir,
|
||||
|
@ -186,14 +186,7 @@ impl RealScore {
|
||||
|
||||
/// Add an f64 to the score abiding by the limits.
|
||||
fn add(&mut self, score: f64) {
|
||||
let mut new_score = self.lighthouse_score + score;
|
||||
if new_score > MAX_SCORE {
|
||||
new_score = MAX_SCORE;
|
||||
}
|
||||
if new_score < MIN_SCORE {
|
||||
new_score = MIN_SCORE;
|
||||
}
|
||||
|
||||
let new_score = (self.lighthouse_score + score).clamp(MIN_SCORE, MAX_SCORE);
|
||||
self.set_lighthouse_score(new_score);
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ fn handle_length(
|
||||
// Note: length-prefix of > 10 bytes(uint64) would be a decoding error
|
||||
match uvi_codec.decode(bytes).map_err(RPCError::from)? {
|
||||
Some(length) => {
|
||||
*len = Some(length as usize);
|
||||
*len = Some(length);
|
||||
Ok(Some(length))
|
||||
}
|
||||
None => Ok(None), // need more bytes to decode length
|
||||
|
@ -270,11 +270,11 @@ impl<TSpec: EthSpec> PeerScoreSettings<TSpec> {
|
||||
|
||||
let modulo_smaller = max(
|
||||
1,
|
||||
smaller_committee_size / self.target_aggregators_per_committee as usize,
|
||||
smaller_committee_size / self.target_aggregators_per_committee,
|
||||
);
|
||||
let modulo_larger = max(
|
||||
1,
|
||||
(smaller_committee_size + 1) / self.target_aggregators_per_committee as usize,
|
||||
(smaller_committee_size + 1) / self.target_aggregators_per_committee,
|
||||
);
|
||||
|
||||
Ok((
|
||||
|
@ -88,7 +88,7 @@ fn keypair_from_hex(hex_bytes: &str) -> error::Result<Keypair> {
|
||||
hex_bytes.to_string()
|
||||
};
|
||||
|
||||
hex::decode(&hex_bytes)
|
||||
hex::decode(hex_bytes)
|
||||
.map_err(|e| format!("Failed to parse p2p secret key bytes: {:?}", e).into())
|
||||
.and_then(keypair_from_bytes)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ impl<'a, T: EthSpec> AttMaxCover<'a, T> {
|
||||
let indices = get_attesting_indices::<T>(committee.committee, &fresh_validators).ok()?;
|
||||
let fresh_validators_rewards: HashMap<u64, u64> = indices
|
||||
.iter()
|
||||
.map(|i| *i as u64)
|
||||
.copied()
|
||||
.flat_map(|validator_index| {
|
||||
let reward = base::get_base_reward(
|
||||
state,
|
||||
|
@ -801,7 +801,7 @@ mod test {
|
||||
|
||||
fn needs_genesis_value_test_randao<F: Field<TestSpec>>(_: F) {
|
||||
let spec = &TestSpec::default_spec();
|
||||
let max = TestSpec::slots_per_epoch() as u64 * (F::Length::to_u64() - 1);
|
||||
let max = TestSpec::slots_per_epoch() * (F::Length::to_u64() - 1);
|
||||
for i in 0..max {
|
||||
assert!(
|
||||
F::slot_needs_genesis_value(Slot::new(i), spec),
|
||||
|
@ -12,10 +12,10 @@ This number can be much higher depending on how many other validators are queued
|
||||
|
||||
## Withdrawal of exited funds
|
||||
|
||||
Even though users can perform a voluntary exit in phase 0, they **cannot withdraw their exited funds at this point in time**.
|
||||
This implies that the staked funds are effectively **frozen** until withdrawals are enabled in future phases.
|
||||
Even though users can currently perform a voluntary exit, they **cannot withdraw their exited funds at this point in time**.
|
||||
This implies that the staked funds are effectively **frozen** until withdrawals are enabled in a future hard fork (Capella).
|
||||
|
||||
To understand the phased rollout strategy for Ethereum upgrades, please visit <https://ethereum.org/en/upgrades/#roadmap>.
|
||||
To understand the rollout strategy for Ethereum upgrades, please visit <https://ethereum.org/en/upgrades>.
|
||||
|
||||
|
||||
|
||||
|
@ -189,7 +189,7 @@ impl ValidatorDefinitions {
|
||||
.write(true)
|
||||
.read(true)
|
||||
.create_new(false)
|
||||
.open(&config_path)
|
||||
.open(config_path)
|
||||
.map_err(Error::UnableToOpenFile)?;
|
||||
serde_yaml::from_reader(file).map_err(Error::UnableToParseFile)
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ impl<'a> Builder<'a> {
|
||||
if path.exists() {
|
||||
return Err(Error::DepositDataAlreadyExists(path));
|
||||
} else {
|
||||
let hex = format!("0x{}", hex::encode(&deposit_data));
|
||||
let hex = format!("0x{}", hex::encode(deposit_data));
|
||||
File::options()
|
||||
.write(true)
|
||||
.read(true)
|
||||
|
@ -63,15 +63,15 @@ mod test {
|
||||
#[test]
|
||||
fn encoding() {
|
||||
let bytes = vec![0, 255];
|
||||
let hex = encode(&bytes);
|
||||
let hex = encode(bytes);
|
||||
assert_eq!(hex.as_str(), "0x00ff");
|
||||
|
||||
let bytes = vec![];
|
||||
let hex = encode(&bytes);
|
||||
let hex = encode(bytes);
|
||||
assert_eq!(hex.as_str(), "0x");
|
||||
|
||||
let bytes = vec![1, 2, 3];
|
||||
let hex = encode(&bytes);
|
||||
let hex = encode(bytes);
|
||||
assert_eq!(hex.as_str(), "0x010203");
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl<'de> Visitor<'de> for QuantityVisitor {
|
||||
} else if stripped.starts_with('0') {
|
||||
Err(de::Error::custom("cannot have leading zero"))
|
||||
} else if stripped.len() % 2 != 0 {
|
||||
hex::decode(&format!("0{}", stripped))
|
||||
hex::decode(format!("0{}", stripped))
|
||||
.map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e)))
|
||||
} else {
|
||||
hex::decode(stripped).map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e)))
|
||||
|
@ -52,10 +52,10 @@ pub fn process_sync_aggregate<T: EthSpec>(
|
||||
.zip(aggregate.sync_committee_bits.iter())
|
||||
{
|
||||
if participation_bit {
|
||||
increase_balance(state, participant_index as usize, participant_reward)?;
|
||||
increase_balance(state, participant_index, participant_reward)?;
|
||||
increase_balance(state, proposer_index as usize, proposer_reward)?;
|
||||
} else {
|
||||
decrease_balance(state, participant_index as usize, participant_reward)?;
|
||||
decrease_balance(state, participant_index, participant_reward)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ pub fn get_flag_index_deltas<T: EthSpec>(
|
||||
let base_reward = get_base_reward(state, index, base_reward_per_increment, spec)?;
|
||||
let mut delta = Delta::default();
|
||||
|
||||
if unslashed_participating_indices.contains(index as usize)? {
|
||||
if unslashed_participating_indices.contains(index)? {
|
||||
if !state.is_in_inactivity_leak(previous_epoch, spec) {
|
||||
let reward_numerator = base_reward
|
||||
.safe_mul(weight)?
|
||||
@ -89,8 +89,8 @@ pub fn get_flag_index_deltas<T: EthSpec>(
|
||||
delta.penalize(base_reward.safe_mul(weight)?.safe_div(WEIGHT_DENOMINATOR)?)?;
|
||||
}
|
||||
deltas
|
||||
.get_mut(index as usize)
|
||||
.ok_or(Error::DeltaOutOfBounds(index as usize))?
|
||||
.get_mut(index)
|
||||
.ok_or(Error::DeltaOutOfBounds(index))?
|
||||
.combine(delta)?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -235,7 +235,7 @@ fn get_inclusion_delay_delta(
|
||||
let max_attester_reward = base_reward.safe_sub(proposer_reward)?;
|
||||
delta.reward(max_attester_reward.safe_div(inclusion_info.delay)?)?;
|
||||
|
||||
let proposer_index = inclusion_info.proposer_index as usize;
|
||||
let proposer_index = inclusion_info.proposer_index;
|
||||
Ok((delta, Some((proposer_index, proposer_delta))))
|
||||
} else {
|
||||
Ok((Delta::default(), None))
|
||||
|
@ -504,7 +504,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
/// Spec v0.12.1
|
||||
pub fn get_committee_count_at_slot(&self, slot: Slot) -> Result<u64, Error> {
|
||||
let cache = self.committee_cache_at_slot(slot)?;
|
||||
Ok(cache.committees_per_slot() as u64)
|
||||
Ok(cache.committees_per_slot())
|
||||
}
|
||||
|
||||
/// Compute the number of committees in an entire epoch.
|
||||
|
@ -144,7 +144,7 @@ impl CommitteeCache {
|
||||
self.committees_per_slot as usize,
|
||||
index as usize,
|
||||
);
|
||||
let committee = self.compute_committee(committee_index as usize)?;
|
||||
let committee = self.compute_committee(committee_index)?;
|
||||
|
||||
Some(BeaconCommittee {
|
||||
slot,
|
||||
|
@ -344,12 +344,7 @@ mod committees {
|
||||
|
||||
let cache_epoch = cache_epoch.into_epoch(state_epoch);
|
||||
|
||||
execute_committee_consistency_test(
|
||||
new_head_state,
|
||||
cache_epoch,
|
||||
validator_count as usize,
|
||||
spec,
|
||||
);
|
||||
execute_committee_consistency_test(new_head_state, cache_epoch, validator_count, spec);
|
||||
}
|
||||
|
||||
async fn committee_consistency_test_suite<T: EthSpec>(cached_epoch: RelativeEpoch) {
|
||||
@ -361,18 +356,13 @@ mod committees {
|
||||
.mul(spec.target_committee_size)
|
||||
.add(1);
|
||||
|
||||
committee_consistency_test::<T>(validator_count as usize, Epoch::new(0), cached_epoch)
|
||||
committee_consistency_test::<T>(validator_count, Epoch::new(0), cached_epoch).await;
|
||||
|
||||
committee_consistency_test::<T>(validator_count, T::genesis_epoch() + 4, cached_epoch)
|
||||
.await;
|
||||
|
||||
committee_consistency_test::<T>(
|
||||
validator_count as usize,
|
||||
T::genesis_epoch() + 4,
|
||||
cached_epoch,
|
||||
)
|
||||
.await;
|
||||
|
||||
committee_consistency_test::<T>(
|
||||
validator_count as usize,
|
||||
validator_count,
|
||||
T::genesis_epoch()
|
||||
+ (T::slots_per_historical_root() as u64)
|
||||
.mul(T::slots_per_epoch())
|
||||
|
@ -223,7 +223,7 @@ mod test {
|
||||
}
|
||||
|
||||
fn preset_from_file<T: DeserializeOwned>(preset_name: &str, filename: &str) -> T {
|
||||
let f = File::open(&presets_base_path().join(preset_name).join(filename))
|
||||
let f = File::open(presets_base_path().join(preset_name).join(filename))
|
||||
.expect("preset file exists");
|
||||
serde_yaml::from_reader(f).unwrap()
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ fn double_vote_multi_vals() {
|
||||
fn double_vote_some_vals() {
|
||||
let v1 = vec![0, 1, 2, 3, 4, 5, 6];
|
||||
let v2 = vec![0, 2, 4, 6];
|
||||
let att1 = indexed_att(&v1, 0, 1, 0);
|
||||
let att2 = indexed_att(&v2, 0, 1, 1);
|
||||
let att1 = indexed_att(v1, 0, 1, 0);
|
||||
let att2 = indexed_att(v2, 0, 1, 1);
|
||||
let slashings = hashset![att_slashing(&att1, &att2)];
|
||||
let attestations = vec![att1, att2];
|
||||
slasher_test_indiv(&attestations, &slashings, 1);
|
||||
@ -53,9 +53,9 @@ fn double_vote_some_vals_repeat() {
|
||||
let v1 = vec![0, 1, 2, 3, 4, 5, 6];
|
||||
let v2 = vec![0, 2, 4, 6];
|
||||
let v3 = vec![1, 3, 5];
|
||||
let att1 = indexed_att(&v1, 0, 1, 0);
|
||||
let att2 = indexed_att(&v2, 0, 1, 1);
|
||||
let att3 = indexed_att(&v3, 0, 1, 0);
|
||||
let att1 = indexed_att(v1, 0, 1, 0);
|
||||
let att2 = indexed_att(v2, 0, 1, 1);
|
||||
let att3 = indexed_att(v3, 0, 1, 0);
|
||||
let slashings = hashset![att_slashing(&att1, &att2)];
|
||||
let attestations = vec![att1, att2, att3];
|
||||
slasher_test_indiv(&attestations, &slashings, 1);
|
||||
@ -67,8 +67,8 @@ fn double_vote_some_vals_repeat() {
|
||||
fn no_double_vote_same_target() {
|
||||
let v1 = vec![0, 1, 2, 3, 4, 5, 6];
|
||||
let v2 = vec![0, 1, 2, 3, 4, 5, 7, 8];
|
||||
let att1 = indexed_att(&v1, 0, 1, 0);
|
||||
let att2 = indexed_att(&v2, 0, 1, 0);
|
||||
let att1 = indexed_att(v1, 0, 1, 0);
|
||||
let att2 = indexed_att(v2, 0, 1, 0);
|
||||
let attestations = vec![att1, att2];
|
||||
slasher_test_indiv(&attestations, &hashset! {}, 1);
|
||||
slasher_test_indiv(&attestations, &hashset! {}, 1000);
|
||||
@ -79,8 +79,8 @@ fn no_double_vote_same_target() {
|
||||
fn no_double_vote_distinct_vals() {
|
||||
let v1 = vec![0, 1, 2, 3];
|
||||
let v2 = vec![4, 5, 6, 7];
|
||||
let att1 = indexed_att(&v1, 0, 1, 0);
|
||||
let att2 = indexed_att(&v2, 0, 1, 1);
|
||||
let att1 = indexed_att(v1, 0, 1, 0);
|
||||
let att2 = indexed_att(v2, 0, 1, 1);
|
||||
let attestations = vec![att1, att2];
|
||||
slasher_test_indiv(&attestations, &hashset! {}, 1);
|
||||
slasher_test_indiv(&attestations, &hashset! {}, 1000);
|
||||
@ -89,7 +89,7 @@ fn no_double_vote_distinct_vals() {
|
||||
#[test]
|
||||
fn no_double_vote_repeated() {
|
||||
let v = vec![0, 1, 2, 3, 4];
|
||||
let att1 = indexed_att(&v, 0, 1, 0);
|
||||
let att1 = indexed_att(v, 0, 1, 0);
|
||||
let att2 = att1.clone();
|
||||
let attestations = vec![att1, att2];
|
||||
slasher_test_indiv(&attestations, &hashset! {}, 1);
|
||||
|
@ -13,6 +13,8 @@ BLS_TARBALL = $(patsubst %,%-$(BLS_TEST_TAG).tar.gz,$(BLS_TEST))
|
||||
BLS_OUTPUT_DIR := $(OUTPUT_DIR)/$(BLS_TEST_REPO_NAME)
|
||||
BLS_BASE_URL := https://github.com/ethereum/$(BLS_TEST_REPO_NAME)/releases/download/$(BLS_TEST_TAG)
|
||||
|
||||
WGET := $(if $(LIGHTHOUSE_GITHUB_TOKEN),wget --header="Authorization: $(LIGHTHOUSE_GITHUB_TOKEN)",wget)
|
||||
|
||||
all:
|
||||
make $(OUTPUT_DIR)
|
||||
make $(BLS_OUTPUT_DIR)
|
||||
@ -25,11 +27,11 @@ $(OUTPUT_DIR): $(TARBALLS)
|
||||
|
||||
$(BLS_OUTPUT_DIR):
|
||||
mkdir $(BLS_OUTPUT_DIR)
|
||||
wget $(BLS_BASE_URL)/$(BLS_TEST).tar.gz -O $(BLS_TARBALL)
|
||||
$(WGET) $(BLS_BASE_URL)/$(BLS_TEST).tar.gz -O $(BLS_TARBALL)
|
||||
tar -xzf $(BLS_TARBALL) -C $(BLS_OUTPUT_DIR)
|
||||
|
||||
%-$(TESTS_TAG).tar.gz:
|
||||
wget $(BASE_URL)/$*.tar.gz -O $@
|
||||
$(WGET) $(BASE_URL)/$*.tar.gz -O $@
|
||||
|
||||
clean-test-files:
|
||||
rm -rf $(OUTPUT_DIR) $(BLS_OUTPUT_DIR)
|
||||
|
@ -76,7 +76,7 @@ impl GenericExecutionEngine for NethermindEngine {
|
||||
fn init_datadir() -> TempDir {
|
||||
let datadir = TempDir::new().unwrap();
|
||||
let genesis_json_path = datadir.path().join("genesis.json");
|
||||
let mut file = File::create(&genesis_json_path).unwrap();
|
||||
let mut file = File::create(genesis_json_path).unwrap();
|
||||
let json = nethermind_genesis_json();
|
||||
serde_json::to_writer(&mut file, &json).unwrap();
|
||||
datadir
|
||||
|
@ -231,7 +231,7 @@ impl<E: EthSpec> LocalExecutionNode<E> {
|
||||
.tempdir()
|
||||
.expect("should create temp directory for client datadir");
|
||||
let jwt_file_path = datadir.path().join("jwt.hex");
|
||||
if let Err(e) = std::fs::write(&jwt_file_path, config.jwt_key.hex_string()) {
|
||||
if let Err(e) = std::fs::write(jwt_file_path, config.jwt_key.hex_string()) {
|
||||
panic!("Failed to write jwt file {}", e);
|
||||
}
|
||||
Self {
|
||||
|
@ -1,7 +1,10 @@
|
||||
//! This build script downloads the latest Web3Signer release and places it in the `OUT_DIR` so it
|
||||
//! can be used for integration testing.
|
||||
|
||||
use reqwest::Client;
|
||||
use reqwest::{
|
||||
header::{self, HeaderValue},
|
||||
Client,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
@ -15,10 +18,15 @@ const FIXED_VERSION_STRING: Option<&str> = None;
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
download_binary(out_dir.into()).await;
|
||||
|
||||
// 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) {
|
||||
pub async fn download_binary(dest_dir: PathBuf, github_token: &str) {
|
||||
let version_file = dest_dir.join("version");
|
||||
|
||||
let client = Client::builder()
|
||||
@ -33,8 +41,11 @@ pub async fn download_binary(dest_dir: PathBuf) {
|
||||
env_version
|
||||
} else {
|
||||
// Get the latest release of the web3 signer repo.
|
||||
let mut token_header_value = HeaderValue::from_str(github_token).unwrap();
|
||||
token_header_value.set_sensitive(true);
|
||||
let latest_response: Value = client
|
||||
.get("https://api.github.com/repos/ConsenSys/web3signer/releases/latest")
|
||||
.header(header::AUTHORIZATION, token_header_value)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
|
@ -441,7 +441,7 @@ impl DoppelgangerService {
|
||||
}
|
||||
|
||||
// Get a list of indices to provide to the BN API.
|
||||
let indices_only = indices_map.iter().map(|(index, _)| *index).collect();
|
||||
let indices_only = indices_map.keys().copied().collect();
|
||||
|
||||
// Pull the liveness responses from the BN.
|
||||
let request_epoch = request_slot.epoch(E::slots_per_epoch());
|
||||
@ -971,16 +971,16 @@ mod test {
|
||||
LivenessResponses {
|
||||
current_epoch_responses: detection_indices
|
||||
.iter()
|
||||
.map(|i| LivenessResponseData {
|
||||
index: *i as u64,
|
||||
.map(|&index| LivenessResponseData {
|
||||
index,
|
||||
epoch: current_epoch,
|
||||
is_live: false,
|
||||
})
|
||||
.collect(),
|
||||
previous_epoch_responses: detection_indices
|
||||
.iter()
|
||||
.map(|i| LivenessResponseData {
|
||||
index: *i as u64,
|
||||
.map(|&index| LivenessResponseData {
|
||||
index,
|
||||
epoch: current_epoch - 1,
|
||||
is_live: false,
|
||||
})
|
||||
|
@ -331,7 +331,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
|
||||
.and(signer.clone())
|
||||
.and_then(|sysinfo, app_start: std::time::Instant, val_dir, signer| {
|
||||
blocking_signed_json_task(signer, move || {
|
||||
let app_uptime = app_start.elapsed().as_secs() as u64;
|
||||
let app_uptime = app_start.elapsed().as_secs();
|
||||
Ok(api_types::GenericResponse::from(observe_system_health_vc(
|
||||
sysinfo, val_dir, app_uptime,
|
||||
)))
|
||||
|
@ -472,7 +472,7 @@ impl InitializedValidators {
|
||||
|
||||
/// Iterate through all voting public keys in `self` that should be used when querying for duties.
|
||||
pub fn iter_voting_pubkeys(&self) -> impl Iterator<Item = &PublicKeyBytes> {
|
||||
self.validators.iter().map(|(pubkey, _)| pubkey)
|
||||
self.validators.keys()
|
||||
}
|
||||
|
||||
/// Returns the voting `Keypair` for a given voting `PublicKey`, if all are true:
|
||||
|
@ -104,7 +104,7 @@ impl KeyCache {
|
||||
let file = File::options()
|
||||
.read(true)
|
||||
.create_new(false)
|
||||
.open(&cache_path)
|
||||
.open(cache_path)
|
||||
.map_err(Error::UnableToOpenFile)?;
|
||||
serde_json::from_reader(file).map_err(Error::UnableToParseFile)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user