Skip to content

Commit

Permalink
Merge branch 'base'
Browse files Browse the repository at this point in the history
  • Loading branch information
mksong76 committed Sep 26, 2023
2 parents 6f49d8d + df382f5 commit 7b6ce70
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion chain/taskreplay.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (t *taskReplay) doReplay() error {
}
ptxs := nblk.PatchTransactions()
if len(ptxs.Hash()) > 0 {
tr = sm.PatchTransition(tr, ptxs, nblk)
tr = service.PatchTransition(tr, ptxs, nblk, true)
}
cb := make(chan error, 2)
cancel, err := tr.Execute(transitionCallback(cb))
Expand Down
2 changes: 1 addition & 1 deletion service/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (m *manager) PatchTransition(t module.Transition, patchTxList module.Transa
// If there is no way to validate patches, then set 'alreadyValidated' to
// true. It'll skip unnecessary validation for already validated normal
// transactions.
return patchTransition(pt, bi, patchTxList)
return patchTransition(pt, patchTxList, bi, false)
}

func (m *manager) CreateSyncTransition(t module.Transition, result []byte, vlHash []byte, noBuffer bool) module.Transition {
Expand Down
31 changes: 22 additions & 9 deletions service/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,19 @@ type transition struct {
dsrTracker DSRTracker
}

func patchTransition(t *transition, bi module.BlockInfo, patchTXs module.TransactionList) *transition {
func patchTransition(t *transition, patchTXs module.TransactionList, bi module.BlockInfo, validated bool) *transition {
if patchTXs == nil {
patchTXs = transaction.NewTransactionListFromSlice(t.db, nil)
}
if len(patchTXs.Hash()) == 0 {
bi = nil
}
var step transitionStep
if validated {
step = stepValidated
} else {
step = stepInited
}
return &transition{
parent: t.parent,
pid: t.pid,
Expand All @@ -176,7 +182,7 @@ func patchTransition(t *transition, bi module.BlockInfo, patchTXs module.Transac
transitionContext: t.transitionContext,
ntxIDs: t.ntxIDs,
ntxCount: t.ntxCount,
step: stepInited,
step: step,
}
}

Expand Down Expand Up @@ -902,23 +908,29 @@ func (t *transition) executeTxs(l module.TransactionList, ctx contract.Context,

func (t *transition) finalizeNormalTransaction() error {
startTS := time.Now();
defer func() {
t.txFlushDuration = time.Since(startTS)
}()
if err := t.normalTransactions.Flush(); err != nil {
return err
}
if err := t.commitTXIDs(module.TransactionGroupNormal); err != nil {
return err
}
if err := t.commitDSRs(); err != nil {
return err
}
defer func() {
t.txFlushDuration = time.Since(startTS)
}()
return t.normalTransactions.Flush()
return nil
}

func (t *transition) finalizePatchTransaction() error {
if err := t.patchTransactions.Flush(); err != nil {
return err
}
if err := t.commitTXIDs(module.TransactionGroupPatch); err != nil {
return err
}
return t.patchTransactions.Flush()
return nil
}

func (t *transition) finalizeResult(noFlush bool, keepParent bool) error {
Expand Down Expand Up @@ -1108,8 +1120,9 @@ func NewSyncTransition(

func PatchTransition(
tr module.Transition,
bi module.BlockInfo,
ptxs module.TransactionList,
bi module.BlockInfo,
validated bool,
) module.Transition {
return patchTransition(tr.(*transition), bi, ptxs)
return patchTransition(tr.(*transition), ptxs, bi, validated)
}
3 changes: 2 additions & 1 deletion testsuite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ChainTest extends Test {
}

void startDocker(String serverPort) {
def glTag = System.getProperty("GL_TAG", "latest")
List<String> commands = new LinkedList<String>()
commands.add("docker")
commands.add("run")
Expand All @@ -107,7 +108,7 @@ class ChainTest extends Test {
commands.add("data/dockerenv/" + dockerEnv)
commands.add("--name")
commands.add("gochain-" + dockerEnv)
commands.add("goloop/gochain")
commands.add("goloop/gochain:${glTag}")
process = commands.execute(null, getWorkingDir())
if (process.waitFor() == 0) {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
Expand Down

0 comments on commit 7b6ce70

Please sign in to comment.