From ca5fe231fe5124fd3adf6beddc4110c37733df87 Mon Sep 17 00:00:00 2001 From: Manav Aggarwal Date: Fri, 2 Dec 2022 15:20:24 -0500 Subject: [PATCH] Resolve discrepany --- block/manager.go | 7 +++++++ node/integration_test.go | 9 +++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/block/manager.go b/block/manager.go index da0a3d5475..f339fcbb9c 100644 --- a/block/manager.go +++ b/block/manager.go @@ -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 } diff --git a/node/integration_test.go b/node/integration_test.go index 7144f485de..34fa583047 100644 --- a/node/integration_test.go +++ b/node/integration_test.go @@ -3,6 +3,7 @@ package node import ( "context" "crypto/rand" + "fmt" mrand "math/rand" "strconv" "strings" @@ -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)) } } } @@ -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) } } @@ -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)