From 4c2c909f0fce5367a2b0acd3dd448f3a17091f1b Mon Sep 17 00:00:00 2001 From: DinhLN Date: Sat, 6 Oct 2018 10:29:52 +0700 Subject: [PATCH] Fixed duplicate nonce value for randomize and sign txs --- contracts/utils.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/utils.go b/contracts/utils.go index bb6d195769..435f6d668d 100644 --- a/contracts/utils.go +++ b/contracts/utils.go @@ -95,9 +95,7 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m // Only process when private key empty in state db. // Save randomize key into state db. randomizeKeyValue := RandStringByte(32) - chainDb.Put(randomizeKeyName, randomizeKeyValue) - - tx, err := BuildTxSecretRandomize(nonce, common.HexToAddress(common.RandomizeSMC), chainConfig.Posv.Epoch, randomizeKeyValue) + tx, err := BuildTxSecretRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), chainConfig.Posv.Epoch, randomizeKeyValue) if err != nil { log.Error("Fail to get tx opening for randomize", "error", err) return err @@ -112,6 +110,9 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m if err != nil { log.Error("Fail to add tx secret to local pool.", "error", err) } + + // Put randomize key into chainDb. + chainDb.Put(randomizeKeyName, randomizeKeyValue) } // Set opening for randomize. @@ -121,7 +122,7 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m log.Error("Fail to get randomize key from state db.", "error", err) } - tx, err := BuildTxOpeningRandomize(nonce, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue) + tx, err := BuildTxOpeningRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue) if err != nil { log.Error("Fail to get tx opening for randomize", "error", err) return err