Skip to content
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

Support non-standard RPC methods for indexing services #123

Closed
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
992702d
eth_getTransactionsByBlockNumber and eth_getTransactionReceiptsByBloc…
rahul10puchd Nov 11, 2021
b897e04
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 11, 2021
51a620d
Bog fix for eth_getTransactionsByBlockNumber
rahul10puchd Nov 18, 2021
d3d4ea3
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 18, 2021
9cff011
update lib
rahul10puchd Nov 18, 2021
a7efcc3
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 19, 2021
6b5df19
lint fix
rahul10puchd Nov 19, 2021
65eccec
comments removed
rahul10puchd Dec 3, 2021
f77037f
added eth_getTransactionReceiptsByBlockNumber sql function and callin…
rahul10puchd Dec 3, 2021
4a0466c
added eth_getTransactionsByBlockNumber sql function and calling it fr…
rahul10puchd Dec 7, 2021
1f88776
sorted non-standard methods in alphabetical order and updated query f…
rahul10puchd Dec 9, 2021
bec099b
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Dec 9, 2021
13235bf
code formating
rahul10puchd Dec 9, 2021
936d30a
identation fixing
rahul10puchd Dec 9, 2021
a6d67a1
Merge branch 'master' of https://github.com/aurora-is-near/aurora-rel…
0x3bfc Dec 20, 2021
894d002
minor lint fixes
0x3bfc Dec 21, 2021
32424c4
return set of transaction receipts and transaction results
0x3bfc Dec 21, 2021
54282a3
Merge branch 'master' of https://github.com/aurora-is-near/aurora-rel…
0x3bfc Dec 21, 2021
2749281
revert to the old timestamp def in eth_geBlockByNumber.sql
0x3bfc Dec 21, 2021
0ee999e
Merge branch 'master' into covalentMethods
0x3bfc Dec 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion etc/methods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,18 @@ eth_getTransactionByBlockNumberAndIndex:
implementations:
- etc/schema/functions/eth_getTransactionByBlockNumberAndIndex.sql
- src/servers/skeleton.ts

