-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unique hashes for spc txs #171
Conversation
Hi, can you fetch the latest code from dev-upgrade please? Your test is failed. |
Could you please create relevant unit or integration tests to cover the changes you made? |
I think you use this line |
By the way, is it feasible to use incremental nonce, just like normal transactions? If nonce is incremented ( |
No. It is impossible to use Gas Limit larger when pool Gas Limit Line 608 in be3e9eb
However, if it be based on case that blocks appears every 2 seconds and it looks so, it is possible to use Nonce can be also incremented but it won't guarantee that every block will have special transaction cause of possible errors. Like get address from in that case XDPoSChain/core/state_processor.go Line 452 in 22479f1
|
Hmm. I do not see special test cases for these changes. I suppose all current test cover the worker's functional. |
miner/worker.go
Outdated
@@ -701,7 +701,8 @@ func (self *worker) commitNewWork() { | |||
return | |||
} | |||
nonce := work.state.GetNonce(self.coinbase) | |||
tx := types.NewTransaction(nonce, common.HexToAddress(common.XDCXAddr), big.NewInt(0), txMatchGasLimit, big.NewInt(0), txMatchBytes) | |||
dynamicTxMatchGasLimit := uint64(time.Now().UnixNano() / int64(time.Millisecond) % txMatchGasLimit) | |||
tx := types.NewTransaction(nonce, common.HexToAddress(common.XDCXAddr), big.NewInt(0), dynamicTxMatchGasLimit, big.NewInt(0), txMatchBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please create a function in types that avoid duplicate code all over the place
Ideally, it would be best to simulate the issue in unit test prior to your fix. i.e it shall fail. |
miner/worker.go
Outdated
@@ -701,7 +701,8 @@ func (self *worker) commitNewWork() { | |||
return | |||
} | |||
nonce := work.state.GetNonce(self.coinbase) | |||
tx := types.NewTransaction(nonce, common.HexToAddress(common.XDCXAddr), big.NewInt(0), txMatchGasLimit, big.NewInt(0), txMatchBytes) | |||
dynamicTxMatchGasLimit := uint64(time.Now().UnixNano() / int64(time.Millisecond) % txMatchGasLimit) | |||
tx := types.NewTransaction(nonce, common.HexToAddress(common.XDCXAddr), big.NewInt(0), dynamicTxMatchGasLimit, big.NewInt(0), txMatchBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered creating a new function types.NewTransactionWithDynamicGasLimit
where all the randomised logic such as uint64(time.Now().UnixNano() / int64(time.Millisecond) % txMatchGasLimit)
can hide inside it.
Then call this function in this file instead of duplicating it across 4 different places?
Also, it would be very straightforward to write a unit test for such function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@longwinterday could you reply above please
@longwinterday will this change create a hard forking? |
No description provided.