Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
chore: remove unnecessary TODOs from api, update TODOs with issue num…
Browse files Browse the repository at this point in the history
…bers (#3472)
  • Loading branch information
tenthirtyone committed Aug 15, 2022
1 parent 1592b1d commit 2cdf9bd
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/chains/ethereum/ethereum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export default class EthereumApi implements Api {
async evm_setAccountNonce(address: DATA, nonce: QUANTITY) {
// TODO: the effect of this function could happen during a block mine operation, which would cause all sorts of
// issues. We need to figure out a good way of timing this.
// Issue: https://github.com/trufflesuite/ganache/issues/1646
const buffer = Address.from(address).toBuffer();
const blockchain = this.#blockchain;
const stateManager = blockchain.vm.stateManager;
Expand Down Expand Up @@ -391,6 +392,7 @@ export default class EthereumApi implements Api {
async evm_setAccountBalance(address: DATA, balance: QUANTITY) {
// TODO: the effect of this function could happen during a block mine operation, which would cause all sorts of
// issues. We need to figure out a good way of timing this.
// Issue: https://github.com/trufflesuite/ganache/issues/1646
const buffer = Address.from(address).toBuffer();
const blockchain = this.#blockchain;
const stateManager = blockchain.vm.stateManager;
Expand Down Expand Up @@ -429,6 +431,7 @@ export default class EthereumApi implements Api {
async evm_setAccountCode(address: DATA, code: DATA) {
// TODO: the effect of this function could happen during a block mine operation, which would cause all sorts of
// issues. We need to figure out a good way of timing this.
// Issue: https://github.com/trufflesuite/ganache/issues/1646
const addressBuffer = Address.from(address).toBuffer();
const codeBuffer = Data.toBuffer(code);
const blockchain = this.#blockchain;
Expand Down Expand Up @@ -477,6 +480,7 @@ export default class EthereumApi implements Api {
async evm_setAccountStorageAt(address: DATA, slot: DATA, value: DATA) {
// TODO: the effect of this function could happen during a block mine operation, which would cause all sorts of
// issues. We need to figure out a good way of timing this.
// Issue: https://github.com/trufflesuite/ganache/issues/1646
const addressBuffer = Address.from(address).toBuffer();
const slotBuffer = Data.toBuffer(slot);
const valueBuffer = Data.toBuffer(value);
Expand Down Expand Up @@ -866,7 +870,6 @@ export default class EthereumApi implements Api {

//#region eth

// TODO: example doesn't return correct value
/**
* Generates and returns an estimate of how much gas is necessary to allow the
* transaction to complete. The transaction will not be added to the
Expand Down Expand Up @@ -2939,6 +2942,7 @@ export default class EthereumApi implements Api {
}

// TODO: example doesn't return correct value
// Issue: https://github.com/trufflesuite/ganache/issues/3203
/**
* Attempts to replay the transaction as it was executed on the network and
* return storage data given a starting key and max number of entries to return.
Expand Down Expand Up @@ -3014,7 +3018,6 @@ export default class EthereumApi implements Api {
return this.#wallet.addresses;
}

// TODO: example doesn't return correct value
/**
* Generates a new account with private key. Returns the address of the new
* account.
Expand Down Expand Up @@ -3093,7 +3096,6 @@ export default class EthereumApi implements Api {
return this.#wallet.lockAccount(address.toLowerCase());
}

// TODO: example doesn't return correct value
/**
* Unlocks the account for use.
*
Expand Down
1 change: 1 addition & 0 deletions src/chains/ethereum/ethereum/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ export default class Blockchain extends Emittery<BlockchainTypedEvents> {
// TODO: gas could go theoretically go over Number.MAX_SAFE_INTEGER.
// (Ganache v2 didn't handle this possibility either, so it hasn't been
// updated yet)
// Issue: https://github.com/trufflesuite/ganache/issues/3473
let gas = 0;
const structLogs: Array<StructLog> = [];
const TraceData = TraceDataFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default class BlockManager extends Manager<Block> {
async getRawByBlockNumber(blockNumber: Quantity): Promise<Buffer> {
// TODO(perf): make the block's raw fields accessible on latest/earliest/pending so
// we don't have to fetch them from the db each time a block tag is used.
// Issue: https://github.com/trufflesuite/ganache/issues/3481
const fallback = this.#blockchain.fallback;
const numBuf = blockNumber.toBuffer();
return this.getRaw(numBuf).then(block => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class BlockLogManager extends Manager<BlockLogs> {
blockLogsRange.forEach(blockLogs => {
// TODO(perf): this loops over all addresses for every block.
// Maybe make it loop only once?
// Issue: https://github.com/trufflesuite/ganache/issues/3482
if (blockLogs)
filteredBlockLogs.push(...blockLogs.filter(addresses, topics));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EthereumInternalOptions } from "@ganache/ethereum-options";
import { JsonRpcResponse, JsonRpcError } from "@ganache/utils";
import { AbortError } from "@ganache/ethereum-utils";
// TODO: support http2
// Issue: https://github.com/trufflesuite/ganache/issues/3474
import http, { RequestOptions, Agent as HttpAgent } from "http";
import https, { Agent as HttpsAgent } from "https";
import { AbortSignal } from "abort-controller";
Expand Down Expand Up @@ -138,6 +139,7 @@ export class HttpHandler extends BaseHandler implements Handler {
}

// TODO: handle invalid JSON (throws on parse)?
// Issue: https://github.com/trufflesuite/ganache/issues/3475
buffer.then(buffer => {
try {
deferred.resolve({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class WsHandler extends BaseHandler implements Handler {
this.open = this.connect(this.connection, logging);
this.connection.onclose = () => {
// try to connect again...
// Issue: https://github.com/trufflesuite/ganache/issues/3476
// TODO: backoff and eventually fail
// Issue: https://github.com/trufflesuite/ganache/issues/3477
this.open = this.connect(this.connection, logging);
};
this.abortSignal.addEventListener("abort", () => {
Expand Down Expand Up @@ -76,6 +78,7 @@ export class WsHandler extends BaseHandler implements Handler {
}>();

// TODO: timeout an in-flight request after some amount of time
// Issue: https://github.com/trufflesuite/ganache/issues/3478
this.inFlightRequests.set(messageId, deferred);

this.connection.send(`${JSONRPC_PREFIX}${messageId},${key.slice(1)}`);
Expand All @@ -92,6 +95,7 @@ export class WsHandler extends BaseHandler implements Handler {
const raw = event.data as Buffer;

// TODO: handle invalid JSON (throws on parse)?
// Issue: https://github.com/trufflesuite/ganache/issues/3479
const response = JSON.parse(raw) as JsonRpcResponse | JsonRpcError;
const id = response.id;
const prom = this.inFlightRequests.get(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class PersistentCache {

// TODO(perf): we always re-save the targetBlock but could optimize to only
// resave if it is needed.
// Issue: https://github.com/trufflesuite/ganache/issues/3485
atomicBatch.put(targetBlock.key, targetBlock.serialize());

await atomicBatch.write();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { AbortSignal } from "abort-controller";
import Semaphore from "semaphore";
import { LimitCounter } from "./limit-counter";

type PromiseFn<T> = (
...args: unknown[]
) => Promise<{
type PromiseFn<T> = (...args: unknown[]) => Promise<{
response: { result: any } | { error: { message: string; code: number } };
raw: T;
}>;
Expand Down Expand Up @@ -234,6 +232,7 @@ export default class RateLimiter {
// a LIMIT_EXCEEDED error behave, otherwise we'll just send ALL
// requests back to Infura simultaneously after their initial 30
// backoff_seconds have elapsed.
// Issue: https://github.com/trufflesuite/ganache/issues/3480
//
// When we are *not* self-rate limited (meaning fork.rps isn't set)
// we need to be able to go at full speed until we are, and THEN we
Expand Down
2 changes: 2 additions & 0 deletions src/chains/ethereum/ethereum/src/forking/trie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class ForkTrie extends GanacheTrie {
// checking the database itself
// TODO(perf): there is probably a better/faster way of doing this for the
// common case.
// Issue: https://github.com/trufflesuite/ganache/issues/3483
const checkpoints = this.metadata.checkpoints;
for (let i = checkpoints.length - 1; i >= 0; i--) {
for (let [encodedKeyStr, value] of checkpoints[i].keyValueMap.entries()) {
Expand All @@ -137,6 +138,7 @@ export class ForkTrie extends GanacheTrie {
// TODO(perf): this is just going to be slow once we get lots of keys
// because it just checks every single key we've ever deleted (before this
// one).
// Issue: https://github.com/trufflesuite/ganache/issues/3484
const stream = this.metadata._leveldb.createReadStream({
lte: this.createDelKey(key),
reverse: true
Expand Down
1 change: 1 addition & 0 deletions src/chains/ethereum/transaction/src/base-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const calculateIntrinsicGas = (
// Make sure we don't exceed uint64 for all data combinations.
// TODO: make sure these upper-bound checks are safe to remove, then
// remove if so.
// Issue: https://github.com/trufflesuite/ganache/issues/3486
// NOTE: This is an upper-bounds limit ported from geth that doesn't
// make sense for Ethereum, as exceeding the upper bound would require
// something like 200+ Petabytes of data.
Expand Down
1 change: 1 addition & 0 deletions src/chains/ethereum/transaction/src/transaction-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class TransactionFactory {
} else {
// TODO: I believe this is unreachable with current architecture.
// If 2718 is supported, so is 2930.
// Issue: https://github.com/trufflesuite/ganache/issues/3487
throw new CodedError(
`EIP 2930 is not activated.`,
JsonRpcErrorCode.INVALID_PARAMS
Expand Down
1 change: 1 addition & 0 deletions src/packages/core/tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ describe("server", () => {
});

// TODO: actually handle backpressure!
// Issue: https://github.com/trufflesuite/ganache/issues/2790
it.skip("can handle backpressure", async () => {
{
// create tons of data to force websocket backpressure
Expand Down

0 comments on commit 2cdf9bd

Please sign in to comment.