Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
cf1c093
create debug storage contract for testing
eshaben Jan 26, 2021
cce0f48
add initial debug_storageRangeAt entry point to api
eshaben Jan 26, 2021
5af3f4f
create initial test
eshaben Jan 26, 2021
b6fa4b0
add debug_traceTransaction logic so we can recompute txs
eshaben Jan 26, 2021
2299c0f
use contract address to set state root
eshaben Jan 26, 2021
c1318ac
use startKey and maxResult to iterate over storage entries
eshaben Jan 26, 2021
57c8940
oops remove left over comment
eshaben Jan 26, 2021
0c3caef
get nextKey and format return data correctly
eshaben Jan 26, 2021
a118a50
return result and update test assertions
eshaben Jan 26, 2021
10a9b39
add more tests
eshaben Jan 26, 2021
61eeed6
add keccak hash key to storage output
eshaben Jan 28, 2021
7ab7c86
remove irrelevant logic
eshaben Feb 9, 2021
522672d
create an in memory map for storage keys and write it to block
eshaben Feb 9, 2021
14b462e
fill in memory storage map with raw and hashed version of storage keys
eshaben Feb 9, 2021
abdff2e
create storageKeys db
eshaben Feb 9, 2021
cf5d306
save storage keys to the database one at a time
eshaben Feb 9, 2021
49eed1d
remove irrelevant comment
eshaben Feb 9, 2021
d142bbf
create function to get storage keys
eshaben Feb 9, 2021
b7939c5
fix tests
eshaben Feb 9, 2021
1b8b8d6
check if the startKey matches any of the keys from the trie stream
eshaben Feb 9, 2021
d014318
try hashing the startKey and seeing if the hashed key matches any of …
eshaben Feb 9, 2021
9fbd8b9
handle arbitrary hexadecimal strings as startKeys
eshaben Feb 9, 2021
6bf68a2
add complex storage for additional testing
eshaben Feb 11, 2021
9aeb4f6
sort keys and filter by start key to get storage results
eshaben Feb 11, 2021
574649a
fix conditional as we want to include keys that are the same
eshaben Feb 11, 2021
e35a7ca
add debug complex storage tests
eshaben Feb 11, 2021
f0aec98
remove .only flag on tests
eshaben Feb 11, 2021
49f6915
remove duplicate traceTransaction code
eshaben Feb 11, 2021
2467308
update comments for storageRangeAt
eshaben Feb 11, 2021
c699f6f
update fn name
eshaben Feb 11, 2021
46b1d79
add typings
eshaben Feb 11, 2021
01e6f7f
remove extra describe block
eshaben Feb 11, 2021
2c785f7
fix spacing
eshaben Feb 11, 2021
b774179
update comments
eshaben Feb 11, 2021
aaad871
add api annotation
eshaben Feb 11, 2021
b5bba2f
throw error if we can't find the address in the trie
eshaben Feb 17, 2021
f4ee6d7
super messy but transaction indexes now work
eshaben Feb 18, 2021
99ee6eb
clean up test for transaction indexes
eshaben Feb 18, 2021
d52b5bf
remove comments
eshaben Feb 18, 2021
d37a8a4
clean up comments
eshaben Feb 18, 2021
02e5654
the rawKey shouldn't need to be padded
eshaben Feb 18, 2021
b6b14ef
wip
eshaben Feb 19, 2021
c40ac9d
add descriptions to parameters
eshaben Feb 23, 2021
b24b558
fix typo
eshaben Feb 23, 2021
0abc80b
remove unused import
eshaben Feb 23, 2021
166db81
update comment for accuracy
eshaben Feb 23, 2021
e90dd00
remove unnecessary async keyword
eshaben Feb 23, 2021
9b516b6
update keys declaration
eshaben Feb 23, 2021
3e9ae3c
remove unnecessary try/catch
eshaben Feb 23, 2021
ca4124e
clean up test
eshaben Feb 23, 2021
2c5e1b3
create reusable getFromTrie function
eshaben Feb 25, 2021
c062285
create internal traceTransaction function
eshaben Feb 25, 2021
045074f
remove .only
eshaben Feb 25, 2021
21b9e03
pass storageKeys to runtimeBlock.finalize
eshaben Feb 25, 2021
760e8ba
move StepEvent type to utils
eshaben Feb 25, 2021
733d314
use assert.rejects in test
eshaben Feb 25, 2021
2f970bb
wrap test in snapshot and revert
eshaben Feb 25, 2021
ea431f5
use Promise.all in test
eshaben Feb 25, 2021
0c71c3b
update storageKeys key to be a string instead of a buffer
eshaben Feb 25, 2021
3d21b85
remove .only on test
eshaben Feb 25, 2021
468c623
update error message for tx index out of range
eshaben Feb 25, 2021
a6187d7
create test for transaction index out of range
eshaben Feb 25, 2021
62ad4f1
remove unnecessary async keyword
eshaben Feb 25, 2021
726bfa8
update comments
eshaben Feb 25, 2021
487c80f
fix typing of keys array
eshaben Feb 25, 2021
b5cc898
throw error instead of console.log it
eshaben Feb 25, 2021
d9966c4
remove unneccessary for loop
eshaben Feb 25, 2021
20ab776
clean up promises
eshaben Feb 25, 2021
c383f1c
update keccak import
eshaben Feb 26, 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
Prev Previous commit
Next Next commit
move StepEvent type to utils
  • Loading branch information
