Skip to content

(VDB-1111) flap wards storage transformer#91

Merged
gslaughl merged 7 commits intostagingfrom
vdb-1111-flap-wards
Jan 16, 2020
Merged

(VDB-1111) flap wards storage transformer#91
gslaughl merged 7 commits intostagingfrom
vdb-1111-flap-wards

Conversation

@gslaughl
Copy link
Copy Markdown
Contributor

@gslaughl gslaughl commented Jan 14, 2020

Includes wards mapping for flip, flap, flop + jug contracts.

Edit: also Vat

@gslaughl gslaughl changed the base branch from vdb-1110-cat-wards to staging January 14, 2020 17:07
@gslaughl gslaughl force-pushed the vdb-1111-flap-wards branch from 5638eb6 to b33c1d1 Compare January 15, 2020 19:58
@gslaughl gslaughl force-pushed the vdb-1111-flap-wards branch from b33c1d1 to b321018 Compare January 15, 2020 20:02
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.

🚢

No blockers here 👍

}
headerID int64
header = fakes.FakeHeader
headerID int64
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 and not introduced by this PR but I've become a fan of not having a headerID var and instead always accessing that val via header.Id in tests so that we don't get weird failures deriving from headerID != header.Id

headerID int64
header = fakes.FakeHeader
headerID int64
err error
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.

Similar thing for err vars - generally prefer to scope these as locally as possible so that we have unique errors in each place they can occur (so that the compiler will tell us if they're unchecked)

@@ -36,18 +39,18 @@ import (
var _ = Describe("Executing the transformer", func() {
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.

🤔 I wonder if we want to name this configured_transformer_test. Still getting used to converter => transformer, which I think is a win - but the various vat "transformer tests" threw me off for a minute

@gslaughl gslaughl force-pushed the vdb-1111-flap-wards branch from b321018 to d3780f3 Compare January 16, 2020 20:49
}

func getUser(keys map[storage.Key]string) (string, error) {
func GetUser(keys map[storage.Key]string) (string, error) {
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.

curious why we're exposing this method outside of this package now 🤔

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! I was using it somewhere else, but ended up undoing the change, so this can totally be a private function.

id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES public.headers (id) ON DELETE CASCADE,
log_id BIGINT NOT NULL REFERENCES public.event_logs (id) ON DELETE CASCADE,
address_id INTEGER NOT NULL REFERENCES addresses (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.

Are we removing the address_id from here (and from vat_deny) because there's only going to be one vat contract per release?

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.

Yeah exactly

insertErr := event.PersistModels([]event.InsertionModel{denyModel}, db)
Expect(insertErr).NotTo(HaveOccurred())

key := common.HexToHash("614c9873ec2671d6eb30d7a22b531442a34fc10f8c24a6598ef401fe94d9cb7d")
Copy link
Copy Markdown
Contributor

@elizabethengelman elizabethengelman Jan 16, 2020

Choose a reason for hiding this comment

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

I wonder if we could go through the steps to calculate the key here so it's more explicit about where it came from? Not super important and definitely not merge blocking!

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.

I like that idea, but in this instance I just grabbed a record from a CSV storage diff. Maybe it would be more thorough to actually calculate the key in the test though 🤔

The code responsible for the calculation is pretty simple:

func GetKeyForMapping(indexOnContract, key string) common.Hash {
	keyBytes := common.FromHex(key + indexOnContract)
	return crypto.Keccak256Hash(keyBytes)
}

@gslaughl gslaughl force-pushed the vdb-1111-flap-wards branch from d3780f3 to 59d4e6b Compare January 16, 2020 21:16
@gslaughl gslaughl merged commit 83587d6 into staging Jan 16, 2020
@gslaughl gslaughl deleted the vdb-1111-flap-wards branch January 16, 2020 21:29
@elizabethengelman elizabethengelman mentioned this pull request Jan 23, 2020
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