Fantom-foundation / Aida

Aida is a block-processing testing infrastructure for EVM-compatible chains.
GNU Lesser General Public License v3.0
6 stars 12 forks source link

Priming of Carmen failed when using carmen as a shadow-db #733

Closed wsodsong closed 1 month ago

wsodsong commented 1 year ago

App: aida-sdb replay, aida-vm-sdb Description: When running aida-vm tool using geth as a primary state-db and carmen as a shadow state-db, priming of carmen failed with a negative balance error. The reverse combination (carmen primary, geth: shadow) worked as intended. Jenkins log; https://jenkins.fantom.network/job/Aida/job/CustomBuild/job/github-test/7/console

step to reproduce:

# record
build/aida-sdb record --cpu-profile cpu-profile-0.dat --trace-file tracefiles/trace-0.dat --aida-db=/var/opera/Aida/mainnet-data/aida-db opera opera+1000

# replay
build/aida-sdb replay --vm-impl geth --db-impl geth --db-tmp=/var/opera/Aida/dbtmpjenkins --aida-db=/var/opera/Aida/mainnet-data/aida-db --update-buffer-size 4096 --shadow-db --db-shadow-impl carmen --cpu-profile cpu-profile.dat --memory-profile mem-profile.dat --memory-breakdown --update-buffer-size 4000 --trace-file tracefiles/trace-0.dat opera 4600000

error:

2023/10/11 06:19:22 INFO:       Merge update set at block 999997. New toal size 14 MB (+14 MB)
2023/10/11 06:19:22 INFO:       Merge update set at block 1999999. New toal size 30 MB (+16 MB)
2023/10/11 06:19:23 INFO:       Merge update set at block 2999999. New toal size 54 MB (+23 MB)
2023/10/11 06:19:23 INFO:       Merge update set at block 3999998. New toal size 66 MB (+12 MB)
2023/10/11 06:19:23 INFO:       Loading 165156 accounts with 1732039 values ..
2023/10/11 06:19:30 INFO:               Loading state ... 141488.7 slots/s,  57.7%, time: 0:07, ETA: 0:51
2023/10/11 06:19:43 INFO:               Priming completed ...
2023/10/11 06:19:43 INFO:       Priming using substate from 3999999 to 4564025
2023/10/11 06:19:43 substate: OpenDestroyedAccountDB
INFO [10-11|06:19:43.213] Allocated cache and file handles         database=/var/opera/Aida/mainnet-data/aida-db cache=1024.00MiB handles=100 readonly=true
2023/10/11 06:20:18 INFO:                1 suicided accounts were removed from statedb (before priming).
2023/10/11 06:20:18 INFO:       Loading 37155 accounts with 2481598 values ..
record-replay: CloseSubstateDB
panic: Unable to convert big.Int balance to common.Balance: negative numbers can not be converted to balances, got -116553000023123100000000

goroutine 1 [running]:
github.com/Fantom-foundation/Carmen/go/state.(*bulkLoad).SetBalance(0xc00061c600, {0xd4, 0xe3, 0xdd, 0x26, 0xb0, 0x84, 0xa6, 0x98, 0x16, ...}, ...)
        /home/wawa/dev/aida2/carmen/go/state/state_db.go:1272 +0x1b9
github.com/Fantom-foundation/Aida/state.(*carmenBulkLoad).SetBalance(0xc190b70b20?, {0xd4, 0xe3, 0xdd, 0x26, 0xb0, 0x84, 0xa6, 0x98, 0x16, ...}, ...)
        /home/wawa/dev/aida2/state/carmen.go:344 +0x34
github.com/Fantom-foundation/Aida/state/proxy.(*shadowBulkLoad).SetBalance(0xc13c666f00, {0xd4, 0xe3, 0xdd, 0x26, 0xb0, 0x84, 0xa6, 0x98, 0x16, ...}, ...)
        /home/wawa/dev/aida2/state/proxy/shadow.go:390 +0x6d
github.com/Fantom-foundation/Aida/utils.(*PrimeContext).primeOneAccount(0xc008c21438, {0xd4, 0xe3, 0xdd, 0x26, 0xb0, 0x84, 0xa6, 0x98, 0x16, ...}, ...)
        /home/wawa/dev/aida2/utils/prime.go:131 +0x107
github.com/Fantom-foundation/Aida/utils.(*PrimeContext).PrimeStateDB(0xc008c21438, 0xc1efcc38c0, {0x1ec6088, 0xc00027a460})
        /home/wawa/dev/aida2/utils/prime.go:106 +0x3f6
github.com/Fantom-foundation/Aida/utils.LoadWorldStateAndPrime({0x1ec6088, 0xc00027a460}, 0xc0004ae700, 0x45a439)
        /home/wawa/dev/aida2/utils/prime.go:282 +0x913
github.com/Fantom-foundation/Aida/cmd/aida-sdb/trace.traceReplayTask(0xc0004ae700, 0xc0069d0150)
        /home/wawa/dev/aida2/cmd/aida-sdb/trace/replay.go:112 +0x3e5
github.com/Fantom-foundation/Aida/cmd/aida-sdb/trace.traceReplayAction(0xc000361b88?)
        /home/wawa/dev/aida2/cmd/aida-sdb/trace/replay.go:263 +0x14a
github.com/urfave/cli/v2.(*Command).Run(0x2af4980, 0xc00033c680, {0xc0003456c0, 0x1b, 0x1b})
        /home/wawa/go/pkg/mod/github.com/urfave/cli/v2@v2.24.4/command.go:273 +0x9eb
github.com/urfave/cli/v2.(*Command).Run(0xc0001c4580, 0xc00033c5c0, {0xc00012c000, 0x1c, 0x1c})
        /home/wawa/go/pkg/mod/github.com/urfave/cli/v2@v2.24.4/command.go:266 +0xc4d
github.com/urfave/cli/v2.(*App).RunContext(0xc000164000, {0x1ea1a08?, 0xc000126010}, {0xc00012c000, 0x1c, 0x1c})
        /home/wawa/go/pkg/mod/github.com/urfave/cli/v2@v2.24.4/app.go:332 +0x616
github.com/urfave/cli/v2.(*App).Run(...)
        /home/wawa/go/pkg/mod/github.com/urfave/cli/v2@v2.24.4/app.go:309
main.main()
        /home/wawa/dev/aida2/cmd/aida-sdb/main.go:30 +0x11a
wsodsong commented 1 year ago

This issue is found in aida-vm-sdb as well