Skip to content

Commit

Permalink
Merge pull request #5832 from ethDreamer/electra_attestation_changes_…
Browse files Browse the repository at this point in the history
…merge_unstable

Merge `unstable` into `electra_attestation_changes`
  • Loading branch information
realbigsean authored May 24, 2024
2 parents a8088f1 + 987abe0 commit 469296b
Show file tree
Hide file tree
Showing 103 changed files with 2,148 additions and 1,589 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ env:
# Enable portable to prevent issues with caching `blst` for the wrong CPU type
TEST_FEATURES: portable
jobs:
check-labels:
runs-on: ubuntu-latest
name: Check for 'skip-ci' label
outputs:
skip_ci: ${{ steps.set-output.outputs.SKIP_CI }}
steps:
- name: check for skip-ci label
id: set-output
env:
LABELS: ${{ toJson(github.event.pull_request.labels) }}
run: |
SKIP_CI="false"
if [ -z "${LABELS}" ]; then
LABELS="none";
else
LABELS=$(echo ${LABELS} | jq -r '.[].name')
fi
for label in ${LABELS}; do
if [ "$label" = "skip-ci" ]; then
SKIP_CI="true"
break
fi
done
echo "::set-output name=skip_ci::$SKIP_CI"
target-branch-check:
name: target-branch-check
runs-on: ubuntu-latest
Expand All @@ -38,6 +63,8 @@ jobs:
run: test ${{ github.base_ref }} != "stable"
release-tests-ubuntu:
name: release-tests-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
# Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "large"]') || 'ubuntu-latest' }}
steps:
Expand All @@ -63,6 +90,8 @@ jobs:
run: sccache --show-stats
release-tests-windows:
name: release-tests-windows
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "windows", "CI"]') || 'windows-2019' }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -97,6 +126,8 @@ jobs:
run: sccache --show-stats
beacon-chain-tests:
name: beacon-chain-tests
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
# Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "large"]') || 'ubuntu-latest' }}
env:
Expand All @@ -117,6 +148,8 @@ jobs:
run: sccache --show-stats
op-pool-tests:
name: op-pool-tests
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -132,6 +165,8 @@ jobs:
run: make test-op-pool
network-tests:
name: network-tests
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -147,6 +182,8 @@ jobs:
run: make test-network
slasher-tests:
name: slasher-tests
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -162,6 +199,8 @@ jobs:
run: make test-slasher
debug-tests-ubuntu:
name: debug-tests-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
# Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "large"]') || 'ubuntu-latest' }}
env:
Expand All @@ -186,6 +225,8 @@ jobs:
run: sccache --show-stats
state-transition-vectors-ubuntu:
name: state-transition-vectors-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -198,6 +239,8 @@ jobs:
run: make run-state-transition-tests
ef-tests-ubuntu:
name: ef-tests-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
# Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "small"]') || 'ubuntu-latest' }}
env:
Expand All @@ -218,6 +261,8 @@ jobs:
run: sccache --show-stats
dockerfile-ubuntu:
name: dockerfile-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -227,6 +272,8 @@ jobs:
run: docker run -t lighthouse:local lighthouse --version
basic-simulator-ubuntu:
name: basic-simulator-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -239,6 +286,8 @@ jobs:
run: cargo run --release --bin simulator basic-sim
fallback-simulator-ubuntu:
name: fallback-simulator-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -251,6 +300,8 @@ jobs:
run: cargo run --release --bin simulator fallback-sim
doppelganger-protection-test:
name: doppelganger-protection-test
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "small"]') || 'ubuntu-latest' }}
env:
# Enable portable to prevent issues with caching `blst` for the wrong CPU type
Expand Down Expand Up @@ -285,6 +336,8 @@ jobs:
./doppelganger_protection.sh success genesis.json
execution-engine-integration-ubuntu:
name: execution-engine-integration-ubuntu
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "small"]') || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -330,6 +383,8 @@ jobs:
run: make audit-CI
- name: Run cargo vendor to make sure dependencies can be vendored for packaging, reproducibility and archival purpose
run: CARGO_HOME=$(readlink -f $HOME) make vendor
- name: Markdown-linter
run: make mdlint
check-msrv:
name: check-msrv
runs-on: ubuntu-latest
Expand All @@ -344,6 +399,8 @@ jobs:
run: cargo check --workspace
cargo-udeps:
name: cargo-udeps
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -366,6 +423,8 @@ jobs:
RUSTFLAGS: ""
compile-with-beta-compiler:
name: compile-with-beta-compiler
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -377,6 +436,8 @@ jobs:
run: make
cli-check:
name: cli-check
needs: [check-labels]
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -391,8 +452,10 @@ jobs:
# a PR is safe to merge. New jobs should be added here.
test-suite-success:
name: test-suite-success
if: needs.check-labels.outputs.skip_ci != 'true'
runs-on: ubuntu-latest
needs: [
'check-labels',
'target-branch-check',
'release-tests-ubuntu',
'release-tests-windows',
Expand Down
42 changes: 26 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Contributors Guide

[![GitPOAP badge](https://public-api.gitpoap.io/v1/repo/sigp/lighthouse/badge)](https://www.gitpoap.io/gh/sigp/lighthouse)

Lighthouse is an open-source Ethereum 2.0 client. We're community driven and
Lighthouse is an open-source Ethereum consensus client. We're community driven and
welcome all contribution. We aim to provide a constructive, respectful and fun
environment for collaboration.

We are active contributors to the [Ethereum 2.0 specification](https://github.com/ethereum/eth2.0-specs) and attend all [Eth
2.0 implementers calls](https://github.com/ethereum/eth2.0-pm).
We are active contributors to
the [Ethereum Proof-of-Stake Consensus specification](https://github.com/ethereum/consensus-specs) and attend
all [Ethereum implementers calls](https://github.com/ethereum/pm/).

This guide is geared towards beginners. If you're an open-source veteran feel
free to just skim this document and get straight into crushing issues.
Expand Down Expand Up @@ -41,21 +43,21 @@ We recommend the following work-flow for contributors:

1. **Find an issue** to work on, either because it's interesting or suitable to
your skill-set. Use comments to communicate your intentions and ask
questions.
questions.
2. **Work in a feature branch** of your personal fork
(github.com/YOUR_NAME/lighthouse) of the main repository
(github.com/sigp/lighthouse).
3. Once you feel you have addressed the issue, **create a pull-request** with
`unstable` as the base branch to merge your changes into the main repository.
4. Wait for the repository maintainers to **review your changes** to ensure the
issue is addressed satisfactorily. Optionally, mention your PR on
[discord](https://discord.gg/cyAszAh).
[discord](https://discord.gg/cyAszAh).
5. If the issue is addressed the repository maintainers will **merge your
pull-request** and you'll be an official contributor!

Generally, you find an issue you'd like to work on and announce your intentions
to start work in a comment on the issue. Then, do your work on a separate
branch (a "feature branch") in your own fork of the main repository. Once
branch (a "feature branch") in your own fork of the main repository. Once
you're happy and you think the issue has been addressed, create a pull request
into the main repository.

Expand All @@ -66,18 +68,20 @@ steps:

1. [Create a
fork](https://help.github.com/articles/fork-a-repo/#fork-an-example-repository)
and [clone
it](https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork)
to your local machine.
and [clone
it](https://help.github.com/articles/fork-a-repo/#step-2-create-a-local-clone-of-your-fork)
to your local machine.
2. [Add an _"upstream"_
branch](https://help.github.com/articles/fork-a-repo/#step-3-configure-git-to-sync-your-fork-with-the-original-spoon-knife-repository)
that tracks github.com/sigp/lighthouse using `$ git remote add upstream
https://github.com/sigp/lighthouse.git` (pro-tip: [use SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) instead of HTTPS).
that tracks github.com/sigp/lighthouse using `$ git remote add upstream
https://github.com/sigp/lighthouse.git` (
pro-tip: [use SSH](https://help.github.com/articles/connecting-to-github-with-ssh/) instead of HTTPS).
3. Create a new feature branch with `$ git checkout -b your_feature_name`. The
name of your branch isn't critical but it should be short and instructive.
E.g., if you're fixing a bug with serialization, you could name your branch
`fix_serialization_bug`.
4. Make sure you sign your commits. See [relevant doc](https://help.github.com/en/github/authenticating-to-github/about-commit-signature-verification).
E.g., if you're fixing a bug with serialization, you could name your branch
`fix_serialization_bug`.
4. Make sure you sign your commits.
See [relevant doc](https://help.github.com/en/github/authenticating-to-github/about-commit-signature-verification).
5. Commit your changes and push them to your fork with `$ git push origin
your_feature_name`.
6. Go to your fork on github.com and use the web interface to create a pull
Expand All @@ -92,22 +96,28 @@ by Rob Allen that provides much more detail on each of these steps, if you're
having trouble. As always, jump on [discord](https://discord.gg/cyAszAh)
if you get stuck.

Additionally,
the ["Contributing to Lighthouse" section](https://lighthouse-book.sigmaprime.io/contributing.html#contributing-to-lighthouse)
of the Lighthouse Book provides more details on the setup.

## FAQs

### I don't think I have anything to add

There's lots to be done and there's all sorts of tasks. You can do anything
from correcting typos through to writing core consensus code. If you reach out,
from enhancing documentation through to writing core consensus code. If you reach out,
we'll include you.

Please note, to maintain project quality, we may not accept PRs for small typos or changes
with minimal impact.

### I'm not sure my Rust is good enough

We're open to developers of all levels. If you create a PR and your code
doesn't meet our standards, we'll help you fix it and we'll share the reasoning
with you. Contributing to open-source is a great way to learn.

### I'm not sure I know enough about Ethereum 2.0
### I'm not sure I know enough about Ethereum

No problems, there's plenty of tasks that don't require extensive Ethereum
knowledge. You can learn about Ethereum as you go.
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ cli:
cli-local:
make && ./scripts/cli.sh

# Check for markdown files
mdlint:
./scripts/mdlint.sh

# Runs the entire test suite, downloading test vectors if required.
test-full: cargo-fmt test-release test-debug test-ef test-exec-engine

Expand Down
14 changes: 11 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
signature_verified_block.block_root(),
signature_verified_block,
notify_execution_layer,
BlockImportSource::RangeSync,
|| Ok(()),
)
.await
Expand Down Expand Up @@ -3003,16 +3004,21 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
self: &Arc<Self>,
block_root: Hash256,
unverified_block: B,
block_source: BlockImportSource,
notify_execution_layer: NotifyExecutionLayer,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
self.reqresp_pre_import_cache
.write()
.insert(block_root, unverified_block.block_cloned());

let r = self
.process_block(block_root, unverified_block, notify_execution_layer, || {
Ok(())
})
.process_block(
block_root,
unverified_block,
notify_execution_layer,
block_source,
|| Ok(()),
)
.await;
self.remove_notified(&block_root, r)
}
Expand All @@ -3035,6 +3041,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
block_root: Hash256,
unverified_block: B,
notify_execution_layer: NotifyExecutionLayer,
block_source: BlockImportSource,
publish_fn: impl FnOnce() -> Result<(), BlockError<T::EthSpec>> + Send + 'static,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {
// Start the Prometheus timer.
Expand Down Expand Up @@ -3095,6 +3102,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
"Beacon block imported";
"block_root" => ?block_root,
"block_slot" => block_slot,
"source" => %block_source,
);

// Increment the Prometheus counter for block processing successes.
Expand Down
22 changes: 12 additions & 10 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,18 +1382,20 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
let catchup_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_CATCHUP_STATE);

// Stage a batch of operations to be completed atomically if this block is imported
// successfully. We include the state root of the pre-state, which may be an advanced state
// that was stored in the DB with a `temporary` flag.
// successfully. If there is a skipped slot, we include the state root of the pre-state,
// which may be an advanced state that was stored in the DB with a `temporary` flag.
let mut state = parent.pre_state;

let mut confirmed_state_roots = if state.slot() > parent.beacon_block.slot() {
// Advanced pre-state. Delete its temporary flag.
let pre_state_root = state.update_tree_hash_cache()?;
vec![pre_state_root]
} else {
// Pre state is parent state. It is already stored in the DB without temporary status.
vec![]
};
let mut confirmed_state_roots =
if block.slot() > state.slot() && state.slot() > parent.beacon_block.slot() {
// Advanced pre-state. Delete its temporary flag.
let pre_state_root = state.update_tree_hash_cache()?;
vec![pre_state_root]
} else {
// Pre state is either unadvanced, or should not be stored long-term because there
// is no skipped slot between `parent` and `block`.
vec![]
};

// The block must have a higher slot than its parent.
if block.slot() <= parent.beacon_block.slot() {
Expand Down
Loading

0 comments on commit 469296b

Please sign in to comment.