Skip to content
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

feat(blockManager): refactor and use state as single source of truth for height #847

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e36a9a5
removed pending block as submit to SL retries forever
mtsitrin May 5, 2024
0d4c641
removed BlockBatchSize and fix UT
mtsitrin May 5, 2024
5803cda
moved accumulated count to produce to be mutex protected
mtsitrin May 6, 2024
aef3bc4
refactored error handling
mtsitrin May 6, 2024
1e766ab
removed healthEvents from layers. set by manager on submission skew
mtsitrin May 6, 2024
8c4df90
cleanup
mtsitrin May 6, 2024
f3592e5
fixed defaults
mtsitrin May 6, 2024
6973282
fix UT
mtsitrin May 6, 2024
81baf80
changed accumaletd counter to be atomic
mtsitrin May 6, 2024
24d8b85
fixed UT
mtsitrin May 6, 2024
6c1741a
spelling, typo, format
danwt May 7, 2024
b1c0131
spelling
danwt May 7, 2024
9364c7c
feat: block progress to support ibc should be managed by produceloop …
mtsitrin May 8, 2024
9f76e0b
refactored the signaling
mtsitrin May 8, 2024
c7ffbf1
added ctx support for blocking signals
mtsitrin May 8, 2024
a501fa2
cleanup. comments
mtsitrin May 8, 2024
72a8893
moved indexers to own package
mtsitrin May 9, 2024
9815da3
renamed state and some struct fields
mtsitrin May 9, 2024
5c7c454
moved store back to store package
mtsitrin May 9, 2024
f53ddc4
moving height related managment to be based on State
mtsitrin May 9, 2024
8402076
fixed store pruning
mtsitrin May 9, 2024
90031e7
updated block manager to use state. rpc needs fix
mtsitrin May 9, 2024
d2be2ce
cleanup
mtsitrin May 9, 2024
a095024
Merge branch 'main' into mtsitrin/634-refactor-use-state-as-single-so…
mtsitrin May 12, 2024
d9698f8
simplified commit
mtsitrin May 12, 2024
051a4e7
moved gossip methods to gossip.go
mtsitrin May 12, 2024
cecf106
reverted executer key
mtsitrin May 12, 2024
b896eaa
fixed publishEvents
mtsitrin May 12, 2024
bb66c2c
removed unused fields. saving state post commit
mtsitrin May 12, 2024
efcf193
removed unused params. cleaned the state flow
mtsitrin May 12, 2024
3992f2a
fixed LastBlockHeight to be atomic
mtsitrin May 13, 2024
5b3cda0
avoid copying state and pass by reference
mtsitrin May 13, 2024
953a9b8
fixed PR comments
mtsitrin May 15, 2024
576325e
simplified genesis check on produce block
mtsitrin May 15, 2024
403ec9e
Merge branch 'main' into mtsitrin/634-refactor-use-state-as-single-so…
mtsitrin May 15, 2024
31c8906
pr comments
mtsitrin May 15, 2024
5ab2f15
Merge branch 'main' into mtsitrin/634-refactor-use-state-as-single-so…
mtsitrin May 15, 2024
74bfba0
linter
mtsitrin May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
linter
  • Loading branch information
mtsitrin committed May 15, 2024
commit 74bfba0fe0e01491d210498953f7d8bc32013cab
4 changes: 2 additions & 2 deletions block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ func TestProducePendingBlock(t *testing.T) {
require.NoError(t, err)
// Validate state is updated with the block that was saved in the store

//TODO: fix this test
//hacky way to validate the block was indeed contain txs
// TODO: fix this test
// hacky way to validate the block was indeed contain txs
assert.NotEqual(t, manager.State.LastResultsHash, testutil.GetEmptyLastResultsHash())
}

