-
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
colinlyguo 62758c8
move append conditionalEncode flag after validity check
colinlyguo 6901956
update da-codec
colinlyguo e4bf12e
align naming
colinlyguo 030349d
add ConvertBlobToBlobBytes utility functions
colinlyguo ed4de9e
kept blob bytes
colinlyguo c6af3bb
rename enableEncode to enableCompress
colinlyguo a5691d4
refactor: move some common functions to encoding (#24)
colinlyguo 9532963
move symbol replace script to zstd folder
colinlyguo 990bdb3
refactor: move some util functions to public package
colinlyguo 6b86866
fix CI
colinlyguo 3ad692a
add interfaces of codec
colinlyguo a5c6430
add SetCompression
colinlyguo 43f56e6
move interface to encoding
colinlyguo cd280de
refactor
colinlyguo 879bb98
add dablock.go
colinlyguo 77aafd4
add dachunk.go
colinlyguo 6ee5c19
add dabatch.go
colinlyguo 79422a2
move computeBatchDataHash to codecv
colinlyguo 296880e
fix
colinlyguo c038850
add DABatchBase
colinlyguo 4499e2c
add GetCodecVersion
colinlyguo 8e763dd
add BlobVersionedHashes
colinlyguo 98d5635
rename encoding.go to interfaces.go
colinlyguo bdb98f8
add NewDABatchWithExpectedBlobVersionedHashes
colinlyguo f3f0fbd
Merge branch 'main' into refactor-move-some-util-functions-to-public-…
colinlyguo 08d60a3
tweak
colinlyguo 2d425d8
fix a bug
colinlyguo c1e4a0d
add more logs
colinlyguo e5df846
add DecodeDAChunks
colinlyguo ecaca71
add BlockRange interface
colinlyguo 484fa59
fix
colinlyguo f1fe4c8
add version check
colinlyguo 97711e2
add Version
colinlyguo 2a63797
remove DABatchBase
colinlyguo 87c4537
add DABlock
colinlyguo 2ac7825
fixes
colinlyguo 8a6c35f
fix
colinlyguo 83f6b62
add CodecFromVersion and CodecFromConfig
colinlyguo c4a2495
remove GetCodecVersion
colinlyguo 10af8e7
fix typos
colinlyguo 1594e0f
make Block fields internal
colinlyguo 1f9facd
make chunk fields internal
colinlyguo 451eb68
make batch fields internal and add some tweaks
colinlyguo 955f375
add JSONFromBytes
colinlyguo f73c63e
fix a typo
colinlyguo cf9f084
use register mode
colinlyguo 5ef6c5f
Merge branch 'main' into refactor-move-some-util-functions-to-public-…
colinlyguo 7eb1dc0
fix CI
colinlyguo 91ac897
remove register mode
colinlyguo e6c8965
add common functions
colinlyguo ba853e3
add EstimateBlockL1CommitCalldataSize
colinlyguo aca0bef
add dabatch interfaces
colinlyguo 95d2bc7
update interface implementations
colinlyguo 75812c4
add data hash
colinlyguo 78588e4
fix codecv3 & codecv4 estimate gas
colinlyguo 45548e1
fix
colinlyguo 4469219
fix bugs
colinlyguo 6934f3d
tweak
colinlyguo 0079225
add CheckChunkCompressedDataCompatibility & CheckBatchCompressedDataC…
colinlyguo 3f774d2
fix
colinlyguo 669b454
add BlobDataProofForPointEvaluation
colinlyguo 09127a5
add nil check in NewDAChunk
colinlyguo 1c519d6
make some util functions internal
colinlyguo d2350ff
remove GetMaxChunksPerBatch
colinlyguo b885af8
fix CI
colinlyguo 986850d
change receiver mark from o to d
colinlyguo e222406
remove SetCompression
colinlyguo ef5ea6e
fix
colinlyguo 9d9fd89
add GetChunkEnableCompression & GetBatchEnableCompression
colinlyguo df76a9d
fix
colinlyguo 6e28644
update l2geth dependency
colinlyguo 233b006
make types internal
colinlyguo 8dbf796
embed codecv0 <- codecv1 <- codecv2 <- codecv3 <- codecv4
colinlyguo 7891503
remove dablock.go dachunk.go dabatch.go
colinlyguo 2703f22
trigger ci
colinlyguo 443f126
tweak
colinlyguo db77317
tweaks
colinlyguo 05e42d9
add back TxsToTxsData
colinlyguo 35a7d9b
fix
colinlyguo 1ab5de1
fix
colinlyguo ca48609
fix
colinlyguo 7a81bc2
fix
colinlyguo ca3a6d4
fix
colinlyguo e36ee98
fix
colinlyguo 931bb50
tweak
colinlyguo 5c3c055
add back test block encode and test chunk encode unit tests
colinlyguo 3e092dd
replace some constants with meaningful vars
colinlyguo 558d029
rename daBatchV2 to daBatchV3
colinlyguo 24da905
add chunk hash unit tests
colinlyguo aa46689
add batch encode
colinlyguo 22c3772
add batch hash unit tests
colinlyguo 86a2092
add batch data hash & json marshal unit tests
colinlyguo 99231ac
add calldata size unit tests
colinlyguo c62b2d0
add commit gas estimation
colinlyguo 7df1b27
add BatchSizeAndBlobSizeEstimation unit tests
colinlyguo f3cb3a2
add L1MessagePopped unit tests
colinlyguo 4709903
add BlobEncodingAndHashing unit tests
colinlyguo ec82682
add blob data proof unit tests
colinlyguo d69f8cc
add TestDecodeBitmap
colinlyguo 79ee6f7
add BlobCompressDecompress unit tests
colinlyguo d9c8119
tweaks and bug fixes
colinlyguo 386a24e
fix goimport
colinlyguo 5135ec3
add StandardTestCases
colinlyguo 87e3f15
edge cases
colinlyguo 6eb38e5
fixes
colinlyguo 8432d41
address ai's comments
colinlyguo 54ddf8d
address ai's comments
colinlyguo c89d7ae
address ai's comments
colinlyguo 5aa90e8
address comments
colinlyguo 901e082
address ai's comment
colinlyguo 1eea8ce
remove some constants
colinlyguo 1452109
address comments
colinlyguo 43824ff
add more logs
colinlyguo 886365d
address comments
colinlyguo 4f78d1a
address comments
colinlyguo ef5f1a6
address comments
colinlyguo 3faa778
address comments
colinlyguo 1e07a66
add simple and nil functions unit tests
colinlyguo 24eb594
add uncompressed case unit tests of DecodeTxsFromBlob
colinlyguo 4b5b636
add interface unit tests
colinlyguo e18a147
add codecv2 & codecv3 CompressedDataCompatibilityCheck unit tests
colinlyguo 42af292
remove mock flag
colinlyguo e6cfa7d
add JSONFromBytes unit tests
colinlyguo 102d4a3
add codecv4 CompressedDataCompatibilityCheck unit tests
colinlyguo 715e673
add NewDABatchFromBytes unit tests
colinlyguo 60b9362
fix golint
colinlyguo 0e831aa
tweaks
colinlyguo 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.