Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(forrestrie/examples): programmatically match ethereum block with its beacon slot #8

Conversation

suchapalaver
Copy link
Contributor

@suchapalaver suchapalaver commented Oct 19, 2024

BACK-38

Blocks occasionally miss slots. In such cases there's no execution payload in the Beacon Block. Given an Ethereum block, we need to find the Beacon Block with the Ethereum block in its execution payload.

This PR's aim is to provide an example of what needs to be done as a basis for further implementation and optimization in production code at a later stage.

@suchapalaver suchapalaver self-assigned this Oct 19, 2024
Copy link

linear bot commented Oct 19, 2024

BACK-38 Programmatically match Ethereum block with its Beacon slot.

Blocks occasionally miss slots. In such cases there's no execution payload in the Beacon Block. Given an Ethereum block, find the Beacon Block with the Ethereum block in its execution payload.

This comment has been minimized.

@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from 0c52bf1 to ed83653 Compare October 19, 2024 01:56
Copy link

🤖 Cargo Audit Report 🤖

Crate: object_store
Version: 0.9.1
Title: Apache Arrow Rust Object Store: AWS WebIdentityToken exposure in log files
Date: 2024-07-23
ID: RUSTSEC-2024-0358
URL: https://rustsec.org/advisories/RUSTSEC-2024-0358
Severity: 3.8 (low)
Solution: Upgrade to >=0.10.2
Dependency tree:
object_store 0.9.1
└── flat-head 0.1.0

Crate: ansi_term
Version: 0.12.1
Warning: unmaintained
Title: ansi_term is Unmaintained
Date: 2021-08-18
ID: RUSTSEC-2021-0139
URL: https://rustsec.org/advisories/RUSTSEC-2021-0139
Dependency tree:
ansi_term 0.12.1
└── trin-utils 0.1.1-alpha.1
└── ethportal-api 0.2.2
├── trin-validation 0.1.0
│ ├── header_accumulator 0.1.0
│ │ └── flat-head 0.1.0
│ └── flat-head 0.1.0
├── sf-protos 0.1.0
│ ├── header_accumulator 0.1.0
│ ├── forrestrie 0.1.0
│ ├── flat-head 0.1.0
│ ├── firehose-client 0.1.0
│ │ └── forrestrie 0.1.0
│ └── decoder 0.1.1
│ ├── header_accumulator 0.1.0
│ └── flat-head 0.1.0
├── header_accumulator 0.1.0
└── forrestrie 0.1.0

Crate: atty
Version: 0.2.14
Warning: unmaintained
Title: atty is unmaintained
Date: 2024-09-25
ID: RUSTSEC-2024-0375
URL: https://rustsec.org/advisories/RUSTSEC-2024-0375
Dependency tree:
atty 0.2.14
└── trin-utils 0.1.1-alpha.1
└── ethportal-api 0.2.2
├── trin-validation 0.1.0
│ ├── header_accumulator 0.1.0
│ │ └── flat-head 0.1.0
│ └── flat-head 0.1.0
├── sf-protos 0.1.0
│ ├── header_accumulator 0.1.0
│ ├── forrestrie 0.1.0
│ ├── flat-head 0.1.0
│ ├── firehose-client 0.1.0
│ │ └── forrestrie 0.1.0
│ └── decoder 0.1.1
│ ├── header_accumulator 0.1.0
│ └── flat-head 0.1.0
├── header_accumulator 0.1.0
└── forrestrie 0.1.0

Crate: dotenv
Version: 0.15.0
Warning: unmaintained
Title: dotenv is Unmaintained
Date: 2021-12-24
ID: RUSTSEC-2021-0141
URL: https://rustsec.org/advisories/RUSTSEC-2021-0141
Dependency tree:
dotenv 0.15.0
└── flat-head 0.1.0

