-
Notifications
You must be signed in to change notification settings - Fork 20
refactor: abstract codec versions into common interfaces #25
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
Merged
colinlyguo
merged 128 commits into
main
from
refactor-move-some-util-functions-to-public-package
Oct 18, 2024
Merged
Changes from all commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
ad42cd9
feat: support conditional encode
62758c8
move append conditionalEncode flag after validity check
6901956
update da-codec
e4bf12e
align naming
030349d
add ConvertBlobToBlobBytes utility functions
ed4de9e
kept blob bytes
c6af3bb
rename enableEncode to enableCompress
a5691d4
refactor: move some common functions to encoding (#24)
colinlyguo 9532963
move symbol replace script to zstd folder
990bdb3
refactor: move some util functions to public package
6b86866
fix CI
3ad692a
add interfaces of codec
a5c6430
add SetCompression
43f56e6
move interface to encoding
cd280de
refactor
879bb98
add dablock.go
77aafd4
add dachunk.go
6ee5c19
add dabatch.go
79422a2
move computeBatchDataHash to codecv
296880e
fix
c038850
add DABatchBase
4499e2c
add GetCodecVersion
8e763dd
add BlobVersionedHashes
98d5635
rename encoding.go to interfaces.go
bdb98f8
add NewDABatchWithExpectedBlobVersionedHashes
f3f0fbd
Merge branch 'main' into refactor-move-some-util-functions-to-public-…
08d60a3
tweak
2d425d8
fix a bug
c1e4a0d
add more logs
e5df846
add DecodeDAChunks
ecaca71
add BlockRange interface
484fa59
fix
f1fe4c8
add version check
97711e2
add Version
2a63797
remove DABatchBase
87c4537
add DABlock
2ac7825
fixes
8a6c35f
fix
83f6b62
add CodecFromVersion and CodecFromConfig
c4a2495
remove GetCodecVersion
10af8e7
fix typos
1594e0f
make Block fields internal
1f9facd
make chunk fields internal
451eb68
make batch fields internal and add some tweaks
955f375
add JSONFromBytes
f73c63e
fix a typo
cf9f084
use register mode
5ef6c5f
Merge branch 'main' into refactor-move-some-util-functions-to-public-…
7eb1dc0
fix CI
91ac897
remove register mode
e6c8965
add common functions
ba853e3
add EstimateBlockL1CommitCalldataSize
aca0bef
add dabatch interfaces
95d2bc7
update interface implementations
75812c4
add data hash
78588e4
fix codecv3 & codecv4 estimate gas
45548e1
fix
4469219
fix bugs
6934f3d
tweak
0079225
add CheckChunkCompressedDataCompatibility & CheckBatchCompressedDataC…
3f774d2
fix
669b454
add BlobDataProofForPointEvaluation
09127a5
add nil check in NewDAChunk
1c519d6
make some util functions internal
d2350ff
remove GetMaxChunksPerBatch
b885af8
fix CI
986850d
change receiver mark from o to d
e222406
remove SetCompression
ef5ea6e
fix
9d9fd89
add GetChunkEnableCompression & GetBatchEnableCompression
df76a9d
fix
6e28644
update l2geth dependency
233b006
make types internal
8dbf796
embed codecv0 <- codecv1 <- codecv2 <- codecv3 <- codecv4
7891503
remove dablock.go dachunk.go dabatch.go
2703f22
trigger ci
443f126
tweak
db77317
tweaks
05e42d9
add back TxsToTxsData
35a7d9b
fix
1ab5de1
fix
ca48609
fix
7a81bc2
fix
ca3a6d4
fix
e36ee98
fix
931bb50
tweak
5c3c055
add back test block encode and test chunk encode unit tests
3e092dd
replace some constants with meaningful vars
558d029
rename daBatchV2 to daBatchV3
24da905
add chunk hash unit tests
aa46689
add batch encode
22c3772
add batch hash unit tests
86a2092
add batch data hash & json marshal unit tests
99231ac
add calldata size unit tests
c62b2d0
add commit gas estimation
7df1b27
add BatchSizeAndBlobSizeEstimation unit tests
f3cb3a2
add L1MessagePopped unit tests
4709903
add BlobEncodingAndHashing unit tests
ec82682
add blob data proof unit tests
d69f8cc
add TestDecodeBitmap
79ee6f7
add BlobCompressDecompress unit tests
d9c8119
tweaks and bug fixes
386a24e
fix goimport
5135ec3
add StandardTestCases
87e3f15
edge cases
6eb38e5
fixes
8432d41
address ai's comments
54ddf8d
address ai's comments
c89d7ae
address ai's comments
5aa90e8
address comments
901e082
address ai's comment
1eea8ce
remove some constants
1452109
address comments
43824ff
add more logs
886365d
address comments
4f78d1a
address comments
ef5f1a6
address comments
3faa778
address comments
1e07a66
add simple and nil functions unit tests
24eb594
add uncompressed case unit tests of DecodeTxsFromBlob
4b5b636
add interface unit tests
e18a147
add codecv2 & codecv3 CompressedDataCompatibilityCheck unit tests
42af292
remove mock flag
e6cfa7d
add JSONFromBytes unit tests
102d4a3
add codecv4 CompressedDataCompatibilityCheck unit tests
715e673
add NewDABatchFromBytes unit tests
60b9362
fix golint
0e831aa
tweaks
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 hidden or 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
This file contains hidden or 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,44 @@ | ||
| package encoding | ||
|
|
||
| import ( | ||
| "encoding/hex" | ||
| "math/big" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestDecodeBitmap(t *testing.T) { | ||
| bitmapHex := "0000000000000000000000000000000000000000000000000000001ffffffbff" | ||
| skippedL1MessageBitmap, err := hex.DecodeString(bitmapHex) | ||
| assert.NoError(t, err) | ||
|
|
||
| decodedBitmap, err := decodeBitmap(skippedL1MessageBitmap, 42) | ||
| assert.NoError(t, err) | ||
|
|
||
| isL1MessageSkipped := func(skippedBitmap []*big.Int, index uint64) bool { | ||
| if index >= uint64(len(skippedBitmap))*256 { | ||
| return false | ||
| } | ||
| quo := index / 256 | ||
| rem := index % 256 | ||
| return skippedBitmap[quo].Bit(int(rem)) == 1 | ||
| } | ||
|
|
||
| assert.True(t, isL1MessageSkipped(decodedBitmap, 0)) | ||
| assert.True(t, isL1MessageSkipped(decodedBitmap, 9)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 10)) | ||
| assert.True(t, isL1MessageSkipped(decodedBitmap, 11)) | ||
| assert.True(t, isL1MessageSkipped(decodedBitmap, 36)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 37)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 38)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 39)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 40)) | ||
| assert.False(t, isL1MessageSkipped(decodedBitmap, 41)) | ||
|
|
||
| _, err = decodeBitmap([]byte{0x00}, 8) | ||
| assert.Error(t, err) | ||
|
|
||
| _, err = decodeBitmap([]byte{0x00, 0x00, 0x00, 0x00}, 33) | ||
| assert.Error(t, err) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.