eth_getTransactionsByBlockNumber:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
status: ok
comment:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
link:
implementations:
- src/servers/skeleton.ts
eth_getTransactionReceiptsByBlockNumber:
status: ok
comment:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
link:
implementations:
- src/servers/skeleton.ts
eth_getTransactionByHash:
status: wip
comment:
Expand Down
2 changes: 2 additions & 0 deletions lib/servers/database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export declare class DatabaseServer extends SkeletonServer {
eth_getLogs(_request: Request, filter: web3.FilterOptions): Promise<web3.LogObject[]>;
eth_getStorageAt(_request: Request, address: web3.Data, key: web3.Quantity, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Data>;
eth_getTransactionByBlockHashAndIndex(_request: Request, blockHash: web3.Data, transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionResult | null>;
eth_getTransactionByBlockNumberAndIndex(_request: Request, blockNumber: web3.Quantity | web3.Tag, transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionByHash(_request: Request, transactionHash: web3.Data): Promise<web3.TransactionResult | null>;
eth_getTransactionCount(_request: Request, address: web3.Data, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity>;
eth_getTransactionReceipt(_request: Request, transactionHash: string): Promise<web3.TransactionReceipt | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionReceipt[] | null>;
eth_getUncleCountByBlockHash(_request: Request, blockHash: web3.Data): Promise<web3.Quantity | null>;
eth_getUncleCountByBlockNumber(_request: Request, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity | null>;
eth_newBlockFilter(_request: Request): Promise<web3.Quantity>;
Expand Down
68 changes: 68 additions & 0 deletions lib/servers/database.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/servers/skeleton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export declare abstract class SkeletonServer implements web3.Service {
eth_getStorageAt(_request: Request, _address: web3.Data, _key: web3.Quantity, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.Data>;
eth_getTransactionByBlockHashAndIndex(_request: Request, _blockHash: web3.Data, _transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionByBlockNumberAndIndex(_request: Request, _blockNumber: web3.Quantity | web3.Tag, _transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionReceipt[] | null>;
eth_getTransactionByHash(_request: Request, _transactionHash: web3.Data): Promise<web3.TransactionResult | null>;
eth_getTransactionCount(_request: Request, _address: web3.Data, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity>;
eth_getTransactionReceipt(_request: Request, _transactionHash: string): Promise<web3.TransactionReceipt | null>;
Expand Down
8 changes: 8 additions & 0 deletions lib/servers/skeleton.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/web3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export interface Service {
eth_getProof(_request: Request, address: Data, keys: Data[], blockNumber: Quantity | Tag): Promise<ProofResult>;
eth_getStorageAt(_request: Request, address: Data, key: Quantity, blockNumber: Quantity | Tag): Promise<Data>;
eth_getTransactionByBlockHashAndIndex(_request: Request, blockHash: Data, transactionIndex: Quantity): Promise<TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, blockNumber: Quantity | Tag): Promise<TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, blockNumber: Quantity | Tag): Promise<TransactionReceipt[] | null>;
eth_getTransactionByBlockNumberAndIndex(_request: Request, blockNumber: Quantity | Tag, transactionIndex: Quantity): Promise<TransactionResult | null>;
eth_getTransactionByHash(_request: Request, transactionHash: Data): Promise<TransactionResult | null>;
eth_getTransactionCount(_request: Request, address: Data, blockNumber: Quantity | Tag): Promise<Quantity>;
Expand Down
85 changes: 83 additions & 2 deletions src/servers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,46 @@ export class DatabaseServer extends SkeletonServer {
return null;
}
}

async eth_getTransactionsByBlockNumber(
_request: any,
blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionResult | null> {
const blockNumber_ = parseBlockSpec(blockNumber) != 0
? parseBlockSpec(blockNumber) || (await this._fetchCurrentBlockID())
: parseBlockSpec(blockNumber);

try {
const {
rows,
} = await this._query(
`SELECT
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
b.id AS "blockNumber",
b.hash AS "blockHash",
t.index AS "transactionIndex",
t.hash AS "hash",
t.from AS "from",
t.to AS "to",
t.gas_limit AS "gas",
t.gas_price AS "gasPrice",
t.nonce AS "nonce",
t.value AS "value",
coalesce(t.input, '\\x'::bytea) AS "input",
t.v AS "v",
t.r AS "r",
t.s AS "s"
FROM transaction t
LEFT JOIN block b ON t.block = b.id
WHERE b.id = $1`,
[blockNumber_]
);
return !rows || !rows.length ? null : exportJSON(rows);
} catch (error) {
if (this.config.debug) {
console.debug('eth_getTransactionsByBlockNumber', error);
}
return null;
}
}
async eth_getTransactionByBlockNumberAndIndex(
_request: Request,
blockNumber: web3.Quantity | web3.Tag,
Expand Down Expand Up @@ -557,7 +596,49 @@ export class DatabaseServer extends SkeletonServer {
return null;
}
}

async eth_getTransactionReceiptsByBlockNumber(
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
_request: any,
blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionReceipt[] | null> {
const blockNumber_ = parseBlockSpec(blockNumber) != 0
? parseBlockSpec(blockNumber) || (await this._fetchCurrentBlockID())
: parseBlockSpec(blockNumber);
try {
const {
rows,
} = await this._query(
`SELECT
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
b.id AS "blockNumber",
b.hash AS "blockHash",
t.index AS "transactionIndex",
t.hash AS "transactionHash",
t.from AS "from",
t.to AS "to",
t.gas_used AS "gasUsed",
0::u256 AS "cumulativeGasUsed", -- TODO: tally?
CASE WHEN t.to IS NULL OR t.to = '\\x0000000000000000000000000000000000000000' THEN t.output
ELSE NULL
END AS "contractAddress",
NULL AS "logs", -- TODO: fetch event.id[]
repeat('\\000', 256)::bytea AS "logsBloom",
CASE WHEN t.status THEN 1 ELSE 0 END AS "status"
FROM transaction t
LEFT JOIN block b ON t.block = b.id
WHERE b.id = $1`,
[blockNumber_]
);
//assert(receipt, 'receipt is not null');
for(let i = 0;i<rows.length;i++){
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
rows[i].logs = await this._fetchEvents(hexToBytes(rows[i].transactionHash.toString()));
}
return exportJSON(rows);
} catch (error) {
if (this.config.debug) {
console.debug('eth_getTransactionReceiptsByBlockNumber', error);
}
return null;
}
}
async eth_getUncleCountByBlockHash(
_request: Request,
blockHash: web3.Data
Expand Down
15 changes: 14 additions & 1 deletion src/servers/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,20 @@ export abstract class SkeletonServer implements web3.Service {
unimplemented('eth_getTransactionByBlockNumberAndIndex');
return null;
}

async eth_getTransactionsByBlockNumber(
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
_request: any,
_blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionResult | null> {
unimplemented('eth_getTransactionsByBlockNumber');
return null;
}
async eth_getTransactionReceiptsByBlockNumber(
_request: any,
_blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionReceipt[] | null> {
unimplemented('eth_getTransactionReceiptsByBlockNumber');
return null;
}
async eth_getTransactionByHash(
_request: Request,
_transactionHash: web3.Data
Expand Down
8 changes: 8 additions & 0 deletions src/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export interface Service {
blockHash: Data,
transactionIndex: Quantity
): Promise<TransactionResult | null>;
eth_getTransactionsByBlockNumber(
_request: any,
blockNumber: Quantity | Tag,
): Promise<TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(
_request: any,
blockNumber: Quantity | Tag,
): Promise<TransactionReceipt[] | null>;
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
eth_getTransactionByBlockNumberAndIndex(
_request: Request,
blockNumber: Quantity | Tag,
Expand Down