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

feat: implement Filecoin.EthGetBlockByNumber #4138

Merged
merged 110 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
0c24d27
Add EthGetBlockByNumber method (wip)
elmattic Apr 3, 2024
7b1c5e0
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 3, 2024
ca7374d
Fix EthBlock construction
elmattic Apr 3, 2024
32c52ec
Fix gas limit
elmattic Apr 3, 2024
7da6a77
Refactor using first method
elmattic Apr 3, 2024
f94b0ee
Add full bloom filter
elmattic Apr 3, 2024
a282565
Add empty uncles hash
elmattic Apr 3, 2024
ee5cae0
Start to add support for txs
elmattic Apr 3, 2024
c3ef03a
Add support for eth message (wip)
elmattic Apr 4, 2024
a7f5b91
Add from_filecoin_address impl
elmattic Apr 4, 2024
be215c8
Add eth_tx_args_from_unsigned_eth_message impl
elmattic Apr 4, 2024
256627f
Add eth_tx_from_native_message impl (wip)
elmattic Apr 4, 2024
d18ca39
Add support for to/from addr to Tx
elmattic Apr 5, 2024
ea58cc7
Refactor using trait
elmattic Apr 5, 2024
f7a2bf5
Add input to Tx (wip)
elmattic Apr 5, 2024
1bf353b
Use chainId from chain config
elmattic Apr 5, 2024
d3f782b
Fix eth tx
elmattic Apr 5, 2024
900ea42
Add native message support (wip)
elmattic Apr 8, 2024
9f28f80
Add unit test and fix slice copy and formatting issues
elmattic Apr 8, 2024
792d7c2
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 8, 2024
c8cb12a
Fix the To address for unsigned eth tx
elmattic Apr 9, 2024
eae9477
Minor refactor
elmattic Apr 9, 2024
c1e1281
Add unit test for tx rpl encoding
elmattic Apr 9, 2024
640b6f0
Add missing test
elmattic Apr 9, 2024
a9637d2
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 9, 2024
6028b65
Start implementation of TxArgs rlp encoding
elmattic Apr 10, 2024
37cec83
Fix sig data in unit test
elmattic Apr 10, 2024
f5032a3
Fix sig beeing inline during rlp encoding
elmattic Apr 10, 2024
2249a81
Fix input member that was starting with too much bytes
elmattic Apr 10, 2024
02887c6
Fix access list rlp encoding
elmattic Apr 10, 2024
1a3bf51
Add comment
elmattic Apr 10, 2024
c523216
The unit test passing
elmattic Apr 10, 2024
e7700d0
Fix sig that was badly recovered
elmattic Apr 10, 2024
9e51858
Fix remaining cbor decoding issue
elmattic Apr 10, 2024
503f5af
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 11, 2024
f9c795f
Apply clippy suggestions
elmattic Apr 11, 2024
f9abe44
Fix deserial of byte vector
elmattic Apr 11, 2024
79ab77f
Try to make non-full tx mode work (wip)
elmattic Apr 11, 2024
a717875
Fix incorrect usage of hash
elmattic Apr 11, 2024
619ad9f
Rename method to avoid confusion
elmattic Apr 11, 2024
be83048
Complete support for full_tx_info flag
elmattic Apr 11, 2024
cbc8e08
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 11, 2024
cd69cb4
Avoid allocating temp strings
elmattic Apr 11, 2024
3258c31
Fix a few clippy errors
elmattic Apr 11, 2024
6469118
Rework naming
elmattic Apr 11, 2024
66e1083
Fix another clippy error
elmattic Apr 11, 2024
90a8af9
Optimize format_u64 function
elmattic Apr 12, 2024
491fd33
Allow indexing slicing
elmattic Apr 12, 2024
f6cca6b
Allow indexing slicing
elmattic Apr 12, 2024
4df46e6
Allow indexing slicing
elmattic Apr 12, 2024
baa0426
Allow code hoarding
elmattic Apr 12, 2024
7683c4e
Remove dead code
elmattic Apr 12, 2024
024e958
Move to Option for the To address in eth::Tx
elmattic Apr 12, 2024
6d362b2
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 12, 2024
cbaa298
Refactor to avoid mutation
elmattic Apr 12, 2024
fab11aa
Refactor to avoid mutation
elmattic Apr 12, 2024
ba6b4a4
Remove redundant field names
elmattic Apr 12, 2024
0f56ca3
Update CHANGELOG
elmattic Apr 12, 2024
357f22c
Remove dead code
elmattic Apr 12, 2024
49fc5ab
Add link to Lotus implementation
elmattic Apr 12, 2024
e2c3ec6
Shave some bytes off
elmattic Apr 12, 2024
9ed74f7
Avoid mutation
elmattic Apr 12, 2024
ef7b008
Add quickcheck test
elmattic Apr 12, 2024
9808c1f
Add quickcheck test for bigint_roundtrip
elmattic Apr 12, 2024
b2bcf3c
Remove comment
elmattic Apr 12, 2024
ee05ded
Change format_bigint to fail on negative inputs
elmattic Apr 15, 2024
5d91a3c
Remove clippy directive, use get/except and strenghten len test
elmattic Apr 15, 2024
968c0ac
Rewrite from_actor_id to avoid indexing slicing and add unit test
elmattic Apr 15, 2024
cda5201
Remove clippy directive and add comment
elmattic Apr 15, 2024
14ab79d
Rewrite format_bigint to avoid indexing slicing
elmattic Apr 15, 2024
f3d1592
Remove clippy directive
elmattic Apr 15, 2024
bafc4af
Remove clippy directive
elmattic Apr 15, 2024
bb46648
Reduce expression
elmattic Apr 15, 2024
01a3dc4
Add two more tests for eth abi
elmattic Apr 15, 2024
a2ae7bc
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 15, 2024
d46ece1
Refactor get_parent_receipts internal to use a shimmed function
elmattic Apr 16, 2024
6ea3ad3
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 16, 2024
76d9bc2
Add eth::Address serde roundtrip test
elmattic Apr 16, 2024
8c108e2
Use copy_from_slice instead
elmattic Apr 16, 2024
f6f502f
Fix incorrect expected value (test still fiascoes)
elmattic Apr 16, 2024
971e3d3
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 16, 2024
2b876ea
Add comment
elmattic Apr 16, 2024
e971eec
Revert ref (the third type is bytes[])
elmattic Apr 16, 2024
3425fa5
Fix expected value
elmattic Apr 16, 2024
bfb263c
Rewrite encode_as_abi_helper to remove indexing slicing
elmattic Apr 16, 2024
e20bd27
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 16, 2024
3cc89fc
Fix clippy errors in test module
elmattic Apr 16, 2024
8eb8750
Use existing const binding
elmattic Apr 17, 2024
400d1de
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 17, 2024
8421eb4
Add some doc comments
elmattic Apr 17, 2024
95d2fec
Add some doc comment
elmattic Apr 17, 2024
3c6fe4d
Add link to solidity abi spec
elmattic Apr 17, 2024
516fef6
Add quickcheck test
elmattic Apr 17, 2024
b6f2676
Remove some comments
elmattic Apr 17, 2024
dfb6f31
Improve comment
elmattic Apr 17, 2024
1a52e2c
Remove unwrap and address TODO
elmattic Apr 17, 2024
1fba910
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 17, 2024
a2c3032
Remove todo comment
elmattic Apr 17, 2024
fc98a78
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 18, 2024
d3e8d04
Fix doc comment
elmattic Apr 18, 2024
c541e57
Fix build errors
elmattic Apr 18, 2024
c436ed0
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 18, 2024
9d36be1
Refactor function name and remove useless code
elmattic Apr 18, 2024
c1ce3fa
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 18, 2024
780664e
Update src/shim/executor.rs
elmattic Apr 19, 2024
67d3f40
Fix build
elmattic Apr 19, 2024
6b5905c
Fil Block not initialized properly
elmattic Apr 19, 2024
30296ba
Add empty_uncles ctor
elmattic Apr 19, 2024
b399691
Add unit test for block ctor
elmattic Apr 19, 2024
ed3e510
Merge branch 'main' into elmattic/eth-get-block-by-number
elmattic Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
- [#4184](https://github.com/ChainSafe/forest/pull/4184) Added
`--no-healthcheck` flag to `forest` to disable the healthcheck endpoint.

- [#4183](https://github.com/ChainSafe/forest/issues/4183) Add support for the
`Filecoin.EthGetBlockByNumber` RPC method.

### Changed

- [#4170](https://github.com/ChainSafe/forest/pull/4170) Change the default
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ git-version = "0.3"
group = "0.13"
hex = { version = "0.4", features = ["serde"] }
http = "1.0"
keccak-hash = "0.10.0"
rlp = "0.5.2"
# TODO(forest): https://github.com/ChainSafe/forest/issues/3961
# bump hyper to 1.0 after https://github.com/paritytech/jsonrpsee/issues/1257
http02 = { version = "0.2", package = "http" }
Expand Down
33 changes: 33 additions & 0 deletions src/lotus_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,39 @@ pub mod hexify_bytes {
}
}

pub mod hexify_vec_bytes {
elmattic marked this conversation as resolved.
Show resolved Hide resolved
use super::*;
use std::fmt::Write;

pub fn serialize<S>(value: &[u8], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut s = String::with_capacity(2 + value.len() * 2);
s.push_str("0x");
for b in value {
write!(s, "{:02x}", b).expect("failed to write to string");
}
serializer.serialize_str(&s)
}

pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
if (s.len() >= 2 && s.len() % 2 == 0) && s.get(..2).expect("failed to get prefix") == "0x" {
let result: Result<Vec<u8>, _> = (2..s.len())
.step_by(2)
.map(|i| u8::from_str_radix(s.get(i..i + 2).expect("failed to get slice"), 16))
.collect();
result.map_err(serde::de::Error::custom)
} else {
Err(serde::de::Error::custom("Invalid hex"))
}
}
}

/// Usage: `#[serde(with = "hexify")]`
pub mod hexify {
use super::*;
Expand Down
1 change: 1 addition & 0 deletions src/rpc/auth_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static ACCESS_MAP: Lazy<HashMap<&str, Access>> = Lazy::new(|| {
access.insert(eth::ETH_GAS_PRICE, Access::Read);
access.insert(eth::ETH_GET_BALANCE, Access::Read);
access.insert(eth::ETH_SYNCING, Access::Read);
access.insert(eth::ETH_GET_BLOCK_BY_NUMBER, Access::Read);
access.insert(eth::WEB3_CLIENT_VERSION, Access::Read);

// Pubsub API
Expand Down
Loading
Loading