From bdfdd7cd028518e0bbbc6a7e0ed8322190b80582 Mon Sep 17 00:00:00 2001
From: Wei-Ning Huang <w@dexon.org>
Date: Sat, 17 Nov 2018 13:18:34 +0800
Subject: core: more fix on light node synchronization (#32)

Fix gas calculation in governance contract.
Correctly register round height when processing pending blocks. We
should register the mapping when we get the pending block instead of
waiting for block confirmation.
---
 dex/config.go     |  4 ++--
 dex/governance.go | 11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

(limited to 'dex')

diff --git a/dex/config.go b/dex/config.go
index 282de494f..b90a344c8 100644
--- a/dex/config.go
+++ b/dex/config.go
@@ -48,8 +48,8 @@ var DefaultConfig = Config{
 	},
 	BlockProposerEnabled: false,
 	DefaultGasPrice:      big.NewInt(params.GWei),
-	GasFloor:             8000000,
-	GasCeil:              8000000,
+	GasFloor:             80000000,
+	GasCeil:              80000000,
 	GasLimitTolerance:    1000000,
 }
 
diff --git a/dex/governance.go b/dex/governance.go
index 0251d2afd..f555b3508 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -79,6 +79,7 @@ func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateH
 
 	state, _, err := d.b.StateAndHeaderByNumber(ctx, rpc.BlockNumber(blockHeight))
 	if state == nil || err != nil {
+		log.Error("Failed to retrieve governance state", "round", round, "height", blockHeight)
 		return nil
 	}
 	return &vm.GovernanceStateHelper{state}
@@ -119,17 +120,15 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
 		return err
 	}
 
-	log.Info("sendGovTx", "nonce", nonce)
-
-	// Increase gasPrice to 5 times of suggested gas price to make sure it will
+	// Increase gasPrice to 10 times of suggested gas price to make sure it will
 	// be included in time.
-	gasPrice = new(big.Int).Mul(gasPrice, big.NewInt(5))
+	gasPrice = new(big.Int).Mul(gasPrice, big.NewInt(10))
 
 	tx := types.NewTransaction(
 		nonce,
 		vm.GovernanceContractAddress,
 		big.NewInt(0),
-		uint64(2000000),
+		uint64(10000000),
 		gasPrice,
 		data)
 
@@ -140,7 +139,7 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
 		return err
 	}
 
-	log.Info("Send governance transaction", "fullhash", tx.Hash().Hex())
+	log.Info("Send governance transaction", "fullhash", tx.Hash().Hex(), "nonce", nonce)
 
 	return d.b.SendTx(ctx, tx)
 }
-- 
cgit v1.2.3