Skip to content

Commit

Permalink
Handle StateDB obtaining error in TxPool (Fantom-foundation#65)
Browse files Browse the repository at this point in the history
* Handle StateDB obtaining error in TxPool

* Upgrade golang in Github CI to 1.21 (required by Carmen)
  • Loading branch information
Jan Kalina authored Nov 24, 2023
1 parent b8bba0e commit b9f6c0a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Golang dependency
uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'

- name: Run unit tests
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Golang dependency
uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'

- name: Run unit tests
env:
Expand Down
6 changes: 3 additions & 3 deletions evmcore/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1375,9 +1375,6 @@ func (pool *TxPool) reset(oldHead, newHead *EvmHeader) {
if newHead == nil {
newHead = pool.chain.CurrentBlock().Header() // Special case during testing
}
if pool.currentState != nil {
pool.currentState.Release()
}
statedb, err := pool.chain.StateAt(newHead.Root)
if err != nil && pool.currentState == nil {
log.Debug("Failed to access EVM state", "block", newHead.Number, "root", newHead.Root, "err", err)
Expand All @@ -1387,6 +1384,9 @@ func (pool *TxPool) reset(oldHead, newHead *EvmHeader) {
log.Error("Failed to reset txpool state", "block", newHead.Number, "root", newHead.Root, "err", err)
return
}
if pool.currentState != nil {
pool.currentState.Release() // release only when obtaining of the new StateDB succeed
}
pool.currentState = statedb
pool.pendingNonces = newTxNoncer(statedb)
pool.currentMaxGas = pool.chain.MaxGasLimit()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
)

require (
github.com/Fantom-foundation/Carmen/go v0.0.0-20231122101444-59498c099c54
github.com/Fantom-foundation/Carmen/go v0.0.0-20231124092524-cc66783f55ae
github.com/Fantom-foundation/Tosca v0.0.0-20231103111201-05bbc1e5ebfc
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mo
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Fantom-foundation/Carmen/go v0.0.0-20231122101444-59498c099c54 h1:xnW/TArhODEwHGm4OIG3cwBvUHDpUj85BhUc7QFuuqA=
github.com/Fantom-foundation/Carmen/go v0.0.0-20231122101444-59498c099c54/go.mod h1:zfuEHNMEp1q5Nt7U8Uf28Ary8kNXfVQT7TQv0urQgDY=
github.com/Fantom-foundation/Carmen/go v0.0.0-20231124092524-cc66783f55ae h1:9rvJ9u+fTkwF4FHScOOcL/GGEVDA3X2KlCcWpXmGDI0=
github.com/Fantom-foundation/Carmen/go v0.0.0-20231124092524-cc66783f55ae/go.mod h1:zfuEHNMEp1q5Nt7U8Uf28Ary8kNXfVQT7TQv0urQgDY=
github.com/Fantom-foundation/Tosca v0.0.0-20231103111201-05bbc1e5ebfc h1:yr0MZ1ZCFjo2SyoKHcFd+LqX3vNP0Vu88CnybsncWRw=
github.com/Fantom-foundation/Tosca v0.0.0-20231103111201-05bbc1e5ebfc/go.mod h1:0IgKse/LqcyoneFnQSrBqw/lQ3CHopUcdWmqnAJiQLA=
github.com/Fantom-foundation/go-ethereum-substate v1.1.1-0.20231003122306-febfe681b4a7 h1:AWVp8bMwysTNE2/yORyxk4KF+isK9wFkPeLsT7SYS10=
Expand Down
2 changes: 1 addition & 1 deletion statedb/carmen.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (c *CarmenStateDB) ForEachStorage(addr common.Address, cb func(key common.H
}

func (c *CarmenStateDB) Copy() state.StateDbInterface {
return CreateCarmenStateDb(carmen.CreateStateDBUsing(carmenState))
return CreateCarmenStateDb(carmen.CreateNonCommittableStateDBUsing(carmenState))
}

func (c *CarmenStateDB) Snapshot() int {
Expand Down

0 comments on commit b9f6c0a

Please sign in to comment.