-
Notifications
You must be signed in to change notification settings - Fork 39
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix personal transactions RPC request #1923
Changes from 9 commits
aa2e42b
29e5ec2
09306f7
b34d032
8e04401
48db22e
1360547
e92de20
1050bd7
7e6c1c9
c05cafc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package common | ||
|
||
import "github.com/ethereum/go-ethereum/common" | ||
|
||
// CustomQueries are Ten-specific queries that are not supported by the Ethereum RPC API but that we wish to support | ||
// through the same interface. | ||
// | ||
// We currently use the eth_getStorageAt method to route these queries through the Ethereum RPC API. | ||
// | ||
// In order to match the eth_getStorageAt method signature, we require that all custom queries use an incrementing "address" | ||
// to specify the method we are calling (e.g. 0x000...001 is getUserID, 0x000...002 is listPrivateTransactions). | ||
// | ||
// The signature is: eth_getStorageAt(method, params, nil) where: | ||
// - method is the address of the custom query as an address (e.g. 0x000...001) | ||
// - params is a JSON string with the parameters for the query (this complies with the eth_getStorageAt method signature since position gets encoded as a hex string) | ||
// | ||
// NOTE: Private custom queries must also include "address" as a top-level field in the params json object to indicate | ||
// the account the query is being made for. | ||
|
||
// CustomQuery methods | ||
const ( | ||
UserIDRequestCQMethod = "0x0000000000000000000000000000000000000001" | ||
ListPrivateTransactionsCQMethod = "0x0000000000000000000000000000000000000002" | ||
) | ||
|
||
type ListPrivateTransactionsQueryParams struct { | ||
Address common.Address `json:"address"` | ||
Pagination QueryPagination `json:"pagination"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,11 +428,14 @@ func BatchWasExecuted(ctx context.Context, db *sql.DB, hash common.L2BatchHash) | |
} | ||
|
||
func GetTransactionsPerAddress(ctx context.Context, db *sql.DB, config *params.ChainConfig, address *gethcommon.Address, pagination *common.QueryPagination) (types.Receipts, error) { | ||
return selectReceipts(ctx, db, config, "where tx.sender_address = ? ORDER BY height DESC LIMIT ? OFFSET ? ", address.Bytes(), pagination.Size, pagination.Offset) | ||
return selectReceipts(ctx, db, config, "join externally_owned_account eoa on tx.sender_address = eoa.id where eoa.address = ? ORDER BY height DESC LIMIT ? OFFSET ? ", address.Bytes(), pagination.Size, pagination.Offset) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops. I forgot to change these |
||
} | ||
|
||
func CountTransactionsPerAddress(ctx context.Context, db *sql.DB, address *gethcommon.Address) (uint64, error) { | ||
row := db.QueryRowContext(ctx, "select count(1) from receipt join tx on tx.id=receipt.tx join batch on batch.sequence=receipt.batch "+" where tx.sender_address = ?", address.Bytes()) | ||
row := db.QueryRowContext(ctx, "select count(1) from receipt "+ | ||
"join tx on tx.id=receipt.tx "+ | ||
"join externally_owned_account eoa on eoa.id = tx.sender_address "+ | ||
"where eoa.address = ?", address.Bytes()) | ||
|
||
var count uint64 | ||
err := row.Scan(&count) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,8 @@ func DevTestnet(opts ...TestnetEnvOption) networktest.Environment { | |
// LongRunningLocalNetwork is a local network, the l1WSURL is optional (can be empty string), only required if testing L1 interactions | ||
func LongRunningLocalNetwork(l1WSURL string) networktest.Environment { | ||
connector := newTestnetConnectorWithFaucetAccount( | ||
"ws://127.0.0.1:26900", | ||
[]string{"ws://127.0.0.1:26901"}, | ||
"ws://127.0.0.1:17900", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the correct ports now. |
||
[]string{"ws://127.0.0.1:17901"}, | ||
genesis.TestnetPrefundedPK, | ||
l1WSURL, | ||
"", | ||
|
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.
what's the difference between this and
privateCustomQuery.Address
?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.
Nothing, but we don't have a privateCustomQuery in this
Execute
method, privateCustomQuery got set on the builder asbuilder.Param
in theValidate
method.Yeah this feels a little weird, but will tidy it up when we get rid of 'CustomQuery' from enclave, it will just be a 'GetPersonalTransactions' method and won't be trying to do anything generic.
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.
then let's add a check that they are equal. To avoid any security hole