Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

consortium-v2: new RLP encoder/decoder for HeaderExtraData #415

Merged
merged 5 commits into from
Mar 20, 2024

Conversation

andicrypt
Copy link
Contributor

Currently, HeaderExtraData is encoded/decoded manually, which is error prone and hard to extend. Hence, this PR implements a new RLP encoder/decoder for HeaderExtraData and changes to use this new method.

@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch from 5381b39 to b30a69b Compare March 11, 2024 06:53
@andicrypt andicrypt changed the title Consensus: new RLP encoder/decoder for HeaderExtraData. consortium: new RLP encoder/decoder for HeaderExtraData. Mar 11, 2024
@andicrypt andicrypt changed the title consortium: new RLP encoder/decoder for HeaderExtraData. consortium-v2: new RLP encoder/decoder for HeaderExtraData. Mar 11, 2024
@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch 2 times, most recently from 895dd5b to 0ec2859 Compare March 12, 2024 06:09
@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch 4 times, most recently from df24f03 to 7e5a642 Compare March 13, 2024 03:46
@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch from 7e5a642 to 00c57bb Compare March 13, 2024 10:30
@minh-bq minh-bq changed the title consortium-v2: new RLP encoder/decoder for HeaderExtraData. consortium-v2: new RLP encoder/decoder for HeaderExtraData Mar 14, 2024
@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch 2 times, most recently from e53a5f6 to 7e6f822 Compare March 19, 2024 04:51
@andicrypt
Copy link
Contributor Author

andicrypt commented Mar 19, 2024

Benchmark the length of encoded data (in bytes) in setting of 22 validators. The data is evaluated in term of the length of bytes.
Note: binary represents the presence of fields in mock extra data such that 0 (vacant), 1 (filled) from the right to left:
1st bit: (HasFinalityVotes, FinalityVotedValidators, AggregatedFinalityVotes)
2nd bit: CheckpointValidators
3rd bit: Seal

    consortium_test.go:650: binary: 000, original: 98; new: 69
    consortium_test.go:650: binary: 001, original: 202; new: 167
    consortium_test.go:650: binary: 010, original: 1594; new: 1657
    consortium_test.go:650: binary: 011, original: 1698; new: 1754
    consortium_test.go:650: binary: 100, original: 98; new: 69
    consortium_test.go:650: binary: 101, original: 202; new: 167
    consortium_test.go:650: binary: 110, original: 1594; new: 1657

@andicrypt
Copy link
Contributor Author

andicrypt commented Mar 19, 2024

Note: the smaller is better.
Benchmark the encoding performance, take performance average of 100k times of executions:

BenchmarkEncodeRLP-10             100000              6821 ns/op            6488 B/op         28 allocs/op
BenchmarkEncode-10                100000              6013 ns/op            7120 B/op         31 allocs/op

Benchmark the decoding performance, take performance average of 100k times of executions:

BenchmarkDecodeRLP-10             100000             81366 ns/op            8965 B/op         86 allocs/op
BenchmarkDecode-10                100000             76732 ns/op            3544 B/op         48 allocs/op

@andicrypt andicrypt force-pushed the feat/extra-data-rlp branch from 7e6f822 to fb5c83e Compare March 19, 2024 09:22
@minh-bq minh-bq force-pushed the feat/extra-data-rlp branch from 2bb1d37 to 13f9be0 Compare March 20, 2024 07:59
@minh-bq minh-bq merged commit 61f0db6 into feat/rotating-validator Mar 20, 2024
1 check passed
@minh-bq minh-bq deleted the feat/extra-data-rlp branch March 20, 2024 08:00
@andicrypt andicrypt restored the feat/extra-data-rlp branch March 21, 2024 07:16
@andicrypt andicrypt deleted the feat/extra-data-rlp branch March 21, 2024 07:25
minh-bq added a commit that referenced this pull request Apr 22, 2024
* consortium-v2: implement RLP encoding for header extra data

* consortium-v2: integrate new RLP encoder/decoder for header extra data

* consortium-v2: optimize extra data rlp encoding

* consortium-v2: benchmark for new rlp encoding

* consortium-v2: clean up unit test

---------

Co-authored-by: Bui Quang Minh <[email protected]>
minh-bq added a commit that referenced this pull request May 21, 2024
* consortium-v2: implement RLP encoding for header extra data

* consortium-v2: integrate new RLP encoder/decoder for header extra data

* consortium-v2: optimize extra data rlp encoding

* consortium-v2: benchmark for new rlp encoding

* consortium-v2: clean up unit test

---------

Co-authored-by: Bui Quang Minh <[email protected]>
minh-bq added a commit that referenced this pull request May 21, 2024
* consortium-v2: implement RLP encoding for header extra data

* consortium-v2: integrate new RLP encoder/decoder for header extra data

* consortium-v2: optimize extra data rlp encoding

* consortium-v2: benchmark for new rlp encoding

* consortium-v2: clean up unit test

---------

Co-authored-by: Bui Quang Minh <[email protected]>
Francesco4203 pushed a commit to Francesco4203/ronin that referenced this pull request Jun 18, 2024
…ity#415)

* consortium-v2: implement RLP encoding for header extra data

* consortium-v2: integrate new RLP encoder/decoder for header extra data

* consortium-v2: optimize extra data rlp encoding

* consortium-v2: benchmark for new rlp encoding

* consortium-v2: clean up unit test

---------

Co-authored-by: Bui Quang Minh <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants