-
Notifications
You must be signed in to change notification settings - Fork 126
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
Author a sibling block in case best block's slot is same as current slot #2827
Author a sibling block in case best block's slot is same as current slot #2827
Conversation
the current slot, we should author a new block as child of best block's parent. This would create forks in the chain which would get resolved eventually.
that we are claiming at the moment
- Split out (CGO related) helper functions from `imports.go` to `lib/runtime/wasmer/helpers.go` - Move pointer size helper functions to `lib/runtime/wasmer/helpers.go` - Change `toWasmMemorySized` to NOT take a size argument (unneeded) - Clarify all comments for helper functions - Update all error wrappings - Review variable names - Use `ptr` instead of `out` for 32 bit pointers - Use `pointerSize` instead of `span` for 64 bit pointers size - Name return values - Other minor renamings such as `res` to `result`, `enc` to `encodedResult` - Optimizations: - `storageAppend`: use slice capacity allocation, `copy` and remove unneeded `append`s - `toKillStorageResultEnum`: use `copy` instead of `append` - `toWasmMemoryOptional`: remove unneeded variable copy
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## development #2827 +/- ##
============================================
Coverage 63.37% 63.38%
============================================
Files 217 217
Lines 27062 27088 +26
============================================
+ Hits 17150 17169 +19
- Misses 8348 8353 +5
- Partials 1564 1566 +2 |
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
This is a really good find. I went through that piece of code and tried to figure out what it does. It appears to me that we should report equivocations. I have created an issue for that #2853. Take a look at it, let me know your thoughts. |
…inSafe/gossamer into kishan/fix/slot-number-must-increase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small unneeded comment
if err != nil { | ||
return fmt.Errorf("could not get header for hash %s: %w", parentHeader.ParentHash, err) | ||
} | ||
if newParentHeader == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh should we create an issue for that? Sounds kinda strange we can't find the parent header right?
currentSlot := Slot{ | ||
start: time.Now(), | ||
duration: b.constants.slotDuration, | ||
number: slotNum, | ||
} | ||
|
||
parent, err := b.getParentForBlockAuthoring(slotNum) | ||
if err != nil { | ||
return fmt.Errorf("could not get parent for claiming slot %d: %w", slotNum, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the slotNum
argument should be bundled in the error context by getParentForBlockAuthoring
, not here. Also shouldn't it be for block authoring
instead of for claiming slot
?
return fmt.Errorf("could not get parent for claiming slot %d: %w", slotNum, err) | |
return fmt.Errorf("could not get parent for block authoring: %w", err) |
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// NewTestService creates a new test core service | ||
func NewTestService(t *testing.T, cfg *core.Config) *core.Service { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is used in only one place in the babe package, please remove all the nil checks below and inject a fully configured cfg
to NewTestService
. All these nil checks are just confusing and prone to error/hard to debug. You might be able to remove unused config fields too eventually.
authorityIndex uint32, | ||
preRuntimeDigest *types.PreRuntimeDigest, | ||
) error { | ||
func (b *Service) getParentForBlockAuthoring(slotNum uint64) (*types.Header, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a unit test for this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets tested TestService_HandleSlotWithSameSlot
and TestService_HandleSlotWithLaggingSlot
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are integration tests, not unit tests. We want a unit test because:
- it should cover all code paths (unlike integ tests)
- it should be fast
- it's easier to spot a bug with a unit test than through an integ test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like new code added should be unit tested, but up to you if you feel it's not necessary. I wasn't referring to unit testing handleSlot
, that's indeed out of scope.
Co-authored-by: Eclésio Junior <eclesiomelo.1@gmail.com>
…inSafe/gossamer into kishan/fix/slot-number-must-increase
🎉 This PR is included in version 0.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Changes
Copy of #2726 with the merge fix
_test.go
which were not actually tests, but just things that were getting used in test files. I had to remove_test
from them in order to use that helper code to be used in other packages.createTestService
in babe tests had some un-necessary conditions. Removed them. It also helps me with the test that I have written.Tests
go test -tags integration github.com/ChainSafe/gossamer
Issues
Primary Reviewer
@timwu20