-
Notifications
You must be signed in to change notification settings - Fork 115
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
Generalize expiry based de-duplication #1782
Conversation
chain/accepter.go
Outdated
@@ -7,17 +7,18 @@ import ( | |||
"context" | |||
|
|||
"github.com/ava-labs/avalanchego/trace" | |||
"github.com/ava-labs/hypersdk/internal/validity_window" |
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.
nit: can we make this validitywindow
and avoid underscores?
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.
done
chain/processor.go
Outdated
@@ -41,13 +42,13 @@ func NewExecutionBlock(block *StatelessBlock) *ExecutionBlock { | |||
} | |||
} | |||
|
|||
func (b *ExecutionBlock) initTxs() error { | |||
if b.txsSet.Len() == len(b.Txs) { | |||
func (b *ExecutionBlock) InitTxs() 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.
Can we get rid of this extra call by loading the txs set on parse, so that we don't need to push this into the internal validity window package?
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.
done
|
||
var ErrDuplicateTx = errors.New("duplicate transaction") | ||
|
||
type ExecutionBlock[TxnTypePtr emap.Item] interface { |
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.
nit: Container instead of TxnTypePtr
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.
Same comment to the other function names that refer to Tx
. We should also use Tx
rather than txn as shorthand for txs since we've used that nomenclature throughout the repo.
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.
done
Timestamp() int64 | ||
Height() uint64 | ||
Txs() []TxnTypePtr | ||
InitTxs() 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.
Can we remove the need for InitTxs
?
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.
done
chain/syncer.go
Outdated
chainIndex validity_window.ChainIndex[*Transaction] | ||
timeValidityWindow validity_window.TimeValidityWindow[*Transaction] |
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.
Can we move the syncer into the validity window package as well since it is required to find the point where we can safely start to apply de-duplication?
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.
done
chain/transaction.go
Outdated
// create a local name for the imported interface. | ||
type ValidityWindow validitywindow.TimeValidityWindow[*Transaction] |
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.
Can we move the type alias to where it's used?
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.
done
"github.com/ava-labs/hypersdk/internal/emap" | ||
) | ||
|
||
type GetValidityWindowFunc func(int64) int64 |
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.
What does this function do?
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.
comment updated.
…/hypersdk into tsachi/refactor_validity_window
internal/validitywindow/syncer.go
Outdated
seenValidityWindow = lastAcceptedBlock.Timestamp()-parent.Timestamp() > s.getValidityWindow(lastAcceptedBlock.Timestamp()) | ||
if seenValidityWindow { | ||
break | ||
} |
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.
Can we calculate the validity window for the accepted block once rather than in each iteration of this loop to improve readability?
"github.com/ava-labs/hypersdk/internal/emap" | ||
) | ||
|
||
var ErrDuplicateTx = errors.New("duplicate transaction") |
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.
nit: rename to ErrDuplicateContainer
and update error string to "duplicate container"
v.lock.Lock() | ||
defer v.lock.Unlock() | ||
|
||
lastAcceptedBlkHeight := v.chainIndex.LastAcceptedBlockHeight() |
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.
(not needed for this PR because it's an existing bug) note: we should move tracking the last accepted block internal to the validity window (#1780)
I introduced a subtle bug here where we need to trace back not to the last accepted block, but up to the last block where v.seen
has been updated. This is much simpler if we track the last accepted block by updating it and v.seen
during Accept
.
|
||
type ChainIndex[Container emap.Item] interface { | ||
GetExecutionBlock(ctx context.Context, blkID ids.ID) (ExecutionBlock[Container], error) | ||
LastAcceptedBlockHeight() uint64 |
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.
we should be able to remove this in favor of tracking the last accepted height from within the validity window
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.
done.
chain/stateless_block.go
Outdated
|
||
// authCounts can be used by batch signature verification | ||
// to preallocate memory | ||
authCounts map[uint8]int | ||
txsSet set.Set[ids.ID] |
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.
Could we keep this in ExecutionBlock
so that we only populate it as needed (ie for blocks that we may verify)?
If we put it here, then every type that uses this type will have to populate these fields.
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.
done
What ?