Skip to content

VDB-950 persist untransformed diffs#52

Merged
elizabethengelman merged 29 commits intostagingfrom
vdb-950-persist-untransformed-diffs
Dec 12, 2019
Merged

VDB-950 persist untransformed diffs#52
elizabethengelman merged 29 commits intostagingfrom
vdb-950-persist-untransformed-diffs

Conversation

@elizabethengelman
Copy link
Copy Markdown
Contributor

@elizabethengelman elizabethengelman commented Dec 10, 2019

@elizabethengelman elizabethengelman changed the title Vdb 950 persist untransformed diffs [WIP] VDB-950 persist untransformed diffs Dec 10, 2019
@elizabethengelman elizabethengelman force-pushed the vdb-950-persist-untransformed-diffs branch from b5f838a to c7b9f01 Compare December 10, 2019 21:48
@elizabethengelman elizabethengelman changed the title [WIP] VDB-950 persist untransformed diffs VDB-950 persist untransformed diffs Dec 10, 2019
Copy link
Copy Markdown
Contributor

@rmulhol rmulhol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the lead on this! LGTM - don't think any of my comments are blocking, but curious to hear what you think about them 👍:pray:

"flag"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/makerdao/vulcanizedb/pkg/datastore/postgres/repositories"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be cool to remove the whitespace in the imports in re-run goimports -w, but nbd

)) RETURNING id`
insertVatFrobSql = `INSERT INTO maker.vat_frob (header_id, urn_id, v, w, dink, dart, log_id)
VALUES($1, $2::NUMERIC, $3, $4, $5::NUMERIC, $6::NUMERIC, $7)
VALUES($1::NUMERIC, $2::NUMERIC, $3, $4, $5::NUMERIC, $6::NUMERIC, $7::NUMERIC)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

CREATE TABLE maker.vat_ilk_spot
(
id SERIAL PRIMARY KEY,
diff_id INTEGER NOT NULL REFERENCES storage_diff (id) ON DELETE CASCADE,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking we may end up wanting indexes on every diff_id, but can probably queue that up for another story after confirming

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 totally makes sense. I'll probably do this in another PR.

CREATE TABLE maker.vat_ilk_rate
(
id SERIAL PRIMARY KEY,
diff_id INTEGER NOT NULL REFERENCES storage_diff (id) ON DELETE CASCADE,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another not-necessary-in-this-PR thing - wondering if the storage_diff (id) should be a bigint. Seems like we could end up with more rows than the max integer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice catch! Updated in 1ad6498.

I'm also wondering if this sort of change is something we'd want to consider for header_id and address_id. Seems like the number of headers and addresses will grow way slower than diffs, but it would probably also be easier to handle the type change now vs. later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call, I don't see a reason not to use it for those other fields. Thinking we may need to update sky-ecosystem/vulcanizedb#8 so that the actual primary key on the table is a bigserial, and would be up for making a similar change to other tables whenever

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go.mod Outdated

replace github.com/ethereum/go-ethereum => github.com/vulcanize/go-ethereum v0.0.0-20190731183759-8e20673bd101

replace github.com/makerdao/vulcanizedb => github.com/makerdao/vulcanizedb v0.0.11-0.20191210170334-0491389f8183
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth potentially just changing the version in the require? probably not a big deal if we'll be updating after we cut a new version shortly

fakeHeaderID int64
fakeAddress = "0x12345"
fakeUint256 = "12345"
db *postgres.DB
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor and not an issue with this PR but maybe it's worth defining the db var here as test_config.NewTestDB(test_config.NewTestNode()) here so that it's not a new connection for every test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputs := shared_behaviors.StorageBehaviorInputs{
ValueFieldName: cat.Live,
Value: fakeUint256,
StorageTableName: "maker.cat_live",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not a part of this PR but writing it down so I don't forget, seems like we could restructure this struct to accept a Schema and TableName and then use the constants from transformers/shared/constants/table.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 definitely like that idea! I'll plan to do this in another PR.

type VariableRes struct {
BlockMetadata
Value string
DiffID int64 `db:"diff_id"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor but maybe worth having a DiffMetadata struct that includes BlockMetadata and a DiffID and then inheriting that instead of both of those in subsequent structs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice idea, do you mean something like in fdfe915?

Value string
}

type AuctionVariableRes struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope! nice catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlockHeight: int(header.BlockNumber),
StorageKey: key,
StorageValue: value,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make use of the helper in vulcanizedb here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@gslaughl gslaughl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +66 to +75
vatMetadata := utils.GetStorageValueMetadata(cat.Vat, nil, utils.Address)
inputs := shared_behaviors.StorageVariableBehaviorInputs{
ValueFieldName: cat.Vat,
Value: fakeAddress,
StorageTableName: "maker.cat_vat",
Repository: &repo,
Metadata: vatMetadata,
}

shared_behaviors.SharedStorageRepositoryVariableBehaviors(&inputs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@elizabethengelman elizabethengelman force-pushed the vdb-950-persist-untransformed-diffs branch from 5754d65 to fdfe915 Compare December 11, 2019 21:22
@elizabethengelman elizabethengelman force-pushed the vdb-950-persist-untransformed-diffs branch from 157cf3e to ff1e4e8 Compare December 11, 2019 21:40
github.com/sirupsen/logrus v1.2.0
github.com/spf13/viper v1.3.2
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
Copy link
Copy Markdown
Contributor Author

@elizabethengelman elizabethengelman Dec 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rest of these changes are the result of running gomoderator.py against vdb staging

-- +goose Up
CREATE TABLE public.storage_diff
(
id SERIAL PRIMARY KEY,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should copy over the new migration from vulcanizedb that makes this a bigserial

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! will do.

panic(fmt.Sprintf("valuesMap value type not recognized %v", v))
}

persistedDiff := test_helpers.CreateDiffRecord(db, header, common.Hash{}, key, valueForDiffRecord)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@elizabethengelman elizabethengelman merged commit 4414784 into staging Dec 12, 2019
@elizabethengelman elizabethengelman deleted the vdb-950-persist-untransformed-diffs branch December 12, 2019 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants