-
Notifications
You must be signed in to change notification settings - Fork 241
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
There is non-determinsim in cosmos-sdk simulation #559
Comments
(base) adudu@CNMAC0342 cronos % iaviewer data app/tmp/2-1/testing.db "s/k:cronos/" 1
Got version: 1
Printing all keys with hashed values (to detect diff)
Hash: E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
Size: 0 |
by changing the backend db to #!/usr/bin
declare -a modules=("acc"
"bank"
"staking"
"mint"
"distribution"
"slashing"
"gov"
"params"
"upgrade"
"evidence"
"capability"
"feegrant"
"authz"
"ibc"
"transfer"
"evm"
"feemarket"
"cronos"
)
declare -a dbs=("1-0" "1-1")
for module in "${modules[@]}"
do
for db in "${dbs[@]}"
do
iaviewer data app/tmp/"$db"/testing.db "s/k:${module}/" 1 > tmp/"$module"-"$db".data
done
delta=$(diff tmp/"$module"-2-0.data tmp/"$module"-2-1.data)
if [ "$delta" != "" ]
then
echo "${module} is not deterministic"
fi
done I got: feemarket is not deterministic |
feemarket stores the (base) adudu@192 cronos % iaviewer data app/tmp/1-0/testing.db "s/k:feemarket/" 1
Got version: 1
Printing all keys with hashed values (to detect diff)
01
AE2D60A6B8D5FBC4C55365A3ED0FF2788EF9F88509C8B9CCD5555EE54130F854
Hash: 55C1DAD91EDEAEE2DFBD2F9A9C3C86938549AE19C4A9A291D18005F2B04D1EBD
Size: 1
(base) adudu@192 cronos % iaviewer data app/tmp/1-1/testing.db "s/k:feemarket/" 1
Got version: 1
Printing all keys with hashed values (to detect diff)
01
941CD147CB2BEE405776E744644AB12FADB8AB7351FDCD2807B4786A098579A3
Hash: 2F1FEB4BC48C0967AA23E81E38B156C0C76F10C19F236F9AD95E1EAD673F3F34
Size: 1 we can see |
Besides, by debugging, I find the genesis states and operations of all modules are deterministic even in the non-deterministic rounds. |
Since the feemarket module store is not deterministic, I debug feemarket blockGasUsed in ethermint repo.
< after anteHandler, gas meter value: 99423
< before runMsgs, gas meter value: 99423
< finish running tx, gas meter value: 102011
---
> after anteHandler, gas meter value: 98611
> before runMsgs, gas meter value: 98611
> finish running tx, gas meter value: 101199
224c224
< tx execution: gasWanted 10000000, gasUsed 102011
---
> tx execution: gasWanted 10000000, gasUsed 101199
227,229c227,229
< after anteHandler, gas meter value: 111558
< before runMsgs, gas meter value: 111558
< finish running tx, gas meter value: 129051
---
> after anteHandler, gas meter value: 112174
> before runMsgs, gas meter value: 112174
> finish running tx, gas meter value: 129667
231c231
< tx execution: gasWanted 10000000, gasUsed 129051
---
> tx execution: gasWanted 10000000, gasUsed 129667
234,236c234,236
< after anteHandler, gas meter value: 99675
< before runMsgs, gas meter value: 99675
< finish running tx, gas meter value: 211407
---
> after anteHandler, gas meter value: 98877
> before runMsgs, gas meter value: 98877
> finish running tx, gas meter value: 210609
238c238
< tx execution: gasWanted 10000000, gasUsed 211407
---
> tx execution: gasWanted 10000000, gasUsed 210609
241,243c241,243
< after anteHandler, gas meter value: 112060
< before runMsgs, gas meter value: 112060
< finish running tx, gas meter value: 129829
---
> after anteHandler, gas meter value: 112620
> before runMsgs, gas meter value: 112620
> finish running tx, gas meter value: 130389 The non-deterministic behavior happens in |
the root cause is found: evmos/ethermint#1151 (comment)
|
but it shouldn't cause app hash mismatch? |
feemarket store |
Oh, sorry maybe I describe the problem in a confusing way. |
open a PR in cosmos-sdk repo to fix this |
/runsim |
/runsim |
Describe the bug
There is non-deterministic behavior in cosmos-sdk level simulation caused by
Simstate.Rand
.if we commented this line x/cronos/simulaltion/genesis.go
TestAppStateDeterminism
could pass.But
TestAppStateDeterminism
failed if we usedSimstate.Rand
even if the value was not used anywhere.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Simstate.Rand
should be deterministic with the same seed.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
macos Big Sur
go 1.18.1
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: