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

EC: Besu code directory summary for those who are willing to start contributing to this EC #191

Merged
merged 14 commits into from
Apr 26, 2024
128 changes: 128 additions & 0 deletions docs/wiki/EL/besu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
### Besu Execution Client
taxmeifyoucan marked this conversation as resolved.
Show resolved Hide resolved
This is a brief summary of important information you need to know when starting to contribute to `Besu`:
#### Code directory explanation
taxmeifyoucan marked this conversation as resolved.
Show resolved Hide resolved

##### Modules
taxmeifyoucan marked this conversation as resolved.
Show resolved Hide resolved
+ It is a multi-module [gradle](https://gradle.org/) project. You can take a look to settings.gradle to see all modules:
+ Each module has its own build.gradle:
+ You can specify its module name: `archiveBaseName`
+ You can specify its dependencies but without versions.
+ Each module has its own source code here: /src/main/java
+ **There are top-level modules**:
+ `config`:
+ Where most of the configuration is assembled, validated.
+ You can find the genesis information.
+ `besu:`
+ All the CL arguments are being defined.
+ Is where the main method is located.
+ **There are complementary modules**:
+ `crypto`:
+ Everything relative to cryptographic keys.
+ `data types`:
+ Data types being used by Besu.
+ `metrics`:
+ OpenTelemetry/Prometheus not tight to internal Besu.
+ `ethereum`:
+ Is not a module but contains modules :
+ api :
+ All interaction you want to have with ethereum, world state.
+ core:
+ Storing date, quorum setup.
+ `evm`:
+ EVM behavior
+ In this module you can find each opcode operation implementation.
+ **There are enterprise modules:**
+ enclave, plugin-api, privacy-contracts

##### Gradle
+ gradlew (file) :
+ It is a bash script that will check if gradle is installed or not ( will install the wrapper for you and download the whole distribution)
+ Gradle itself is managed as part of a wrapper that is used by calling this script.
+ gradle (folder):
+ gradle-wrapper.properties:
+ distributionURL : points to the distribution to be used when calling ./gradlew
+ versions.gradle (file):
+ It is where all module's versions are defined. It is used by gradlew.
+ build.gradle (file):
+ plugins:
+ `spotless`: Code formatting, check licensing, etc,
+ Command: `./gradlew spotlessApply`
+ `errorprone`: Compliance with best practices in Java.
+ Command: `./gradlew errorProne`
+ distribution:
+ It defines where the building output is left by taking all projects into an application:
+ .tar .zip distributions. You can see a .tar or .zip under builder/distributions.
+ build (folder):
+ It's not a module.
+ distributions (folder):
+ Location of the Besu distribution.
+ If you go deeper to build/distribution/besu-{version}-SNAPSHOT/lib you can see each version of each component and libraries.

##### Testing
+ Unit tests:
+ Each module has its unit testing under src/test/java
+ Integration tests:
+ Each module has its integration test under src/integration-test/java:
+ Are more rare.
+ Are run outside of the inner internals of the code.
+ Are involved in more expensive runs.
+ Acceptance tests:
+ Are located under the acceptance-test-module.
+ Runs multiple Beau's nodes to create consensus algorithms between them and performs task adjusting and propagating blocks.
+ Reference tests:
+ Taken after Ethereum tests, borrowed by the Ethereum foundation.
+ Are the same for all clients: https://github.com/ethereum/tests
+ Are stored in JSON:
+ Location: `ethereum/referencetests/`
+ Other info:
+ JUnit 4


##### Development tasks:
+ Some useful commands:
+ `git pull --recurse-submodules`.
+ `./gradlew spotlessApply`
+ `./gradlew check` (it is run by CI every time you make a PR to Besu repository)
+ `./gradlew assemble`
+ In case you want to connect your MM to your local Besu node, you should run Besu with these options:
+ bin/besu --network=dev --rpc-http-enabled --rpc-http-cors-origins=chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn
+ RPC URL: http://localhost:8545


##### Important classes:
+ `BesuControllerBuilder`:
+ Manages all the components that are going to be used and needed to setup the client.
+ On the build method you can see if you are building the correct domain object.
+ It returns a BesuController.
+ `BesuCommand`:
+ Represents the main Besu CLI command.
+ `ForkIdManager`:
+ Responsible for building and representing the latest fork synchronized.
+ We always need to know where we are in terms of our own chain. This check is done constantly.
+ It is created on EthProtocolManager which is created on BesuControllerBuilder.
+ `ProtocolSchedule`:
+ Keeps track of all the configuration items as part of a specific range of block numbers for a chain.
+ `ProtocolSpec`:
+ Let's you configure every aspect of how things work inside the protocol.
+ `MainnetProtocolSpec`:
+ You will find every spec since frontier.
+ Each new spec is built on top of the previous one and add or change what is necessary.
+ `MainnetEVMs`:
+ Provides to the EVM the appropriate operations for mainnet hard forks.
+ It is an aggregate state where most of the time you will be adding new features to the spec itself.
+ New operations will be registered here.
+ `JsonRpcMethodsFactory`:
+ A builder class for RPC methods.
+ From here you can understand how to create new RPC methods.


##### Important libraries:
+ https://doc.libsodium.org/:
+ Sodium is a modern, easy-to-use software library for encryption, decryption, signatures, password hashing, and more.
+ https://github.com/nss-dev/nss:
+ Network Security Services (NSS) is a set of libraries designed to support cross-platform development of security-enabled client and server applications. NSS supports TLS 1.2, TLS 1.3, PKCS #5, PKCS#7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other security standards.

####### References:
+ https://www.youtube.com/watch?v=4pCxwuNRaKg
+ https://github.com/hyperledger/besu
+ https://wiki.hyperledger.org/display/besu
7 changes: 7 additions & 0 deletions wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Bankless
Barnabe
Beiko
Bertoni
Besu
BFT
bitrate
bitwise
Expand Down Expand Up @@ -171,6 +172,8 @@ Goron
Goomy
gpg
Grafana
gradle
gradlew
Guillaume
hoc
Holesky
Expand Down Expand Up @@ -257,6 +260,7 @@ NFT
NIST
NIST's
NOXX
NSS
Occhipinti
offsites
onchain
Expand All @@ -282,6 +286,7 @@ POS
PQCA
PQ
PQC
PKCS
pre
precompile
precompiled
Expand Down Expand Up @@ -348,6 +353,7 @@ SNARKify
socio
solvm
SPHINCS
src
SSF
SSLE
SSTORE
Expand All @@ -368,6 +374,7 @@ testnet
Tetris
textnormal
TODO
TLS
TPS
tracoor
tradeoff
Expand Down