Skip to content

There is non-determinsim in cosmos-sdk simulation #559

@adu-crypto

Description

@adu-crypto

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

	// if we use rand here it will cause non determinism, but if we comment this line everything is fine.
	_ = simState.Rand.Intn(100)

TestAppStateDeterminism could pass.
But TestAppStateDeterminism failed if we used Simstate.Rand even if the value was not used anywhere.

To Reproduce

Steps to reproduce the behavior:

  1.       git pull https://github.com/adu-crypto/cronos.git
  2.       git checkout evm-simulation-determinism
  3.       make test-sim-nondeterminism
  4. See error:
    sim_test.go:339: 
        	Error Trace:	sim_test.go:339
        	Error:      	Not equal: 
        	            	expected: "\xad\xa7㌵\x01\xc3bR\xfb\xb1;\xad\x13\x04\xb5d@\xdaS?\xa7;\x05`X\x90\xa5\x91\xf1M\xd2"
        	            	actual  : "4\xbd\xa6\x1f\xabzY4\xfe?e\x8b\xc6\xff%\xb9\xed1u\xdc\x19G\xf7ȑVv}\xae\xe5\xcf\xd4"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-��㌵��bR��;����d@�S?�;�`X����M�
        	            	+4����zY4�?e���%��1u��G�ȑVv}����
        	Test:       	TestAppStateDeterminism
        	Messages:   	non-determinism in seed 3916589616287113937: 2/3, attempt: 2/5
--- FAIL: TestAppStateDeterminism (146.91s)
FAIL
FAIL	github.com/crypto-org-chain/cronos/app	149.376s
FAIL

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):

  • OS: [e.g. iOS]: macos Big Sur
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]: go 1.18.1

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions