From 13686ad80c1fb6350f86490d36566991d7f88447 Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 31 Jan 2022 13:20:25 -0600 Subject: [PATCH 1/2] fix possible race condition --- params/version.go | 2 +- statediff/indexer/database/sql/indexer.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/params/version.go b/params/version.go index e4227773300c..6a5ab4b1deb3 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 10 // Minor version component of the current release VersionPatch = 15 // Patch version component of the current release - VersionMeta = "statediff-3.0.0" // Version metadata to append to the version string + VersionMeta = "statediff-3.0.1" // Version metadata to append to the version string ) // Version holds the textual version string. diff --git a/statediff/indexer/database/sql/indexer.go b/statediff/indexer/database/sql/indexer.go index c8d526d6fa57..3e578a4690ba 100644 --- a/statediff/indexer/database/sql/indexer.go +++ b/statediff/indexer/database/sql/indexer.go @@ -150,8 +150,10 @@ func (sdi *StateDiffIndexer) PushBlock(block *types.Block, receipts types.Receip dbtx: tx, // handle transaction commit or rollback for any return case submit: func(self *BatchTx, err error) error { - close(self.quit) - close(self.iplds) + defer func() { + close(self.quit) + close(self.iplds) + }() if p := recover(); p != nil { rollback(sdi.ctx, tx) panic(p) From 056fc826614fb07a33405822aa2589753ccb5657 Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 31 Jan 2022 14:17:19 -0600 Subject: [PATCH 2/2] fix CI --- Makefile | 6 ++++-- docker-compose.yml | 2 +- .../indexer/database/file/indexer_test.go | 19 ++++++++++++------- .../indexer/database/sql/pgx_indexer_test.go | 4 ---- .../indexer/database/sql/postgres/config.go | 4 ++-- .../indexer/database/sql/sqlx_indexer_test.go | 4 ---- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 77dced321126..7b77e4a97e4e 100644 --- a/Makefile +++ b/Makefile @@ -73,8 +73,10 @@ devtools: .PHONY: statedifftest statedifftest: | $(GOOSE) - MODE=statediff go test -p 1 ./statediff/... -v + GO111MODULE=on go get github.com/stretchr/testify/assert@v1.7.0 + GO111MODULE=on MODE=statediff go test -p 1 ./statediff/... -v .PHONY: statediff_filewriting_test statediff_filetest: | $(GOOSE) - MODE=statediff STATEDIFF_DB=file go test -p 1 ./statediff/... -v + GO111MODULE=on go get github.com/stretchr/testify/assert@v1.7.0 + GO111MODULE=on MODE=statediff STATEDIFF_DB=file go test -p 1 ./statediff/... -v diff --git a/docker-compose.yml b/docker-compose.yml index d305d1dc1445..32dc46147281 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: image: vulcanize/ipld-eth-db:v0.3.1 environment: POSTGRES_USER: "vdbm" - POSTGRES_DB: "vulcanize_public" + POSTGRES_DB: "vulcanize_testing_v3" POSTGRES_PASSWORD: "password" volumes: - geth_node:/var/lib/postgresql/data diff --git a/statediff/indexer/database/file/indexer_test.go b/statediff/indexer/database/file/indexer_test.go index cd6e89b20ef1..ef849e8e86e7 100644 --- a/statediff/indexer/database/file/indexer_test.go +++ b/statediff/indexer/database/file/indexer_test.go @@ -406,15 +406,20 @@ func TestFileIndexer(t *testing.T) { var nodeElements []interface{} for idx, r := range results { - // Decode the log leaf node. + // Attempt to decode the log leaf node. err = rlp.DecodeBytes(r.Data, &nodeElements) require.NoError(t, err) - - logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) - require.NoError(t, err) - - // 2nd element of the leaf node contains the encoded log data. - test_helpers.ExpectEqual(t, logRaw, nodeElements[1].([]byte)) + if len(nodeElements) == 2 { + logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) + require.NoError(t, err) + // 2nd element of the leaf node contains the encoded log data. + test_helpers.ExpectEqual(t, logRaw, nodeElements[1].([]byte)) + } else { + logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) + require.NoError(t, err) + // raw log was IPLDized + test_helpers.ExpectEqual(t, logRaw, r.Data) + } } } }) diff --git a/statediff/indexer/database/sql/pgx_indexer_test.go b/statediff/indexer/database/sql/pgx_indexer_test.go index e1817aff3efc..110f5f22373d 100644 --- a/statediff/indexer/database/sql/pgx_indexer_test.go +++ b/statediff/indexer/database/sql/pgx_indexer_test.go @@ -277,15 +277,11 @@ func TestPGXIndexer(t *testing.T) { err = rlp.DecodeBytes(r.Data, &nodeElements) require.NoError(t, err) if len(nodeElements) == 2 { - log := new(types.Log) - rlp.DecodeBytes(nodeElements[1].([]byte), log) logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) require.NoError(t, err) // 2nd element of the leaf node contains the encoded log data. test_helpers.ExpectEqual(t, logRaw, nodeElements[1].([]byte)) } else { - log := new(types.Log) - rlp.DecodeBytes(r.Data, log) logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) require.NoError(t, err) // raw log was IPLDized diff --git a/statediff/indexer/database/sql/postgres/config.go b/statediff/indexer/database/sql/postgres/config.go index a3f18e1263fa..095b4dd24313 100644 --- a/statediff/indexer/database/sql/postgres/config.go +++ b/statediff/indexer/database/sql/postgres/config.go @@ -50,8 +50,8 @@ var DefaultConfig = Config{ Hostname: "localhost", Port: 5432, DatabaseName: "vulcanize_testing_v3", - Username: "postgres", - Password: "", + Username: "vdbm", + Password: "password", } // Config holds params for a Postgres db diff --git a/statediff/indexer/database/sql/sqlx_indexer_test.go b/statediff/indexer/database/sql/sqlx_indexer_test.go index 20ec00bcda3b..5538a5f9371d 100644 --- a/statediff/indexer/database/sql/sqlx_indexer_test.go +++ b/statediff/indexer/database/sql/sqlx_indexer_test.go @@ -278,15 +278,11 @@ func TestSQLXIndexer(t *testing.T) { err = rlp.DecodeBytes(r.Data, &nodeElements) require.NoError(t, err) if len(nodeElements) == 2 { - log := new(types.Log) - rlp.DecodeBytes(nodeElements[1].([]byte), log) logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) require.NoError(t, err) // 2nd element of the leaf node contains the encoded log data. test_helpers.ExpectEqual(t, logRaw, nodeElements[1].([]byte)) } else { - log := new(types.Log) - rlp.DecodeBytes(r.Data, log) logRaw, err := rlp.EncodeToBytes(expectedLogs[idx]) require.NoError(t, err) // raw log was IPLDized