Crate: proc-macro-error
Version: 1.0.4
Warning: unmaintained
Title: proc-macro-error is unmaintained
Date: 2024-09-01
ID: RUSTSEC-2024-0370
URL: https://rustsec.org/advisories/RUSTSEC-2024-0370
Dependency tree:
proc-macro-error 1.0.4
├── validator_derive 0.13.0
│ └── validator 0.13.0
│ └── ethportal-api 0.2.2
│ ├── trin-validation 0.1.0
│ │ ├── header_accumulator 0.1.0
│ │ │ └── flat-head 0.1.0
│ │ └── flat-head 0.1.0
│ ├── sf-protos 0.1.0
│ │ ├── header_accumulator 0.1.0
│ │ ├── forrestrie 0.1.0
│ │ ├── flat-head 0.1.0
│ │ ├── firehose-client 0.1.0
│ │ │ └── forrestrie 0.1.0
│ │ └── decoder 0.1.1
│ │ ├── header_accumulator 0.1.0
│ │ └── flat-head 0.1.0
│ ├── header_accumulator 0.1.0
│ └── forrestrie 0.1.0
├── alloy-sol-macro-expander 0.7.7
│ └── alloy-sol-macro 0.7.7
│ └── alloy-sol-types 0.7.7
│ ├── alloy-rpc-types-eth 0.1.4
│ │ ├── reth-primitives-traits 1.0.1
│ │ │ ├── reth-trie-common 1.0.1
│ │ │ │ ├── reth-primitives 1.0.1
│ │ │ │ │ ├── sf-protos 0.1.0
│ │ │ │ │ └── decoder 0.1.1
│ │ │ │ └── decoder 0.1.1
│ │ │ └── reth-primitives 1.0.1
│ │ └── alloy-rpc-types 0.1.4
│ │ └── reth-primitives 1.0.1
│ └── alloy-rpc-types 0.1.0
│ ├── reth-rpc-types 0.2.0-beta.5
│ │ └── ethportal-api 0.2.2
│ ├── alloy-rpc-types-trace 0.1.0
│ │ └── reth-rpc-types 0.2.0-beta.5
│ └── alloy-rpc-types-engine 0.1.0
│ └── reth-rpc-types 0.2.0-beta.5
└── alloy-sol-macro 0.7.7

Crate: atty
Version: 0.2.14
Warning: unsound
Title: Potential unaligned read
Date: 2021-07-04
ID: RUSTSEC-2021-0145
URL: https://rustsec.org/advisories/RUSTSEC-2021-0145

warning: 5 allowed warnings found

(Empty means OK! 👍)

@suchapalaver suchapalaver force-pushed the joseph/back-54-veemonforrestrie-fix-historical-summaries-index-in-example branch from e6af2a5 to 48a424d Compare October 21, 2024 13:48
Base automatically changed from joseph/back-54-veemonforrestrie-fix-historical-summaries-index-in-example to main October 21, 2024 14:02
@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from ed83653 to 976c8c5 Compare October 21, 2024 14:28
@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from 976c8c5 to ca5cfe3 Compare October 21, 2024 20:14
@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch 4 times, most recently from 6312f05 to 1b29eaf Compare October 21, 2024 21:20
@suchapalaver
Copy link
Contributor Author

@anirudh2 This is the last of the post-merge stuff I had in dev last from week.

@suchapalaver suchapalaver marked this pull request as ready for review October 21, 2024 21:22
@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from 1b29eaf to 27b71d5 Compare October 22, 2024 00:32
Copy link

@cbehn1 cbehn1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example ran successfully, output makes sense. Minor question for understanding in match_ethereum_to_beacon.rs.

cbehn1
cbehn1 previously approved these changes Oct 22, 2024
Copy link

@cbehn1 cbehn1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor question for understanding of constant value.

@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from 27b71d5 to 4827175 Compare October 22, 2024 13:47
Comment on lines 56 to 59
let mut high = EXECUTION_BLOCK_NUMBER - ETHEREUM_BEACON_DENEB_OFFSET as u64 + 2_000_000;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this magic number 2_000_000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A conservative guess. Because not every slot on the Beacon chain has a block in it, each time that happens the offset between the execution layer and the beacon chain grows. So this is just a super slack guess to get the ball rolling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, shouldn't we use EXECUTION_BLOCK_NUMBER - ETHEREUM_BEACON_DENEB_OFFSET as low? Since this would be without any missing slots.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high should be the current block isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, of course! 😄

match block_number.cmp(&EXECUTION_BLOCK_NUMBER) {
Less => low = mid + 1,
Greater => high = mid - 1,
_ => unreachable!(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are doing a cmp here, you could just add 77-80 here as Equal.

@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch 2 times, most recently from 41cb977 to 7b4c039 Compare October 23, 2024 13:15
@suchapalaver suchapalaver force-pushed the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch from 7b4c039 to d8f042d Compare October 23, 2024 14:45
@suchapalaver suchapalaver merged commit 1158a60 into main Oct 23, 2024
6 of 8 checks passed
@suchapalaver suchapalaver deleted the joseph/back-38-programmatically-match-ethereum-block-with-its-beacon-slot branch October 23, 2024 14:50
suchapalaver added a commit that referenced this pull request Nov 28, 2024
feat(HeadState): Added function to compute block root inclusion proof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants