mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
cmd/evm/t8ntool: add error handling for Commit and state reopening
Previously, both statedb.Commit() and the subsequent state.New() were ignoring returned errors. This could lead to silent failures where: 1. The commit operation fails but execution continues 2. State reopening fails after a successful commit Both scenarios can cause difficult-to-debug issues, especially in testing scenarios where state consistency is critical. This change adds proper error checking for both operations, ensuring that any failures are caught immediately with descriptive error messages. This issue was encountered and fixed in https://github.com/gballet/go-ethereum/pull/552 where the error handling proved essential for debugging.
This commit is contained in:
parent
5e6f04c774
commit
eb99acbb35
1 changed files with 8 additions and 2 deletions
|
|
@ -387,8 +387,14 @@ func MakePreState(db ethdb.Database, accounts types.GenesisAlloc) *state.StateDB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Commit and re-open to start with a clean state.
|
// Commit and re-open to start with a clean state.
|
||||||
root, _ := statedb.Commit(0, false, false)
|
root, err := statedb.Commit(0, false, false)
|
||||||
statedb, _ = state.New(root, sdb)
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("failed to commit initial state: %v", err))
|
||||||
|
}
|
||||||
|
statedb, err = state.New(root, sdb)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("failed to reopen state after commit: %v", err))
|
||||||
|
}
|
||||||
return statedb
|
return statedb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue