Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core-utils: add GenesisJsonProvider and fix tests
The `GenesisJsonProvider` implements the `ethers.Provider` interface and is constructed with a geth genesis file, either as an object or as a file to be read from disk. It implements a subset of the RPC methods that use the genesis file as the backing storage. It includes tests for its correctness. Not all methods are implemented, just the ones for the regenesis testing. This PR also moves the tests around in the `core-utils` package as some of the tests were being skipped. The `tests` directory is flattened, having so many subdirectories was not needed. The `package.json` test script is updated to ensure that all tests are run. Also add some deps that are required for the `GenesisJsonProvider`.
- Loading branch information
Showing
14 changed files
with
440 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@eth-optimism/core-utils': patch | ||
--- | ||
|
||
Add GenesisJsonProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Optimism PBC 2021 | ||
|
||
// Represents the ethereum state | ||
export interface State { | ||
[address: string]: { | ||
nonce: number | ||
balance: string | ||
codeHash: string | ||
root: string | ||
code?: string | ||
storage?: { | ||
[key: string]: string | ||
} | ||
} | ||
} | ||
|
||
// Represents a genesis file that geth can consume | ||
export interface Genesis { | ||
config: { | ||
chainId: number | ||
homesteadBlock: number | ||
eip150Block: number | ||
eip155Block: number | ||
eip158Block: number | ||
byzantiumBlock: number | ||
constantinopleBlock: number | ||
petersburgBlock: number | ||
istanbulBlock: number | ||
muirGlacierBlock: number | ||
clique: { | ||
period: number | ||
epoch: number | ||
} | ||
} | ||
difficulty: string | ||
gasLimit: string | ||
extraData: string | ||
alloc: State | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/core-utils/test/fees/fees.spec.ts → packages/core-utils/test/fees.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/core-utils/test/common/misc.spec.ts → packages/core-utils/test/misc.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.