diff --git a/go.mod b/go.mod index 7b26654..10d0d33 100644 --- a/go.mod +++ b/go.mod @@ -284,12 +284,12 @@ require ( ) replace ( - github.com/cerc-io/eth-ipfs-state-validator/v5 => git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.0-alpha - github.com/cerc-io/eth-iterator-utils => git.vdb.to/cerc-io/eth-iterator-utils v0.1.0 - github.com/cerc-io/eth-testing => git.vdb.to/cerc-io/eth-testing v0.2.1 - github.com/cerc-io/ipld-eth-server/v5 => git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.1-alpha - github.com/cerc-io/ipld-eth-statedb => git.vdb.to/cerc-io/ipld-eth-statedb v0.0.6-alpha - github.com/cerc-io/plugeth-statediff => git.vdb.to/cerc-io/plugeth-statediff v0.1.1 + github.com/cerc-io/eth-ipfs-state-validator/v5 => git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha + github.com/cerc-io/eth-iterator-utils => git.vdb.to/cerc-io/eth-iterator-utils v0.1.2 + github.com/cerc-io/eth-testing => git.vdb.to/cerc-io/eth-testing v0.3.1 + github.com/cerc-io/ipld-eth-server/v5 => git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.2-alpha + github.com/cerc-io/ipld-eth-statedb => git.vdb.to/cerc-io/ipld-eth-statedb v0.0.7-alpha + github.com/cerc-io/plugeth-statediff => git.vdb.to/cerc-io/plugeth-statediff v0.1.4 github.com/ethereum/go-ethereum => git.vdb.to/cerc-io/plugeth v0.0.0-20230808125822-691dc334fab1 github.com/openrelayxyz/plugeth-utils => git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46 ) diff --git a/go.sum b/go.sum index 3028498..e62eff4 100644 --- a/go.sum +++ b/go.sum @@ -45,19 +45,19 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.0-alpha h1:jHCtUi2CYJE0CLPHiwBBpHWDSfN1hGMJq8NOiBUHDaQ= -git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.0-alpha/go.mod h1:zljw2omf9IEyCT2WmR/gzVKQbsQ1XzPE22noSDQ2l34= -git.vdb.to/cerc-io/eth-iterator-utils v0.1.0 h1:4YALvTld0wfp9KV+pPfPcyJfzVCAkKSEhnxtJiFiNlE= -git.vdb.to/cerc-io/eth-iterator-utils v0.1.0/go.mod h1:oYOOUbNpcuAUoFhfTg6Zab4PyrRIk8SSJ/i34WNE6Fw= -git.vdb.to/cerc-io/eth-testing v0.2.1 h1:IZAX7DVgzPkSmu1xdKZ5aOemdEYbvtgae7GUl/TUNtQ= -git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.1-alpha h1:2P0iHcH2Bnq6Rs8GZCH9w1gc76as2YaiXb3WRX6+yuM= -git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.1-alpha/go.mod h1:DlhOVss3Iji8fcqkzDzpVYHgnm9+yz7SKkKYInLEgco= -git.vdb.to/cerc-io/ipld-eth-statedb v0.0.6-alpha h1:0YnoohjuK7w2JhIqLDDyVUNnu1RjyeDqqyhm6MojD74= -git.vdb.to/cerc-io/ipld-eth-statedb v0.0.6-alpha/go.mod h1:cCQCfIUX5vTZBHeAfLa8wLUeLKO8kygDPm7Afc+MMI8= +git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha h1:tophBXLyhMKmQILsxjfUTwQW+TGHtEJNajVULJJLhe0= +git.vdb.to/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha/go.mod h1:e/9QV7BeaAvR+E6G3fab5+OxKGOEwCmJzs8WReuqKZM= +git.vdb.to/cerc-io/eth-iterator-utils v0.1.2 h1:PdMR5B9wrQSYuYpFhN+9Kc8AEZ0pTt5eKCmu8oCtFcY= +git.vdb.to/cerc-io/eth-iterator-utils v0.1.2/go.mod h1:OvXbdWbZ5viBXC/Ui1EkhsSmGB+AUX+TjGa3UDAfjfg= +git.vdb.to/cerc-io/eth-testing v0.3.1 h1:sPnlMev6oEgTjsW7GtUkSsjKNG/+X6P9q0izSejLGpM= +git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.2-alpha h1:kQ1dIFhso2VaJpJ3cVapTvTYmk64pE3XnUnr4eHdJdU= +git.vdb.to/cerc-io/ipld-eth-server/v5 v5.1.2-alpha/go.mod h1:oWqgcY4QPLT70/hSCI/VRxBadCxlpi2k/tMfA8cIDd8= +git.vdb.to/cerc-io/ipld-eth-statedb v0.0.7-alpha h1:jtE+I+xlX9Q+vrkrgef9+w2JC7kuiUdrD//KVWtti5s= +git.vdb.to/cerc-io/ipld-eth-statedb v0.0.7-alpha/go.mod h1:hUTzvyEEdaM0qVrfbtobZEURZoOpaN6wJ5s3YQgAHo8= git.vdb.to/cerc-io/plugeth v0.0.0-20230808125822-691dc334fab1 h1:KLjxHwp9Zp7xhECccmJS00RiL+VwTuUGLU7qeIctg8g= git.vdb.to/cerc-io/plugeth v0.0.0-20230808125822-691dc334fab1/go.mod h1:cYXZu70+6xmDgIgrTD81GPasv16piiAFJnKyAbwVPMU= -git.vdb.to/cerc-io/plugeth-statediff v0.1.1 h1:qKygQwZO2vECySFpgfaiXwWn275jIV//pwsuNfeCXLo= -git.vdb.to/cerc-io/plugeth-statediff v0.1.1/go.mod h1:61WPXOqJshEkxzalwyyLukTiIBG+Z7WyfvRdhVLfBF8= +git.vdb.to/cerc-io/plugeth-statediff v0.1.4 h1:swDJDAk1/yu6MOHAvxeyZz+MS1H9FCmSWGQRswFxFEw= +git.vdb.to/cerc-io/plugeth-statediff v0.1.4/go.mod h1:PX1bwTwZKzegQu6zYdpuJf1tHNmU0suapKOUUO2xIzs= git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46 h1:KYcbbne/RXd7AuxbUd/3hgk1jPN+33k2CKiNsUsMCC0= git.vdb.to/cerc-io/plugeth-utils v0.0.0-20230706160122-cd41de354c46/go.mod h1:VpDN61dxy64zGff05F0adujR5enD/JEdXBkTQ+PaIsQ= github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= diff --git a/internal/helpers/indexing.go b/internal/helpers/indexing.go index 2ca6115..9066381 100644 --- a/internal/helpers/indexing.go +++ b/internal/helpers/indexing.go @@ -24,7 +24,7 @@ func TestStateDiffIndexer(ctx context.Context, chainConfig *params.ChainConfig, ClientName: "geth", ChainID: chainConfig.ChainID.Uint64(), } - _, indexer, err := indexer.NewStateDiffIndexer(ctx, chainConfig, testInfo, TestDBConfig) + _, indexer, err := indexer.NewStateDiffIndexer(ctx, chainConfig, testInfo, TestDBConfig, true) return indexer, err } @@ -72,6 +72,7 @@ func IndexChain(indexer interfaces.StateDiffIndexer, params IndexChainParams) er if err != nil { return fmt.Errorf("failed to index block (block %d): %w", block.Number(), err) } + defer tx.RollbackOnFailure(err) if !params.SkipStateNodes { for _, node := range diff.Nodes { @@ -91,7 +92,7 @@ func IndexChain(indexer interfaces.StateDiffIndexer, params IndexChainParams) er } } } - if err = tx.Submit(err); err != nil { + if err = tx.Submit(); err != nil { return fmt.Errorf("failed to commit diff: %w", err) } } diff --git a/pkg/validator/validator_test.go b/pkg/validator/validator_test.go index 900d6eb..a1d8ecc 100644 --- a/pkg/validator/validator_test.go +++ b/pkg/validator/validator_test.go @@ -51,14 +51,17 @@ func setupStateValidator(t *testing.T) *sqlx.DB { t.Fatal(err) } - { // Insert some non-canonical data into the database so that we test our ability to discern canonicity + // Insert some non-canonical data into the database so that we test our ability to discern canonicity + // Use a func here for defer + func() { tx, err := indexer.PushBlock(server_mocks.MockBlock, server_mocks.MockReceipts, server_mocks.MockBlock.Difficulty()) if err != nil { t.Fatal(err) } + defer tx.RollbackOnFailure(err) - err = tx.Submit(err) + err = tx.Submit() if err != nil { t.Fatal(err) } @@ -69,6 +72,7 @@ func setupStateValidator(t *testing.T) *sqlx.DB { if err != nil { t.Fatal(err) } + defer tx.RollbackOnFailure(err) ipld := sdtypes.IPLD{ CID: ipld.Keccak256ToCid(ipld.RawBinary, server_mocks.CodeHash.Bytes()).String(), @@ -79,11 +83,11 @@ func setupStateValidator(t *testing.T) *sqlx.DB { t.Fatal(err) } - err = tx.Submit(err) + err = tx.Submit() if err != nil { t.Fatal(err) } - } + }() if err := helpers.IndexChain(indexer, helpers.IndexChainParams{ StateCache: chain.StateCache(),