-
Notifications
You must be signed in to change notification settings - Fork 249
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
alloy-consensus crate #83
Merged
Merged
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
87ee3b5
refactor: signature keeps v r s in mem
prestwich fd383ce
fix: network
prestwich 197d88c
fix: misc fixes for new signature methods
prestwich fa00a37
feature: custom 2718 error
prestwich 2e94cbb
fix: transaction may not be RLP
prestwich d3afce7
remove log mod
prestwich 873887a
feature: Header, constants, and pure calculations
prestwich 8cfb573
refactor: impl Sealable
prestwich bc874a1
refactor: move 2718 and add docs
prestwich 356efb4
chore: enable lints
prestwich ee68856
fix: const fns
prestwich 1a240d0
fix: correct eip2718 network encoding behavior
prestwich a957c3b
feature: arbitrary
prestwich 7ea13e5
cleanup: deps and patch
prestwich ed028fd
feature: Receipt trait
prestwich 1d02916
fix: impl bloom_cheap
prestwich 119b5cb
feature: generic signature
prestwich 54b83e7
doc: document signature type
prestwich b234327
fix: remove encodable bound
prestwich 5dac547
refactor: signabletx trait
prestwich be9c439
fix: some lints and such
prestwich bc44627
fix: remove dbg
prestwich ec7ca26
fix: spacing
prestwich b45f1ac
feature: alloy-eips
prestwich c39f37e
chore: port access list
prestwich 3b6b188
misc arbitrary cleanup
prestwich 59c4de0
fix: encode_2718 length
prestwich 7a666b3
fix: use core git main instead of local
DaniPopes 3c2e155
Merge branch 'main' into prestwich/new-signature
DaniPopes ae063b8
chore: clippy, docs
DaniPopes a0799e4
fix: features
DaniPopes 4a70592
fix: cap arbitrary logs
DaniPopes 7295a49
chore: use Vec instead of BufMut where possible
DaniPopes c89a7b9
feat: fix Signer EIP-155, implement sign_transaction
DaniPopes 74e8207
chore: make ledger internal sign tx public
DaniPopes ba60ce9
chore: remove eip1559 duplicate functions
DaniPopes 8a57c67
feat: implement sign_transaction on Trezor (#100)
DaniPopes c70c11c
Merge branch 'main' into prestwich/new-signature
DaniPopes f19501d
chore: relax requirements
DaniPopes c93a8f7
chore: address review
DaniPopes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,10 @@ all-features = true | |
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[workspace.dependencies] | ||
alloy-consensus = { version = "0.1.0", path = "crates/consensus" } | ||
alloy-eips = { version = "0.1.0", path = "crates/eips" } | ||
alloy-json-rpc = { version = "0.1.0", path = "crates/json-rpc" } | ||
alloy-networks = { version = "0.1.0", path = "crates/networks" } | ||
alloy-network = { version = "0.1.0", path = "crates/network" } | ||
alloy-pubsub = { version = "0.1.0", path = "crates/pubsub" } | ||
alloy-rpc-client = { version = "0.1.0", path = "crates/rpc-client" } | ||
alloy-rpc-types = { version = "0.1.0", path = "crates/rpc-types" } | ||
|
@@ -37,11 +39,12 @@ alloy-sol-types = { version = "0.5.1", default-features = false, features = ["st | |
alloy-rlp = "0.3" | ||
|
||
# crypto | ||
elliptic-curve = { version = "0.13.5", default-features = false, features = ["std"] } | ||
generic-array = { version = "0.14.7", default-features = false, features = ["std"] } | ||
k256 = { version = "0.13.2", default-features = false, features = ["ecdsa", "std"] } | ||
sha2 = { version = "0.10.8", default-features = false, features = ["std"] } | ||
spki = { version = "0.7.2", default-features = false, features = ["std"] } | ||
c-kzg = "0.4.0" # for eip-4844 | ||
elliptic-curve = { version = "0.13", default-features = false, features = ["std"] } | ||
generic-array = { version = "0.14", default-features = false, features = ["std"] } | ||
k256 = { version = "0.13", default-features = false, features = ["ecdsa", "std"] } | ||
sha2 = { version = "0.10", default-features = false, features = ["std"] } | ||
spki = { version = "0.7", default-features = false, features = ["std"] } | ||
|
||
# async | ||
async-trait = "0.1.74" | ||
|
@@ -57,13 +60,13 @@ tower = { version = "0.4.13", features = ["util"] } | |
tracing = "0.1.40" | ||
tracing-subscriber = "0.3.18" | ||
|
||
tempfile = "3.8" | ||
|
||
# misc | ||
auto_impl = "1.1" | ||
base64 = "0.21" | ||
bimap = "0.6" | ||
home = "0.5" | ||
itertools = "0.12" | ||
once_cell = "1.17" | ||
pin-project = "1.1" | ||
rand = "0.8.5" | ||
reqwest = { version = "0.11.18", default-features = false } | ||
|
@@ -78,7 +81,13 @@ serde_json = "1.0" | |
## misc-testing | ||
arbitrary = "1.3" | ||
assert_matches = "1.5" | ||
similar-asserts = "1.5" | ||
proptest = "1.4" | ||
proptest-derive = "0.4" | ||
serial_test = "2.0" | ||
similar-asserts = "1.5" | ||
tempfile = "3.8" | ||
|
||
[patch.crates-io] | ||
prestwich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
alloy-primitives = { git = "https://github.com/alloy-rs/core" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can remove? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this will need a 0.6 release |
||
alloy-sol-types = { git = "https://github.com/alloy-rs/core" } | ||
alloy-sol-macro = { git = "https://github.com/alloy-rs/core" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
name = "alloy-consensus" | ||
description = "Ethereum consensus interface" | ||
|
||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
exclude.workspace = true | ||
|
||
[dependencies] | ||
alloy-network.workspace = true | ||
alloy-primitives = { workspace = true, features = ["rlp"] } | ||
alloy-rlp.workspace = true | ||
alloy-eips.workspace = true | ||
|
||
# arbitrary | ||
arbitrary = { workspace = true, features = ["derive"], optional = true } | ||
|
||
[dev-dependencies] | ||
# arbitrary | ||
arbitrary = { workspace = true, features = ["derive"] } | ||
|
||
[features] | ||
k256 = ["alloy-primitives/k256", "alloy-network/k256"] | ||
arbitrary = ["dep:arbitrary", "alloy-eips/arbitrary"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# alloy-consensus | ||
|
||
Consensus types for the Ethereum blockchain. | ||
|
||
This crate contains constants, types, and functions for implementing Ethereum | ||
EL consensus and communication. This includes headers, blocks, transactions, | ||
eip2718 envelopes, eip2930, eip4844, and more. The types in this crate | ||
implement many of the traits found in [alloy_network]. | ||
|
||
In general a type belongs in this crate if it is committed to in the EL block | ||
header. This includes: | ||
|
||
- transactions | ||
- blocks | ||
- headers | ||
- receipts | ||
- [EIP-2718] envelopes. | ||
|
||
[alloy-network]: ../network | ||
[EIP-2718]: https://eips.ethereum.org/EIPS/eip-2718 | ||
|
||
## Provenance | ||
|
||
Much of this code was ported from [reth-primitives] as part of ongoing alloy | ||
migrations. | ||
|
||
[reth-primitives]: https://github.com/paradigmxyz/reth/tree/main/crates/primitives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//! Ethereum protocol-related constants | ||
use alloy_primitives::{address, b256, Address, B256}; | ||
|
||
/// The first four bytes of the call data for a function call specifies the function to be called. | ||
pub const SELECTOR_LEN: usize = 4; | ||
|
||
/// Maximum extra data size in a block after genesis | ||
pub const MAXIMUM_EXTRA_DATA_SIZE: usize = 32; | ||
|
||
/// Multiplier for converting gwei to wei. | ||
pub const GWEI_TO_WEI: u64 = 1_000_000_000; | ||
|
||
/// Multiplier for converting finney (milliether) to wei. | ||
pub const FINNEY_TO_WEI: u128 = (GWEI_TO_WEI as u128) * 1_000_000; | ||
|
||
/// Multiplier for converting ether to wei. | ||
pub const ETH_TO_WEI: u128 = FINNEY_TO_WEI * 1000; | ||
|
||
/// Multiplier for converting mgas to gas. | ||
pub const MGAS_TO_GAS: u64 = 1_000_000u64; | ||
|
||
/// The Ethereum mainnet genesis hash. | ||
pub const MAINNET_GENESIS_HASH: B256 = | ||
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"); | ||
|
||
/// Goerli genesis hash. | ||
pub const GOERLI_GENESIS_HASH: B256 = | ||
b256!("bf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a"); | ||
|
||
/// Sepolia genesis hash. | ||
pub const SEPOLIA_GENESIS_HASH: B256 = | ||
b256!("25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9"); | ||
|
||
/// Holesky genesis hash. | ||
pub const HOLESKY_GENESIS_HASH: B256 = | ||
b256!("ff9006519a8ce843ac9c28549d24211420b546e12ce2d170c77a8cca7964f23d"); | ||
|
||
/// Testnet genesis hash. | ||
pub const DEV_GENESIS_HASH: B256 = | ||
b256!("2f980576711e3617a5e4d83dd539548ec0f7792007d505a3d2e9674833af2d7c"); | ||
|
||
/// Optimism goerli genesis hash. | ||
pub const GOERLI_OP_GENESIS: B256 = | ||
b256!("c1fc15cd51159b1f1e5cbc4b82e85c1447ddfa33c52cf1d98d14fba0d6354be1"); | ||
|
||
/// Base goerli genesis hash. | ||
pub const GOERLI_BASE_GENESIS: B256 = | ||
b256!("a3ab140f15ea7f7443a4702da64c10314eb04d488e72974e02e2d728096b4f76"); | ||
|
||
/// Keccak256 over empty array. | ||
pub const KECCAK_EMPTY: B256 = | ||
b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); | ||
|
||
/// Ommer root of empty list. | ||
pub const EMPTY_OMMER_ROOT_HASH: B256 = | ||
b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"); | ||
|
||
/// Root hash of an empty trie. | ||
pub const EMPTY_ROOT_HASH: B256 = | ||
b256!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); | ||
|
||
/// Transactions root of empty receipts set. | ||
pub const EMPTY_RECEIPTS: B256 = EMPTY_ROOT_HASH; | ||
|
||
/// Transactions root of empty transactions set. | ||
pub const EMPTY_TRANSACTIONS: B256 = EMPTY_ROOT_HASH; | ||
|
||
/// Withdrawals root of empty withdrawals set. | ||
pub const EMPTY_WITHDRAWALS: B256 = EMPTY_ROOT_HASH; | ||
|
||
/// The address for the beacon roots contract defined in EIP-4788. | ||
pub const BEACON_ROOTS_ADDRESS: Address = address!("000F3df6D732807Ef1319fB7B8bB8522d0Beac02"); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this would be optional but maybe not possible here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the workspace dependencies, but anyway it's unused