diff --git a/pkg/state/appender.go b/pkg/state/appender.go index 15a247d8f..9a9137586 100644 --- a/pkg/state/appender.go +++ b/pkg/state/appender.go @@ -352,7 +352,8 @@ func (a *txAppender) commitTxApplication( applicationStatus = applicationRes.status ) - balanceChanges := a.diffStor.allChanges() + //balanceChanges := a.diffStor.allChanges() + balanceChanges := applicationRes.changes.diff.balancesChanges() a.diffStor.reset() snapshot, err := a.txHandler.performTx(tx, pi, params.validatingUtx, invocationRes, applicationStatus, balanceChanges) if err != nil { @@ -671,7 +672,6 @@ func (a *txAppender) appendBlock(params *appendBlockParams) error { } // create the initial snapshot - initialSnapshot, err := a.txHandler.tp.createInitialBlockSnapshot(minerAndRewardDiff.balancesChanges()) if err != nil { return errors.Wrap(err, "failed to create initial snapshot") @@ -693,9 +693,13 @@ func (a *txAppender) appendBlock(params *appendBlockParams) error { return err } // TODO validate before reset - a.diffStor.reset() + err = initialSnapshot.ApplyInitialSnapshot(a.txHandler.sa) + if err != nil { + return errors.Wrap(err, "failed to apply an initial snapshot") + } + defer hasher.Release() // get initial snapshot hash for block @@ -712,12 +716,6 @@ func (a *txAppender) appendBlock(params *appendBlockParams) error { ) } - // TODO snapshot is apply in hasher - //err = initialSnapshot.ApplyInitialSnapshot(a.txHandler.sa) - //if err != nil { - // return errors.Wrap(err, "failed to apply an initial snapshot") - //} - blockV5Activated, err := a.stor.features.newestIsActivated(int16(settings.BlockV5)) if err != nil { return err diff --git a/pkg/state/state.go b/pkg/state/state.go index 9a041d885..be759fa88 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -603,9 +603,10 @@ func (s *stateManager) addGenesisBlock() error { return err } - if err := s.appender.applyAllDiffs(); err != nil { - return err - } + // TODO validate it instead + //if err := s.appender.applyAllDiffs(); err != nil { + // return err + //} if err := s.stor.prepareHashes(); err != nil { return err } @@ -1555,9 +1556,10 @@ func (s *stateManager) addBlocks() (*proto.Block, error) { // Apply all the balance diffs accumulated from this blocks batch. // This also validates diffs for negative balances. - if err := s.appender.applyAllDiffs(); err != nil { - return nil, err - } + // TODO validate it instead + //if err := s.appender.applyAllDiffs(); err != nil { + // return nil, err + //} // Retrieve and store legacy state hashes for each of new blocks. if shErr := s.stor.handleLegacyStateHashes(height, ids); shErr != nil {