-
Notifications
You must be signed in to change notification settings - Fork 122
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
lib/babe: always use 2/3 of slot to produce block, re-add potentially valid txs to queue #1679
Changes from 17 commits
9c9acde
ba86b2b
d26488d
dc15bc1
4ea0542
829fb09
a232522
a74f872
6226fed
f044113
1f91b03
01e341a
a0cff7a
2c8644a
760c8d9
2258825
4fa0bdb
e08dacc
5dbd0f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -244,11 +244,6 @@ func (b *BlockBuilder) buildBlockExtrinsics(slot Slot) []*transaction.ValidTrans | |||||
txn := b.transactionState.Pop() | ||||||
// Transaction queue is empty. | ||||||
if txn == nil { | ||||||
return included | ||||||
} | ||||||
|
||||||
// Move to next extrinsic. | ||||||
if txn.Extrinsic == nil { | ||||||
continue | ||||||
} | ||||||
|
||||||
|
@@ -270,6 +265,21 @@ func (b *BlockBuilder) buildBlockExtrinsics(slot Slot) []*transaction.ValidTrans | |||||
if _, ok := err.(*DispatchOutcomeError); !ok { | ||||||
continue | ||||||
} | ||||||
|
||||||
// don't drop transactions that may be valid in a later block ie. | ||||||
// run out of gas for this block or have a nonce that may be valid in a later block | ||||||
var e *TransactionValidityError | ||||||
if !errors.As(err, &e) { | ||||||
continue | ||||||
} | ||||||
|
||||||
err = err.(*TransactionValidityError).msg | ||||||
if errors.Is(err, errExhaustsResources) || errors.Is(err, errInvalidTransaction) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why this is necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it just changes to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
hash, err := b.transactionState.Push(txn) | ||||||
if err != nil { | ||||||
logger.Debug("failed to re-add transaction to queue", "tx", hash, "error", err) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
logger.Debug("build block applied extrinsic", "extrinsic", extrinsic) | ||||||
|
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.
This cast is not necessary since we already change the
err
intoTransactionValidityError
on line273
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 doesn't, the above lines do this:
that doesn't cast it as a
*TransactionValidityError
afaikThere 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.
Sorry, the
errors.As
doesn't cast the variableerr
, it gets the error and transform it to type*TransactionValidityError
and sets to variable&e
, without change theerr
variable, and returns true (or false if fails the type doesn't match). So basically it is possible to usee.msg
without the cast on line276
from: https://golang.org/pkg/errors/#As
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.
okay makes sense, I updated it!