e3: to produce stateChanges stream (#7692)

This commit is contained in:
Alex Sharov 2023-06-09 11:13:06 +07:00 committed by GitHub
parent afa4f53ae2
commit 2c39570077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -149,6 +149,7 @@ func ExecV3(ctx context.Context,
parallel bool, logPrefix string,
maxBlockNum uint64,
logger log.Logger,
initialCycle bool,
) error {
batchSize := cfg.batchSize
chainDb := cfg.db
@ -503,6 +504,8 @@ func ExecV3(ctx context.Context,
slowDownLimit := time.NewTicker(time.Second)
defer slowDownLimit.Stop()
stateStream := !initialCycle && cfg.stateStream && maxBlockNum-block < stateStreamLimit
var b *types.Block
var blockNum uint64
var err error
@ -560,6 +563,14 @@ Loop:
}
}
}()
} else {
if !initialCycle && stateStream {
txs, err := blockReader.RawTransactions(context.Background(), applyTx, b.NumberU64(), b.NumberU64())
if err != nil {
return err
}
cfg.accumulator.StartChange(b.NumberU64(), b.Hash(), txs, false)
}
}
rules := chainConfig.Rules(blockNum, b.Time())

View File

@ -277,7 +277,7 @@ func ExecBlockV3(s *StageState, u Unwinder, tx kv.RwTx, toBlock uint64, ctx cont
}
parallel := initialCycle && tx == nil
if err := ExecV3(ctx, s, u, workersCount, cfg, tx, parallel, logPrefix,
to, logger); err != nil {
to, logger, initialCycle); err != nil {
return fmt.Errorf("ExecV3: %w", err)
}
return nil