New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
show us the encrypted data #407
Conversation
0dbece1
to
2027e2b
Compare
@@ -254,8 +254,8 @@ const ( | |||
VALUES ($1, $2, $3, $4)` | |||
|
|||
RuntimeTransactionInsert = ` | |||
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, gas_limit, gas_used, size, timestamp, method, body, "to", amount, success, error_module, error_code, error_message) | |||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)` | |||
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, gas_limit, gas_used, size, timestamp, method, body, "to", amount, evm_encrypted_format, evm_encrypted_public_key, evm_encrypted_data_nonce, evm_encrypted_data_data, evm_encrypted_result_nonce, evm_encrypted_result_data, success, error_module, error_code, error_message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃殏馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃殝馃挩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃槅
I can think of a few ways around the runaway train:
-
Create a separate
evm_transactions
table, move the new fields (and probably alsotx_eth_hash
) in there. I'm a little worried about performance because we'll need probably at leasttx_eth_hash
andevm_encrypted_format
(?) every time we're retrieving txs, even if en masse. Or we could denormalize slightly: we create anevm_encryption
table, put just the new fields in it, and additionally store anis_encrypted
flag in the mainruntime_transactions
table, because that's likely all we'll need for the non-detailed view. It's also nice because it generalizes to non-evm encryption (= Cipher). -
Using a postgres composite type, i.e. a struct-typed column, to store the evm encryption info. You create them like so (first format), and use them from Go via
pgtype.CompositeFields
like so. The downside is that we're adding a little complexity to the DB interface/structure/usage. -
Same as number 2, but with JSON instead of composite types. Pretty yuck and space-hungry. I prefer the train over this.
I started off favoring 2, but I'm now more in favor of the denormalized variant of 1.
Note on performance of 1 vs 2: Bulky table rows hurt performance; first in gradual ways (because of page size and disk caches), then at 8kB per row abruptly, because postgres stores rows over 8kB in a TOAST table, so every row lookup performs an implicit JOIN. This would imply 2 is faster, because we JOIN only explicitly, and only for single-tx results. However my understanding of TOAST is that only bulky columns are moved to the overflow (= TOAST) table, so with some luck, our composite type and the existing body
type would be the ones to get moved, which should result in about the same performance as 1 if we only SELECT those columns for single-tx results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too scary to do in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for figuring out the deserialization incantations!
@@ -254,8 +254,8 @@ const ( | |||
VALUES ($1, $2, $3, $4)` | |||
|
|||
RuntimeTransactionInsert = ` | |||
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, gas_limit, gas_used, size, timestamp, method, body, "to", amount, success, error_module, error_code, error_message) | |||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)` | |||
INSERT INTO chain.runtime_transactions (runtime, round, tx_index, tx_hash, tx_eth_hash, fee, gas_limit, gas_used, size, timestamp, method, body, "to", amount, evm_encrypted_format, evm_encrypted_public_key, evm_encrypted_data_nonce, evm_encrypted_data_data, evm_encrypted_result_nonce, evm_encrypted_result_data, success, error_module, error_code, error_message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃槅
I can think of a few ways around the runaway train:
-
Create a separate
evm_transactions
table, move the new fields (and probably alsotx_eth_hash
) in there. I'm a little worried about performance because we'll need probably at leasttx_eth_hash
andevm_encrypted_format
(?) every time we're retrieving txs, even if en masse. Or we could denormalize slightly: we create anevm_encryption
table, put just the new fields in it, and additionally store anis_encrypted
flag in the mainruntime_transactions
table, because that's likely all we'll need for the non-detailed view. It's also nice because it generalizes to non-evm encryption (= Cipher). -
Using a postgres composite type, i.e. a struct-typed column, to store the evm encryption info. You create them like so (first format), and use them from Go via
pgtype.CompositeFields
like so. The downside is that we're adding a little complexity to the DB interface/structure/usage. -
Same as number 2, but with JSON instead of composite types. Pretty yuck and space-hungry. I prefer the train over this.
I started off favoring 2, but I'm now more in favor of the denormalized variant of 1.
Note on performance of 1 vs 2: Bulky table rows hurt performance; first in gradual ways (because of page size and disk caches), then at 8kB per row abruptly, because postgres stores rows over 8kB in a TOAST table, so every row lookup performs an implicit JOIN. This would imply 2 is faster, because we JOIN only explicitly, and only for single-tx results. However my understanding of TOAST is that only bulky columns are moved to the overflow (= TOAST) table, so with some luck, our composite type and the existing body
type would be the ones to get moved, which should result in about the same performance as 1 if we only SELECT those columns for single-tx results.
analyzer/runtime/extract.go
Outdated
EVMEncryptedPublicKey *[]byte | ||
EVMEncryptedDataNonce *[]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we able to decode the format/nonces/publickey into a more concrete type here? Or can it vary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format is CallFormat from the sdk. it's an enum
in x25519 (callformat 1), the public key and nonce are specific length byte arrays, which I'm sure the cryptosystem is happy to keep opaque on the outside
8ff1eef
to
f9c0338
Compare
f9c0338
to
b4f4a80
Compare
Co-authored-by: mitjat <mitjat@users.noreply.github.com>
daa75c0
to
27f74fd
Compare
alright, if you really want to look 馃し
no api
philosophy: