Skip to content

Commit cf8c3d6

Browse files
Merge branch 'master' into alertIfNoConnections
2 parents d1b4d92 + 6960a80 commit cf8c3d6

File tree

8 files changed

+22
-62
lines changed

8 files changed

+22
-62
lines changed

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ func getSubnetConfigsFromFlags(v *viper.Viper, subnetIDs []ids.ID) (map[ids.ID]s
10771077
return res, nil
10781078
}
10791079

1080-
// getSubnetConfigs reads SubnetConfigs to node config map
1080+
// getSubnetConfigsFromDir reads SubnetConfigs to node config map
10811081
func getSubnetConfigsFromDir(v *viper.Viper, subnetIDs []ids.ID) (map[ids.ID]subnets.Config, error) {
10821082
subnetConfigPath, err := getPathFromDirKey(v, SubnetConfigDirKey)
10831083
if err != nil {

database/corruptabledb/db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func TestIterator(t *testing.T) {
184184
// Put a key-value pair in the database.
185185
require.NoError(corruptableDB.Put([]byte{0}, []byte{1}))
186186

187-
// Mark database as corupted, if applicable
187+
// Mark database as corrupted, if applicable
188188
_ = corruptableDB.handleError(tt.databaseErrBefore)
189189

190190
// Make an iterator

tests/fixture/tmpnet/kube.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func DefaultPodFlags(networkName string, dataDir string) map[string]string {
4646
}
4747
}
4848

49-
// newNodeStatefulSet returns a statefulset for an avalanchego node.
49+
// NewNodeStatefulSet returns a statefulset for an avalanchego node.
5050
func NewNodeStatefulSet(
5151
name string,
5252
imageName string,

vms/avm/block/executor/block.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,12 @@ func (b *Block) Accept(context.Context) error {
246246
return err
247247
}
248248

249-
txChecksum, utxoChecksum := b.manager.state.Checksums()
250249
b.manager.backend.Ctx.Log.Trace(
251250
"accepted block",
252251
zap.Stringer("blkID", blkID),
253252
zap.Uint64("height", b.Height()),
254253
zap.Stringer("parentID", b.Parent()),
255-
zap.Stringer("txChecksum", txChecksum),
256-
zap.Stringer("utxoChecksum", utxoChecksum),
254+
zap.Stringer("checksum", b.manager.state.Checksum()),
257255
)
258256
return nil
259257
}

vms/avm/block/executor/block_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ func TestBlockAccept(t *testing.T) {
749749
// because we mock the call to shared memory
750750
mockManagerState.EXPECT().CommitBatch().Return(nil, nil)
751751
mockManagerState.EXPECT().Abort()
752-
mockManagerState.EXPECT().Checksums().Return(ids.Empty, ids.Empty)
752+
mockManagerState.EXPECT().Checksum().Return(ids.Empty)
753753

754754
mockSharedMemory := atomicmock.NewSharedMemory(ctrl)
755755
mockSharedMemory.EXPECT().Apply(gomock.Any(), gomock.Any()).Return(nil)

vms/avm/state/state.go

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ type State interface {
8989
// pending changes to the base database.
9090
CommitBatch() (database.Batch, error)
9191

92-
// Checksums returns the current TxChecksum and UTXOChecksum.
93-
Checksums() (txChecksum ids.ID, utxoChecksum ids.ID)
92+
// Checksum returns the current state checksum.
93+
Checksum() ids.ID
9494

9595
Close() error
9696
}
@@ -134,9 +134,6 @@ type state struct {
134134
lastAccepted, persistedLastAccepted ids.ID
135135
timestamp, persistedTimestamp time.Time
136136
singletonDB database.Database
137-
138-
trackChecksum bool
139-
txChecksum ids.ID
140137
}
141138

142139
func New(
@@ -183,7 +180,7 @@ func New(
183180
return nil, err
184181
}
185182

186-
s := &state{
183+
return &state{
187184
parser: parser,
188185
db: db,
189186

@@ -204,10 +201,7 @@ func New(
204201
blockDB: blockDB,
205202

206203
singletonDB: singletonDB,
207-
208-
trackChecksum: trackChecksums,
209-
}
210-
return s, s.initTxChecksum()
204+
}, nil
211205
}
212206

213207
func (s *state) GetUTXO(utxoID ids.ID) (*avax.UTXO, error) {
@@ -264,7 +258,6 @@ func (s *state) GetTx(txID ids.ID) (*txs.Tx, error) {
264258

265259
func (s *state) AddTx(tx *txs.Tx) {
266260
txID := tx.ID()
267-
s.updateTxChecksum(txID)
268261
s.addedTxs[txID] = tx
269262
}
270263

@@ -500,36 +493,6 @@ func (s *state) writeMetadata() error {
500493
return nil
501494
}
502495

503-
func (s *state) Checksums() (ids.ID, ids.ID) {
504-
return s.txChecksum, s.utxoState.Checksum()
505-
}
506-
507-
func (s *state) initTxChecksum() error {
508-
if !s.trackChecksum {
509-
return nil
510-
}
511-
512-
txIt := s.txDB.NewIterator()
513-
defer txIt.Release()
514-
515-
for txIt.Next() {
516-
txIDBytes := txIt.Key()
517-
518-
txID, err := ids.ToID(txIDBytes)
519-
if err != nil {
520-
return err
521-
}
522-
523-
s.updateTxChecksum(txID)
524-
}
525-
526-
return txIt.Error()
527-
}
528-
529-
func (s *state) updateTxChecksum(modifiedID ids.ID) {
530-
if !s.trackChecksum {
531-
return
532-
}
533-
534-
s.txChecksum = s.txChecksum.XOR(modifiedID)
496+
func (s *state) Checksum() ids.ID {
497+
return s.utxoState.Checksum()
535498
}

vms/avm/state/statemock/state.go

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vms/platformvm/block/executor/acceptor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (a *acceptor) ApricotAtomicBlock(b *block.ApricotAtomicBlock) error {
110110
zap.Stringer("blkID", blkID),
111111
zap.Uint64("height", b.Height()),
112112
zap.Stringer("parentID", b.Parent()),
113-
zap.Stringer("utxoChecksum", a.state.Checksum()),
113+
zap.Stringer("checksum", a.state.Checksum()),
114114
)
115115

116116
return nil
@@ -180,7 +180,7 @@ func (a *acceptor) optionBlock(b block.Block, blockType string) error {
180180
zap.Stringer("blkID", blkID),
181181
zap.Uint64("height", b.Height()),
182182
zap.Stringer("parentID", parentID),
183-
zap.Stringer("utxoChecksum", a.state.Checksum()),
183+
zap.Stringer("checksum", a.state.Checksum()),
184184
)
185185

186186
return nil
@@ -212,7 +212,7 @@ func (a *acceptor) proposalBlock(b block.Block, blockType string) {
212212
zap.Stringer("blkID", blkID),
213213
zap.Uint64("height", b.Height()),
214214
zap.Stringer("parentID", b.Parent()),
215-
zap.Stringer("utxoChecksum", a.state.Checksum()),
215+
zap.Stringer("checksum", a.state.Checksum()),
216216
)
217217
}
218218

@@ -259,7 +259,7 @@ func (a *acceptor) standardBlock(b block.Block, blockType string) error {
259259
zap.Stringer("blkID", blkID),
260260
zap.Uint64("height", b.Height()),
261261
zap.Stringer("parentID", b.Parent()),
262-
zap.Stringer("utxoChecksum", a.state.Checksum()),
262+
zap.Stringer("checksum", a.state.Checksum()),
263263
)
264264

265265
return nil

0 commit comments

Comments
 (0)