Skip to content

Commit

Permalink
Merge pull request #198 from vulcanize/v1.10.15-statediff-3.0.1
Browse files Browse the repository at this point in the history
fix possible race condition
  • Loading branch information
i-norden authored Jan 31, 2022
2 parents d2711b0 + 056fc82 commit f78f9be
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
GO111MODULE=on MODE=statediff STATEDIFF_DB=file go test -p 1 ./statediff/... -v
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 12 additions & 7 deletions statediff/indexer/database/file/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
})
Expand Down
6 changes: 4 additions & 2 deletions statediff/indexer/database/sql/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions statediff/indexer/database/sql/pgx_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions statediff/indexer/database/sql/postgres/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions statediff/indexer/database/sql/sqlx_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f78f9be

Please sign in to comment.