Skip to content

Commit

Permalink
Resolve discrepany (cosmos#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manav-Aggarwal authored Dec 5, 2022
1 parent dcb2092 commit 7ced28a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ func (m *Manager) publishBlock(ctx context.Context) error {

// Apply the block but DONT commit
newState, responses, err := m.executor.ApplyBlock(ctx, m.lastState, block)

if err != nil {
return err
}

// SaveBlock commits the DB tx
err = m.store.SaveBlock(block, commit)
if err != nil {
return err
}
Expand Down
9 changes: 3 additions & 6 deletions node/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package node
import (
"context"
"crypto/rand"
"fmt"
mrand "math/rand"
"strconv"
"strings"
Expand Down Expand Up @@ -127,9 +128,7 @@ func TestTxGossipingAndAggregation(t *testing.T) {
require.NoError(err)
nodeBlock, err := nodes[i].Store.LoadBlock(h)
require.NoError(err)
// Only Intermediate state roots set by block aggregator are relevant, removed for sake of comparison
nodeBlock.Data.IntermediateStateRoots.RawRootsList = nil
assert.Equal(aggBlock, nodeBlock)
assert.Equal(aggBlock, nodeBlock, fmt.Sprintf("height: %d", h))
}
}
}
Expand Down Expand Up @@ -186,8 +185,6 @@ func TestFraudProofTrigger(t *testing.T) {
require.NoError(err)
aggBlock, err := nodes[0].Store.LoadBlock(h)
require.NoError(err)
// Only Intermediate state roots set by block aggregator are relevant, removed for sake of comparison
nodeBlock.Data.IntermediateStateRoots.RawRootsList = nil
assert.Equal(aggBlock, nodeBlock)
}
}
Expand All @@ -198,7 +195,7 @@ func createAndStartNodes(clientNodes int, isMalicious bool, t *testing.T) ([]*No
var wg sync.WaitGroup
aggCtx, aggCancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(context.Background())
nodes, apps := createNodes(aggCtx, ctx, clientNodes+1, true, &wg, t)
nodes, apps := createNodes(aggCtx, ctx, clientNodes+1, isMalicious, &wg, t)
startNodes(nodes, &wg, t)
aggCancel()
time.Sleep(100 * time.Millisecond)
Expand Down

0 comments on commit 7ced28a

Please sign in to comment.