Skip to content

Commit

Permalink
Squashed commit of Rename random to prev_randao sigp#3040:
Browse files Browse the repository at this point in the history
commit 6370edd
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 16:31:18 2022 +1100

    Update testing/execution_engine_integration/src/build_geth.rs

    Co-authored-by: Michael Sproul <micsproul@gmail.com>

commit f5a1dee
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 16:24:03 2022 +1100

    Fix proto-array bug

commit 4f7610f
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 16:23:52 2022 +1100

    Fix payload tests

commit cd7a0f5
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 15:22:54 2022 +1100

    Implement consensus-specs/2844

commit 5313364
Merge: d5e84a5 668115a
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 14:23:19 2022 +1100

    Merge branch 'unstable' into prev-randao-rename

commit d5e84a5
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 13:31:45 2022 +1100

    Fix windows test errors

commit 668115a
Author: Akihito Nakano <sora.akatsuki@gmail.com>
Date:   Wed Mar 2 01:05:08 2022 +0000

    Rename Eth1/Eth2 in documents (sigp#3021)

    ## Issue Addressed

    Resolves sigp#3019

    ## Proposed Changes

    - Eth2 Eth2.0 Ethereum 2.0 -> Ethereum consensus
    - Eth2 network -> consensus layer
    - Ethereum 2.0 specification -> Ethereum proof-of-stake consensus specification
    - Eth2 deposit contract -> Staking deposit contract
    - Eth1 -> execution client

    ## Additional Info

    The description needs to be updated by someone who has permission to do. 📝

    <img width="487" alt="image" src="https://user-images.githubusercontent.com/1885716/153995211-816d9561-751e-4810-abb9-83d979379783.png">

commit e34524b
Author: Age Manning <Age@AgeManning.com>
Date:   Wed Mar 2 01:05:07 2022 +0000

    Increase default target-peer count to 80 (sigp#3005)

    Increase the default peer count from 50 to 80

commit db2e3ae
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 11:08:40 2022 +1100

    Fix yaml indenting

commit a2f99e5
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 11:05:57 2022 +1100

    Specify go version in github actions

commit 0c5e9c6
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 11:04:15 2022 +1100

    Switch EE tests to be a binary

commit 7f07fa5
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 10:22:32 2022 +1100

    Print output of failed make command

commit fa20696
Author: Paul Hauner <paul@paulhauner.com>
Date:   Wed Mar 2 10:01:00 2022 +1100

    Bump spec tests version

commit c2d7677
Author: Paul Hauner <paul@paulhauner.com>
Date:   Sat Feb 26 10:17:14 2022 +1100

    Add auth port

commit 540337a
Author: Paul Hauner <paul@paulhauner.com>
Date:   Sat Feb 26 10:10:06 2022 +1100

    Use `merge-kiln-v2` branch for geth

commit 1a3d32e
Author: Paul Hauner <paul@paulhauner.com>
Date:   Fri Feb 25 15:08:38 2022 +1100

    Revert "Add serde "random" alias"

    This reverts commit bb02c2f.

commit 63376bd
Author: Paul Hauner <paul@paulhauner.com>
Date:   Fri Feb 25 14:59:26 2022 +1100

    Add serde "random" alias

commit 375aa32
Author: Paul Hauner <paul@paulhauner.com>
Date:   Fri Feb 25 10:09:38 2022 +1100

    Rename random to prev_randao

commit b6493d5
Author: Paul Hauner <paul@paulhauner.com>
Date:   Tue Mar 1 22:56:47 2022 +0000

    Enforce Optimistic Sync Conditions & CLI Tests (v2) (sigp#3050)

    ## Description

    This PR adds a single, trivial commit (f5d2b27) atop sigp#2986 to resolve a tests compile error. The original author (@ethDreamer) is AFK so I'm getting this one merged ☺️

    Please see sigp#2986 for more information about the other, significant changes in this PR.

    Co-authored-by: Mark Mackey <mark@sigmaprime.io>
    Co-authored-by: ethDreamer <37123614+ethDreamer@users.noreply.github.com>
  • Loading branch information
pawanjay176 committed Mar 2, 2022
1 parent 52263a1 commit 1630817
Show file tree
Hide file tree
Showing 65 changed files with 597 additions and 258 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ jobs:
needs: cargo-fmt
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Get latest version of stable Rust
run: rustup update stable
- name: Run exec engine integration tests in release
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lighthouse: Ethereum 2.0
# Lighthouse: Ethereum consensus client

An open-source Ethereum 2.0 client, written in Rust and maintained by Sigma Prime.
An open-source Ethereum consensus client, written in Rust and maintained by Sigma Prime.

[![Build Status]][Build Link] [![Book Status]][Book Link] [![Chat Badge]][Chat Link]

Expand All @@ -22,21 +22,21 @@ An open-source Ethereum 2.0 client, written in Rust and maintained by Sigma Prim

Lighthouse is:

- Ready for use on Eth2 mainnet.
- Ready for use on Ethereum consensus mainnet.
- Fully open-source, licensed under Apache 2.0.
- Security-focused. Fuzzing techniques have been continuously applied and several external security reviews have been performed.
- Built in [Rust](https://www.rust-lang.org), a modern language providing unique safety guarantees and
excellent performance (comparable to C++).
- Funded by various organisations, including Sigma Prime, the
Ethereum Foundation, ConsenSys, the Decentralization Foundation and private individuals.
- Actively involved in the specification and security analysis of the
Ethereum 2.0 specification.
Ethereum proof-of-stake consensus specification.

## Eth2 Deposit Contract
## Staking Deposit Contract

The Lighthouse team acknowledges
[`0x00000000219ab540356cBB839Cbe05303d7705Fa`](https://etherscan.io/address/0x00000000219ab540356cbb839cbe05303d7705fa)
as the canonical Eth2 deposit contract address.
as the canonical staking deposit contract address.

## Documentation

Expand Down Expand Up @@ -66,7 +66,7 @@ of the Lighthouse book.
## Contact

The best place for discussion is the [Lighthouse Discord
server](https://discord.gg/cyAszAh).
server](https://discord.gg/cyAszAh).

Sign up to the [Lighthouse Development Updates](http://eepurl.com/dh9Lvb) mailing list for email
notifications about releases, network status and other important information.
Expand Down
25 changes: 25 additions & 0 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ pub enum ExecutionPayloadError {
///
/// The peer is not necessarily invalid.
PoWParentMissing(ExecutionBlockHash),
/// The execution node is syncing but we fail the conditions for optimistic sync
UnverifiedNonOptimisticCandidate,
}

impl From<execution_layer::Error> for ExecutionPayloadError {
Expand Down Expand Up @@ -1128,6 +1130,29 @@ impl<'a, T: BeaconChainTypes> FullyVerifiedBlock<'a, T> {
// `randao` may change.
let payload_verification_status = notify_new_payload(chain, &state, block.message())?;

// If the payload did not validate or invalidate the block, check to see if this block is
// valid for optimistic import.
if payload_verification_status == PayloadVerificationStatus::NotVerified {
let current_slot = chain
.slot_clock
.now()
.ok_or(BeaconChainError::UnableToReadSlot)?;

if !chain
.fork_choice
.read()
.is_optimistic_candidate_block(
current_slot,
block.slot(),
&block.parent_root(),
&chain.spec,
)
.map_err(BeaconChainError::from)?
{
return Err(ExecutionPayloadError::UnverifiedNonOptimisticCandidate.into());
}
}

// If the block is sufficiently recent, notify the validator monitor.
if let Some(slot) = chain.slot_clock.now() {
let epoch = slot.epoch(T::EthSpec::slots_per_epoch());
Expand Down
34 changes: 27 additions & 7 deletions beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,33 @@ pub fn validate_merge_block<T: BeaconChainTypes>(
}
.into()),
None => {
debug!(
chain.log,
"Optimistically accepting terminal block";
"block_hash" => ?execution_payload.parent_hash,
"msg" => "the terminal block/parent was unavailable"
);
Ok(())
let current_slot = chain
.slot_clock
.now()
.ok_or(BeaconChainError::UnableToReadSlot)?;

// Ensure the block is a candidate for optimistic import.
if chain
.fork_choice
.read()
.is_optimistic_candidate_block(
current_slot,
block.slot(),
&block.parent_root(),
&chain.spec,
)
.map_err(BeaconChainError::from)?
{
debug!(
chain.log,
"Optimistically accepting terminal block";
"block_hash" => ?execution_payload.parent_hash,
"msg" => "the terminal block/parent was unavailable"
);
Ok(())
} else {
Err(ExecutionPayloadError::UnverifiedNonOptimisticCandidate.into())
}
}
}
}
Expand Down
37 changes: 29 additions & 8 deletions beacon_node/beacon_chain/tests/payload_invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ fn valid_invalid_syncing() {
/// `latest_valid_hash`.
#[test]
fn invalid_payload_invalidates_parent() {
let mut rig = InvalidPayloadRig::new();
let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
rig.import_block(Payload::Valid); // Import a valid transition block.
rig.move_to_first_justification(Payload::Syncing);

let roots = vec![
rig.import_block(Payload::Syncing),
Expand All @@ -258,6 +260,7 @@ fn invalid_payload_invalidates_parent() {
fn justified_checkpoint_becomes_invalid() {
let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
rig.import_block(Payload::Valid); // Import a valid transition block.
rig.move_to_first_justification(Payload::Syncing);

let justified_checkpoint = rig.head_info().current_justified_checkpoint;
Expand Down Expand Up @@ -305,7 +308,9 @@ fn pre_finalized_latest_valid_hash() {

let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
let blocks = rig.build_blocks(num_blocks, Payload::Syncing);
let mut blocks = vec![];
blocks.push(rig.import_block(Payload::Valid)); // Import a valid transition block.
blocks.extend(rig.build_blocks(num_blocks - 1, Payload::Syncing));

assert_eq!(rig.head_info().finalized_checkpoint.epoch, finalized_epoch);

Expand All @@ -330,7 +335,11 @@ fn pre_finalized_latest_valid_hash() {
for i in E::slots_per_epoch() * finalized_epoch..num_blocks {
let slot = Slot::new(i);
let root = rig.block_root_at_slot(slot).unwrap();
assert!(rig.execution_status(root).is_not_verified());
if slot == 1 {
assert!(rig.execution_status(root).is_valid());
} else {
assert!(rig.execution_status(root).is_not_verified());
}
}
}

Expand All @@ -344,7 +353,10 @@ fn latest_valid_hash_will_validate() {

let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
let blocks = rig.build_blocks(4, Payload::Syncing);

let mut blocks = vec![];
blocks.push(rig.import_block(Payload::Valid)); // Import a valid transition block.
blocks.extend(rig.build_blocks(4, Payload::Syncing));

let latest_valid_root = rig
.block_root_at_slot(Slot::new(LATEST_VALID_SLOT))
Expand All @@ -357,7 +369,7 @@ fn latest_valid_hash_will_validate() {

assert_eq!(rig.head_info().slot, LATEST_VALID_SLOT);

for slot in 0..=4 {
for slot in 0..=5 {
let slot = Slot::new(slot);
let root = if slot > 0 {
// If not the genesis slot, check the blocks we just produced.
Expand Down Expand Up @@ -386,7 +398,9 @@ fn latest_valid_hash_is_junk() {

let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
let blocks = rig.build_blocks(num_blocks, Payload::Syncing);
let mut blocks = vec![];
blocks.push(rig.import_block(Payload::Valid)); // Import a valid transition block.
blocks.extend(rig.build_blocks(num_blocks, Payload::Syncing));

assert_eq!(rig.head_info().finalized_checkpoint.epoch, finalized_epoch);

Expand All @@ -408,7 +422,11 @@ fn latest_valid_hash_is_junk() {
for i in E::slots_per_epoch() * finalized_epoch..num_blocks {
let slot = Slot::new(i);
let root = rig.block_root_at_slot(slot).unwrap();
assert!(rig.execution_status(root).is_not_verified());
if slot == 1 {
assert!(rig.execution_status(root).is_valid());
} else {
assert!(rig.execution_status(root).is_not_verified());
}
}
}

Expand All @@ -421,6 +439,7 @@ fn invalidates_all_descendants() {

let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
rig.import_block(Payload::Valid); // Import a valid transition block.
let blocks = rig.build_blocks(num_blocks, Payload::Syncing);

assert_eq!(rig.head_info().finalized_checkpoint.epoch, finalized_epoch);
Expand Down Expand Up @@ -493,6 +512,7 @@ fn switches_heads() {

let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
rig.import_block(Payload::Valid); // Import a valid transition block.
let blocks = rig.build_blocks(num_blocks, Payload::Syncing);

assert_eq!(rig.head_info().finalized_checkpoint.epoch, finalized_epoch);
Expand Down Expand Up @@ -571,8 +591,9 @@ fn invalid_during_processing() {

#[test]
fn invalid_after_optimistic_sync() {
let mut rig = InvalidPayloadRig::new();
let mut rig = InvalidPayloadRig::new().enable_attestations();
rig.move_to_terminal_block();
rig.import_block(Payload::Valid); // Import a valid transition block.

let mut roots = vec![
rig.import_block(Payload::Syncing),
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub struct ExecutionBlock {
#[derive(Clone, Copy, Debug)]
pub struct PayloadAttributes {
pub timestamp: u64,
pub random: Hash256,
pub prev_randao: Hash256,
pub suggested_fee_recipient: Address,
}

Expand Down
24 changes: 12 additions & 12 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ mod test {
"stateRoot": HASH_01,
"receiptsRoot": HASH_00,
"logsBloom": LOGS_BLOOM_01,
"random": HASH_01,
"prevRandao": HASH_01,
"blockNumber": "0x0",
"gasLimit": "0x1",
"gasUsed": "0x2",
Expand Down Expand Up @@ -497,7 +497,7 @@ mod test {
},
Some(PayloadAttributes {
timestamp: 5,
random: Hash256::zero(),
prev_randao: Hash256::zero(),
suggested_fee_recipient: Address::repeat_byte(0),
}),
)
Expand All @@ -514,7 +514,7 @@ mod test {
},
{
"timestamp":"0x5",
"random": HASH_00,
"prevRandao": HASH_00,
"suggestedFeeRecipient": ADDRESS_00
}]
}),
Expand Down Expand Up @@ -576,7 +576,7 @@ mod test {
state_root: Hash256::repeat_byte(1),
receipts_root: Hash256::repeat_byte(0),
logs_bloom: vec![1; 256].into(),
random: Hash256::repeat_byte(1),
prev_randao: Hash256::repeat_byte(1),
block_number: 0,
gas_limit: 1,
gas_used: 2,
Expand All @@ -598,7 +598,7 @@ mod test {
"stateRoot": HASH_01,
"receiptsRoot": HASH_00,
"logsBloom": LOGS_BLOOM_01,
"random": HASH_01,
"prevRandao": HASH_01,
"blockNumber": "0x0",
"gasLimit": "0x1",
"gasUsed": "0x2",
Expand Down Expand Up @@ -715,7 +715,7 @@ mod test {
},
Some(PayloadAttributes {
timestamp: 5,
random: Hash256::zero(),
prev_randao: Hash256::zero(),
suggested_fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(),
})
)
Expand All @@ -732,7 +732,7 @@ mod test {
},
{
"timestamp":"0x5",
"random": HASH_00,
"prevRandao": HASH_00,
"suggestedFeeRecipient":"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
}]
})
Expand Down Expand Up @@ -762,7 +762,7 @@ mod test {
},
Some(PayloadAttributes {
timestamp: 5,
random: Hash256::zero(),
prev_randao: Hash256::zero(),
suggested_fee_recipient: Address::from_str("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap(),
})
)
Expand Down Expand Up @@ -806,7 +806,7 @@ mod test {
"stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45",
"receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logsBloom": LOGS_BLOOM_00,
"random": HASH_00,
"prevRandao": HASH_00,
"blockNumber":"0x1",
"gasLimit":"0x1c95111",
"gasUsed":"0x0",
Expand All @@ -829,7 +829,7 @@ mod test {
state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(),
receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(),
logs_bloom: vec![0; 256].into(),
random: Hash256::zero(),
prev_randao: Hash256::zero(),
block_number: 1,
gas_limit: u64::from_str_radix("1c95111",16).unwrap(),
gas_used: 0,
Expand All @@ -854,7 +854,7 @@ mod test {
state_root: Hash256::from_str("0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45").unwrap(),
receipts_root: Hash256::from_str("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").unwrap(),
logs_bloom: vec![0; 256].into(),
random: Hash256::zero(),
prev_randao: Hash256::zero(),
block_number: 1,
gas_limit: u64::from_str_radix("1c9c380",16).unwrap(),
gas_used: 0,
Expand All @@ -876,7 +876,7 @@ mod test {
"stateRoot":"0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45",
"receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logsBloom": LOGS_BLOOM_00,
"random": HASH_00,
"prevRandao": HASH_00,
"blockNumber":"0x1",
"gasLimit":"0x1c9c380",
"gasUsed":"0x0",
Expand Down
Loading

0 comments on commit 1630817

Please sign in to comment.