eshaben committed Feb 25, 2021
commit 760e8ba9adef54410a0b51dbf401ea175790ff8c
15 changes: 2 additions & 13 deletions src/chains/ethereum/ethereum/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
TraceStorageMap,
RuntimeError,
RETURN_TYPES,
Snapshots
Snapshots,
StepEvent
} from "@ganache/ethereum-utils";
import TransactionManager from "./data-managers/transaction-manager";
import SecureTrie from "merkle-patricia-tree/secure";
Expand Down Expand Up @@ -881,18 +882,6 @@ export default class Blockchain extends Emittery.Typed<
const structLogs: Array<StructLog> = [];
const TraceData = TraceDataFactory();

type StepEvent = {
gasLeft: BN;
memory: Array<number>; // Not officially sure the type. Not a buffer or uint8array
stack: Array<BN>;
depth: number;
opcode: {
name: string;
};
pc: number;
address: Buffer;
};

const stepListener = (
event: StepEvent,
next: (error?: any, cb?: any) => void
Expand Down
16 changes: 2 additions & 14 deletions src/chains/ethereum/ethereum/src/miner/miner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
RETURN_TYPES,
Executables,
ITraceData,
TraceDataFactory
TraceDataFactory,
StepEvent
} from "@ganache/ethereum-utils";
import { utils, Quantity, Data } from "@ganache/utils";
import { promisify } from "util";
Expand All @@ -17,7 +18,6 @@ import VM from "ethereumjs-vm";
import { encode as rlpEncode } from "rlp";
import { EthereumInternalOptions } from "@ganache/ethereum-options";
import replaceFromHeap from "./replace-from-heap";
import { BN } from "ethereumjs-util";
import { keccak } from "@ganache/utils/src/utils/keccak";
const { BUFFER_EMPTY, BUFFER_256_ZERO } = utils;

Expand Down Expand Up @@ -221,18 +221,6 @@ export default class Miner extends Emittery.Typed<
// vm's "live" trie.
await this.#checkpoint();

type StepEvent = {
gasLeft: BN;
memory: Array<number>; // Not officially sure the type. Not a buffer or uint8array
stack: Array<BN>;
depth: number;
opcode: {
name: string;
};
pc: number;
address: Buffer;
};

const TraceData = TraceDataFactory();
// We need to listen for any SSTORE opcodes so we can grab the raw, unhashed version
// of the storage key and save it to the db along with it's keccak hashed version of
Expand Down
1 change: 1 addition & 0 deletions src/chains/ethereum/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export * from "./types/extract-values-from-types";
export * from "./types/filters";
export * from "./types/shh";
export * from "./types/snapshots";
export * from "./types/step-event";
export * from "./types/subscriptions";
export * from "./types/tuple-from-union";
13 changes: 13 additions & 0 deletions src/chains/ethereum/utils/src/types/step-event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BN } from "ethereumjs-util";

export type StepEvent = {
gasLeft: BN;
memory: Array<number>; // Not officially sure the type. Not a buffer or uint8array
stack: Array<BN>;
depth: number;
opcode: {
name: string;
};
pc: number;
address: Buffer;
};