Expand Down
4 changes: 2 additions & 2 deletions block/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (m *Manager) produceBlock(allowEmpty bool) (*types.Block, *types.Commit, er
newHeight := m.State.NextHeight()
lastHeaderHash, lastCommit, err := loadPrevBlock(m.Store, newHeight-1)
if err != nil {
if !m.State.IsGenesis() { //allow prevBlock not to be found only on genesis
if !m.State.IsGenesis() { // allow prevBlock not to be found only on genesis
return nil, nil, fmt.Errorf("load prev block: %w: %w", err, ErrNonRecoverable)
}
lastHeaderHash = [32]byte{}
Expand Down Expand Up @@ -186,7 +186,7 @@ func (m *Manager) createTMSignature(block *types.Block, proposerAddress []byte,
}
v := vote.ToProto()
// convert libp2p key to tm key
//TODO: move to types
// TODO: move to types
raw_key, _ := m.ProposerKey.Raw()
tmprivkey := tmed25519.PrivKey(raw_key)
tmprivkey.PubKey().Bytes()
Expand Down
2 changes: 1 addition & 1 deletion block/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (e *Executor) UpdateStateAfterCommit(s *types.State, resp *tmstate.ABCIResp
copy(s.AppHash[:], appHash[:])
copy(s.LastResultsHash[:], tmtypes.NewResults(resp.DeliverTxs).Hash())

//TODO: load consensus params from endblock?
// TODO: load consensus params from endblock?

s.Validators = s.NextValidators.Copy()
s.NextValidators = valSet.Copy()
Expand Down
2 changes: 1 addition & 1 deletion indexers/txindex/indexer_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (is *IndexerService) OnStart() error {
go func() {
for {
msg := <-blockHeadersSub.Out()
eventDataHeader := msg.Data().(types.EventDataNewBlockHeader)
eventDataHeader, _ := msg.Data().(types.EventDataNewBlockHeader)
height := eventDataHeader.Header.Height
batch := NewBatch(eventDataHeader.NumTxs)

Expand Down
2 changes: 1 addition & 1 deletion mempool/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *LRUTxCache) Push(tx types.Tx) bool {
if c.list.Len() >= c.size {
front := c.list.Front()
if front != nil {
frontKey := front.Value.(types.TxKey)
frontKey, _ := front.Value.(types.TxKey)
delete(c.cacheMap, frontKey)
c.list.Remove(front)
}
Expand Down
2 changes: 1 addition & 1 deletion mempool/v1/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (txmp *TxMempool) CheckTx(tx types.Tx, cb func(*abci.Response), txInfo memp
if !txmp.cache.Push(tx) {
// If the cached transaction is also in the pool, record its sender.
if elt, ok := txmp.txByKey[txKey]; ok {
w := elt.Value.(*WrappedTx)
w, _ := elt.Value.(*WrappedTx)
w.SetPeer(txInfo.SenderID)
}
return 0, mempool.ErrTxInCache
Expand Down
2 changes: 1 addition & 1 deletion rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (c *Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64)
const limit int64 = 20

minHeight, maxHeight, err := filterMinMax(
0, //FIXME: we might be pruned
0, // FIXME: we might be pruned
int64(c.node.GetBlockManagerHeight()),
minHeight,
maxHeight,
Expand Down
3 changes: 1 addition & 2 deletions store/pruning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func TestStorePruning(t *testing.T) {
to uint64
shouldError bool
}{

{"blocks with pruning", []*types.Block{
testutil.GetRandomBlock(1, 0),
testutil.GetRandomBlock(2, 0),
Expand Down Expand Up @@ -79,7 +78,7 @@ func TestStorePruning(t *testing.T) {

// Validate only blocks in the range are pruned
for k := range savedHeights {
if k >= c.from && k < c.to { //k < c.to is the exclusion test
if k >= c.from && k < c.to { // k < c.to is the exclusion test
_, err := bstore.LoadBlock(k)
assert.Error(err, "Block at height %d should be pruned", k)

Expand Down
2 changes: 1 addition & 1 deletion types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewStateFromGenesis(genDoc *types.GenesisDoc) (*State, error) {
// but leaves the Consensus.App version blank.
// The Consensus.App version will be set during the Handshake, once
// we hear from the app what protocol version it is running.
var InitStateVersion = tmstate.Version{
InitStateVersion := tmstate.Version{
Consensus: tmversion.Consensus{
Block: version.BlockProtocol,
App: 0,
Expand Down
Loading