Skip to content

Commit d68e3f7

Browse files
committed
rebase conflicts
1 parent cc5f26a commit d68e3f7

File tree

4 files changed

+16
-29
lines changed

4 files changed

+16
-29
lines changed

simplex/block.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ type blockTracker struct {
155155

156156
// handles block acceptance and rejection of inner blocks
157157
tree tree.Tree
158-
159-
// digest of the last block that was indexed
160-
lastIndexed simplex.Digest
161158
}
162159

163160
func newBlockTracker(latestBlock *Block) *blockTracker {
@@ -166,7 +163,6 @@ func newBlockTracker(latestBlock *Block) *blockTracker {
166163
simplexDigestsToBlock: map[simplex.Digest]*Block{
167164
latestBlock.digest: latestBlock,
168165
},
169-
lastIndexed: latestBlock.digest,
170166
}
171167
}
172168

@@ -218,11 +214,5 @@ func (bt *blockTracker) indexBlock(ctx context.Context, digest simplex.Digest) e
218214
}
219215

220216
// notify the VM that we are accepting this block, and reject all competing blocks
221-
err := bt.tree.Accept(ctx, bd.vmBlock)
222-
if err != nil {
223-
return fmt.Errorf("failed to accept block: %w", err)
224-
}
225-
226-
bt.lastIndexed = digest
227-
return nil
217+
return bt.tree.Accept(ctx, bd.vmBlock)
228218
}

simplex/block_builder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func (b *BlockBuilder) BuildBlock(ctx context.Context, metadata simplex.Protocol
3535
default:
3636
err := b.incomingBlock(ctx)
3737
if err != nil {
38-
b.log.Debug("Error waiting for incoming block:", zap.Error(err))
38+
b.log.Debug("Error waiting for incoming block", zap.Error(err))
3939
curWait = backoff(ctx, curWait, maxBackoff)
4040
continue
4141
}
4242
vmBlock, err := b.vm.BuildBlock(ctx)
4343
if err != nil {
44-
b.log.Info("Error building block:", zap.Error(err))
44+
b.log.Info("Error building block", zap.Error(err))
4545
curWait = backoff(ctx, curWait, maxBackoff)
4646
continue
4747
}
@@ -52,7 +52,7 @@ func (b *BlockBuilder) BuildBlock(ctx context.Context, metadata simplex.Protocol
5252
curWait = 10 * time.Millisecond // Reset backoff after a successful block build
5353
verifiedBlock, err := simplexBlock.Verify(ctx)
5454
if err != nil {
55-
b.log.Info("Error verifying block we built ourselves: %s", zap.Error(err))
55+
b.log.Warn("Error verifying block we built ourselves", zap.Error(err))
5656
curWait = backoff(ctx, curWait, maxBackoff)
5757
continue
5858
}
@@ -67,7 +67,7 @@ func (b *BlockBuilder) BuildBlock(ctx context.Context, metadata simplex.Protocol
6767
func (b *BlockBuilder) IncomingBlock(ctx context.Context) {
6868
err := b.incomingBlock(ctx)
6969
if err != nil {
70-
b.log.Error("Error waiting for incoming block:", zap.Error(err))
70+
b.log.Error("Error waiting for incoming block", zap.Error(err))
7171
}
7272
}
7373

simplex/storage.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,10 @@ func (s *Storage) Retrieve(seq uint64) (simplex.VerifiedBlock, simplex.Finalizat
123123
return nil, simplex.Finalization{}, err
124124
}
125125

126-
vb := &Block{vmBlock: block, metadata: finalization.Finalization.ProtocolMetadata, blockTracker: s.blockTracker}
127-
bytes, err := vb.Bytes()
126+
vb, err := newBlock(finalization.Finalization.ProtocolMetadata, block, s.blockTracker)
128127
if err != nil {
129-
s.log.Error("Failed to serialize block", zap.Error(err))
130128
return nil, simplex.Finalization{}, err
131129
}
132-
vb.digest = computeDigest(bytes)
133130

134131
return vb, finalization, nil
135132
}

simplex/storage_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestStorageNew(t *testing.T) {
7272
}
7373

7474
func TestStorageRetrieve(t *testing.T) {
75-
genesis := newBlock(t, newBlockConfig{})
75+
genesis := newTestBlock(t, newBlockConfig{})
7676
genesisBytes, err := genesis.Bytes()
7777
require.NoError(t, err)
7878

@@ -131,9 +131,9 @@ func TestStorageRetrieve(t *testing.T) {
131131

132132
func TestStorageIndexFails(t *testing.T) {
133133
ctx := context.Background()
134-
genesis := newBlock(t, newBlockConfig{})
135-
child1 := newBlock(t, newBlockConfig{prev: genesis})
136-
child2 := newBlock(t, newBlockConfig{prev: child1})
134+
genesis := newTestBlock(t, newBlockConfig{})
135+
child1 := newTestBlock(t, newBlockConfig{prev: genesis})
136+
child2 := newTestBlock(t, newBlockConfig{prev: child1})
137137

138138
configs := newNetworkConfigs(t, 4)
139139
configs[0].VM = genesis.vmBlock.(*wrappedBlock).vm
@@ -216,10 +216,10 @@ func TestStorageIndexFails(t *testing.T) {
216216
// previous digest of the block being indexed.
217217
func TestIndexMismatchedChild(t *testing.T) {
218218
ctx := context.Background()
219-
genesis := newBlock(t, newBlockConfig{})
220-
child1 := newBlock(t, newBlockConfig{prev: genesis})
221-
child1Sibling := newBlock(t, newBlockConfig{prev: genesis})
222-
child2Nephew := newBlock(t, newBlockConfig{prev: child1Sibling})
219+
genesis := newTestBlock(t, newBlockConfig{})
220+
child1 := newTestBlock(t, newBlockConfig{prev: genesis})
221+
child1Sibling := newTestBlock(t, newBlockConfig{prev: genesis})
222+
child2Nephew := newTestBlock(t, newBlockConfig{prev: child1Sibling})
223223

224224
configs := newNetworkConfigs(t, 4)
225225
configs[0].VM = genesis.vmBlock.(*wrappedBlock).vm
@@ -251,7 +251,7 @@ func TestIndexMismatchedChild(t *testing.T) {
251251
// TestStorageIndexSuccess indexes 10 blocks and verifies that they can be retrieved.
252252
func TestStorageIndexSuccess(t *testing.T) {
253253
ctx := context.Background()
254-
genesis := newBlock(t, newBlockConfig{})
254+
genesis := newTestBlock(t, newBlockConfig{})
255255
configs := newNetworkConfigs(t, 4)
256256

257257
_, verifier := NewBLSAuth(configs[0])
@@ -270,7 +270,7 @@ func TestStorageIndexSuccess(t *testing.T) {
270270

271271
prev := genesis
272272
for i := 0; i < numBlocks; i++ {
273-
child := newBlock(t, newBlockConfig{prev: prev})
273+
child := newTestBlock(t, newBlockConfig{prev: prev})
274274
_, err := child.Verify(ctx)
275275
require.NoError(t, err)
276276

0 commit comments

Comments
 (0)