VDB-950 persist untransformed diffs#52
Conversation
still need to pass in a value instead of 0 for the component tests
…itoryBehaviors since this method handles both varible and mapping results
b5f838a to
c7b9f01
Compare
rmulhol
left a comment
There was a problem hiding this comment.
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:
data_generator/data_generator.go
Outdated
| "flag" | ||
| "fmt" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/makerdao/vulcanizedb/pkg/datastore/postgres/repositories" |
There was a problem hiding this comment.
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) |
| CREATE TABLE maker.vat_ilk_spot | ||
| ( | ||
| id SERIAL PRIMARY KEY, | ||
| diff_id INTEGER NOT NULL REFERENCES storage_diff (id) ON DELETE CASCADE, |
There was a problem hiding this comment.
Thinking we may end up wanting indexes on every diff_id, but can probably queue that up for another story after confirming
There was a problem hiding this comment.
👍 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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
👍 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| inputs := shared_behaviors.StorageBehaviorInputs{ | ||
| ValueFieldName: cat.Live, | ||
| Value: fakeUint256, | ||
| StorageTableName: "maker.cat_live", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
👍 definitely like that idea! I'll plan to do this in another PR.
| type VariableRes struct { | ||
| BlockMetadata | ||
| Value string | ||
| DiffID int64 `db:"diff_id"` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
nice idea, do you mean something like in fdfe915?
| Value string | ||
| } | ||
|
|
||
| type AuctionVariableRes struct { |
There was a problem hiding this comment.
nope! nice catch!
| BlockHeight: int(header.BlockNumber), | ||
| StorageKey: key, | ||
| StorageValue: value, | ||
| } |
There was a problem hiding this comment.
Can we make use of the helper in vulcanizedb here?
| 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) |
5754d65 to
fdfe915
Compare
157cf3e to
ff1e4e8
Compare
| 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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Should copy over the new migration from vulcanizedb that makes this a bigserial
There was a problem hiding this comment.
nice catch! will do.
| panic(fmt.Sprintf("valuesMap value type not recognized %v", v)) | ||
| } | ||
|
|
||
| persistedDiff := test_helpers.CreateDiffRecord(db, header, common.Hash{}, key, valueForDiffRecord) |
Uh oh!
There was an error while loading. Please reload this page.