-
Notifications
You must be signed in to change notification settings - Fork 204
P2P sync update for 0.13.2 hashing scheme #2033
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
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
962edf8
Make adaptSignature private
AnkushinDaniil ee1fea2
Rename from receipt_pkg_test.go receipt_test.go
AnkushinDaniil b4bc4c6
Add TestAdaptReceipt
AnkushinDaniil c3b6842
Move version parcing to ParseBlockVersion
AnkushinDaniil e3cc599
Add TestReceiptCommon
AnkushinDaniil b3eaf4c
Update comments
AnkushinDaniil f115ea6
Rename testcase
AnkushinDaniil 9737488
Move wg closer to usage
AnkushinDaniil 1a91bc3
Remove ParseBlockVersion
AnkushinDaniil 8f8153d
Update Post0132Hash
AnkushinDaniil ccba253
Update adaptAndSanityCheckBlock
AnkushinDaniil d9edf3d
Add isgomock field
AnkushinDaniil b394e77
Regenerate mocks
AnkushinDaniil 8c6a82e
Update onHeadersRequest
AnkushinDaniil c775fe4
Fix rebase issues
AnkushinDaniil 7fe1ef2
Fix rebase issues
AnkushinDaniil 1be0368
Add hashstorage
AnkushinDaniil 3cb47b4
Make Post0132Hash public
AnkushinDaniil efedf8f
Remove unnecessary line
AnkushinDaniil 6291d30
Revert test name change
AnkushinDaniil 1800c6f
Format
AnkushinDaniil 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
AnkushinDaniil marked this conversation as resolved.
Show resolved
Hide resolved
|
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,36 @@ | ||
package core2p2p | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/NethermindEth/juno/core" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReceiptCommon(t *testing.T) { | ||
t.Run("successful", func(t *testing.T) { | ||
receipt := &core.TransactionReceipt{ | ||
Reverted: false, | ||
} | ||
r := receiptCommon(receipt) | ||
// if RevertReason is nil then receipt considered as non reverted | ||
AnkushinDaniil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert.Nil(t, r.RevertReason) | ||
}) | ||
t.Run("reverted", func(t *testing.T) { | ||
receipts := []*core.TransactionReceipt{ | ||
{ | ||
Reverted: true, | ||
RevertReason: "Reason", | ||
}, | ||
{ | ||
Reverted: true, | ||
RevertReason: "", | ||
}, | ||
} | ||
|
||
for _, receipt := range receipts { | ||
r := receiptCommon(receipt) | ||
assert.Equal(t, &receipt.RevertReason, r.RevertReason) | ||
} | ||
}) | ||
} |
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,47 @@ | ||
package p2p2core_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/NethermindEth/juno/adapters/p2p2core" | ||
"github.com/NethermindEth/juno/p2p/gen" | ||
"github.com/NethermindEth/juno/utils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAdaptReceipt(t *testing.T) { | ||
t.Run("successful", func(t *testing.T) { | ||
hash := utils.HexToFelt(t, "0xCAFEBABE") | ||
receipt := &gen.Receipt{ | ||
Type: &gen.Receipt_L1Handler_{ | ||
L1Handler: &gen.Receipt_L1Handler{ | ||
Common: &gen.Receipt_Common{ | ||
RevertReason: nil, | ||
}, | ||
}, | ||
}, | ||
} | ||
r := p2p2core.AdaptReceipt(receipt, hash) | ||
assert.False(t, r.Reverted) | ||
assert.Equal(t, "", r.RevertReason) | ||
}) | ||
t.Run("reverted", func(t *testing.T) { | ||
reasons := []string{"reason", ""} | ||
|
||
for _, reason := range reasons { | ||
hash := utils.HexToFelt(t, "0xCAFEDEAD") | ||
receipt := &gen.Receipt{ | ||
Type: &gen.Receipt_L1Handler_{ | ||
L1Handler: &gen.Receipt_L1Handler{ | ||
Common: &gen.Receipt_Common{ | ||
RevertReason: utils.Ptr(reason), | ||
}, | ||
}, | ||
}, | ||
} | ||
r := p2p2core.AdaptReceipt(receipt, hash) | ||
assert.True(t, r.Reverted) | ||
assert.Equal(t, receipt.GetL1Handler().GetCommon().GetRevertReason(), r.RevertReason) | ||
} | ||
}) | ||
} |
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
File renamed without changes.
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,27 @@ | ||
package core | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/Masterminds/semver/v3" | ||
) | ||
|
||
var ( | ||
Ver0_13_2 = semver.MustParse("0.13.2") | ||
Ver0_13_4 = semver.MustParse("0.13.4") | ||
) | ||
|
||
// ParseBlockVersion computes the block version, defaulting to "0.0.0" for empty strings | ||
func ParseBlockVersion(protocolVersion string) (*semver.Version, error) { | ||
if protocolVersion == "" { | ||
return semver.NewVersion("0.0.0") | ||
} | ||
|
||
sep := "." | ||
digits := strings.Split(protocolVersion, sep) | ||
// pad with 3 zeros in case version has less than 3 digits | ||
digits = append(digits, []string{"0", "0", "0"}...) | ||
|
||
// get first 3 digits only | ||
return semver.NewVersion(strings.Join(digits[:3], sep)) | ||
} |
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.