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

feat: add filecoin to CLI, Filecoin.ChainNotify method, and Filecoin support for websockets/subscriptions #768

Merged
merged 78 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
902b5e2
get filecoin cli working
mikeseese Jan 12, 2021
21b8487
make sure deterministic wallet option comes before seed
mikeseese Jan 12, 2021
99789c5
add option to change the rpc endpoint to support filecoin
mikeseese Jan 12, 2021
dd81c95
update to use cliDescription instead of shortDescription
mikeseese Jan 16, 2021
0f7e4b1
set rpcEndpoint default in the definition instead of CLI args.ts
mikeseese Jan 18, 2021
154d72f
set the default logger to console (as stated in docs)
mikeseese Jan 12, 2021
2531d26
disable logging in filecoin tests
mikeseese Jan 15, 2021
c94d41a
apply changes from code review
mikeseese Jan 20, 2021
1fe428e
change default description of rpcEndpoint
mikeseese Jan 20, 2021
a6b6932
fix blocktime after removing automine option
mikeseese Jan 21, 2021
8e28d54
disable logging in blockchain tests
mikeseese Jan 21, 2021
376f008
fix blocktime to be seconds instead of milliseconds
mikeseese Jan 21, 2021
b5aaa28
add colors to tests! 🎨
mikeseese Jan 21, 2021
69a0306
fix non-filecoin tests affected by filecoin
mikeseese Jan 21, 2021
f473b95
reorganize provider option types
mikeseese Jan 19, 2021
05ad5fc
rename FilecoinApi's blockchain member to be consistent with ethereum
mikeseese Jan 12, 2021
f776edc
break up api tests
mikeseese Jan 21, 2021
bc21428
update lotus schema
mikeseese Jan 21, 2021
ff1a44a
add test to check that we report invalid method for unimplemented met…
mikeseese Jan 21, 2021
d1dc627
ensure Filecoin prefixed api calls are all valid api methods
mikeseese Jan 21, 2021
77e9e95
add test for Ganache.MineTipset method
mikeseese Jan 21, 2021
ca3d1de
support peer dependency for @ganache/filecoin due to node@12 requirement
mikeseese Jan 23, 2021
c02ab7d
remove requirement that packages need a tsconfig.json
mikeseese Jan 23, 2021
3c0653a
revert link-ts-references and add do-nothing tsconfig to filecoin-types
mikeseese Jan 23, 2021
3ee8d95
manually create symlink to @ganache/filecoin for peerDep
mikeseese Jan 25, 2021
61478f5
prevent failure of removing link if it doesnt exist
mikeseese Jan 25, 2021
0fb0a2b
add tsc script for @ganache/filecoin-types to be able to build
mikeseese Jan 26, 2021
96d6c58
make sure we don't swallow other errors
mikeseese Jan 27, 2021
1bef240
change cli ETH label to FIL
mikeseese Jan 27, 2021
923fd72
update filecoin scripts to use lerna ts scripts
mikeseese Jan 29, 2021
97b571c
rename tsconfig file
mikeseese Feb 4, 2021
9261159
add filecoin declarations script to root and add cleaning command
mikeseese Feb 4, 2021
f23fc2e
filecoin blocks should have their height set to the tipset height
mikeseese Jan 12, 2021
cd5c4df
enable websockets/subscriptions for filecoin
mikeseese Jan 12, 2021
bfda36b
implement Filecoin.ChainNotify method
mikeseese Jan 12, 2021
be6d1de
implement initial unsubscribe from ChainNotify
mikeseese Jan 12, 2021
e787a0e
add ChainHead height assertions to test
mikeseese Jan 21, 2021
0a7d444
add chainnotify tests
mikeseese Jan 21, 2021
d6abe4a
fix filecoin subscriptions over websockets
mikeseese Jan 22, 2021
a60df37
initial verification of genesis block
mikeseese Jan 22, 2021
d49fea8
fix Filecoin.WalletBalance to have correct denominations
mikeseese Jan 13, 2021
4dadf53
remove redundant BigInt constructor
mikeseese Jan 20, 2021
e4f9561
update filecoin interface types
mikeseese Jan 15, 2021
5ee069f
add missing fields from DealInfo
mikeseese Jan 15, 2021
1371cd5
fix retrieval peer to have correct pieceCID type
mikeseese Jan 22, 2021
9e95c57
fix tests to support changes in types
mikeseese Jan 22, 2021
1178d22
implement genesis block vrfproof
mikeseese Jan 22, 2021
eb22f04
change other byte[] types to Buffers
mikeseese Jan 22, 2021
13cd4e9
fix tests affected by byte[] changes
mikeseese Jan 22, 2021
5d1fe8a
fix timestamp to be seconds instead of milliseconds
mikeseese Jan 23, 2021
3c37097
implement basic version of block's winCount and parentHeight
mikeseese Jan 23, 2021
65f2b4b
remove unnecessary hardcode
mikeseese Jan 23, 2021
8294635
add SigType type to have a proper value
mikeseese Jan 23, 2021
3849a1e
implement a "null/nil" CID
mikeseese Jan 23, 2021
34a8839
add explicit api version to urls
mikeseese Jan 25, 2021
cff7817
update api doc links with version numbers
mikeseese Jan 25, 2021
c3bf3c0
enable strictNullChecks and noImplicitAny
mikeseese Jan 29, 2021
af0e793
add a longer timeout for filecoin tests
mikeseese Jan 29, 2021
30ed41e
make sure we return the serialized input if it's the last resort
mikeseese Jan 29, 2021
0f0091c
make sure we run tsc in CI to catch all compiler errors
mikeseese Feb 1, 2021
a003393
fix server tests
mikeseese Feb 1, 2021
a492ce6
increase timeout for memory footprint test
mikeseese Feb 1, 2021
11685a2
try a more forgiving block interval test
mikeseese Feb 1, 2021
d8223e0
try adding a timeout for filecoin websocket tests for github ci
mikeseese Feb 2, 2021
275b970
adjust websocket timeouts
mikeseese Feb 2, 2021
697c6b1
try ws.terminate for better erroring?
mikeseese Feb 2, 2021
9bd0bee
make sure that we process an empty string for deserializing buffers
mikeseese Feb 3, 2021
6f88626
fix RNG imports
mikeseese Feb 4, 2021
8e45f7c
update type declarations
mikeseese Feb 4, 2021
2988e4d
remove link.filecoin script in favor of flavors devDependency
mikeseese Feb 4, 2021
305af80
fix errors from filecoin type declarations generation
mikeseese Feb 4, 2021
69ef141
remove unused file
mikeseese Feb 5, 2021
e112f50
change RandomNumberGenerate.getBuffer to be [0, 255] inclusive
mikeseese Feb 5, 2021
86900de
change expected address after changing RNG behavior
mikeseese Feb 5, 2021
14529cf
move external types to the proper directory
mikeseese Feb 5, 2021
d77e8d0
update comment about executor's execute params
mikeseese Feb 5, 2021
96a633a
remove helper type per requested change on code review
mikeseese Feb 5, 2021
13e14bf
update type declarations
mikeseese Feb 5, 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
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
if: startsWith(matrix.os, 'windows-')
run: npm config set msvs_version 2015
- run: npm ci
- run: npm run tsc
mikeseese marked this conversation as resolved.
Show resolved Hide resolved
- run: npm test
env:
FORCE_COLOR: 1
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run tsc
- run: npm test
env:
FORCE_COLOR: 1
Expand Down Expand Up @@ -66,6 +67,7 @@ jobs:
if: startsWith(matrix.os, 'windows-')
run: npm config set msvs_version 2015
- run: npm ci
- run: npm run tsc
- run: npm test
env:
FORCE_COLOR: 1
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start": "lerna exec --loglevel=silent --scope ganache -- npm run start --silent -- ",
"test": "lerna exec -- npm run test",
"tsc": "lerna exec -- npm run tsc",
"tsc.clean": "npx lerna exec -- npx shx rm -rf lib dist"
"tsc.clean": "npx lerna exec -- npx shx rm -rf lib dist",
"tsc.filecoin.declarations": "lerna run tsc.declarations --scope @ganache/filecoin && pretty-quick src/chains/filecoin/types"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "1.0.1",
Expand Down
3 changes: 1 addition & 2 deletions src/chains/ethereum/ethereum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
hashPersonalMessage
} from "ethereumjs-util";
import { TypedData as NotTypedData, signTypedData_v4 } from "eth-sig-util";
import { EthereumInternalOptions } from "@ganache/ethereum-options";
import { EthereumInternalOptions, Hardfork } from "@ganache/ethereum-options";
import { types, Data, Quantity, PromiEvent, utils } from "@ganache/utils";
import Blockchain, { TransactionTraceOptions } from "./blockchain";
import Wallet from "./wallet";
Expand All @@ -44,7 +44,6 @@ import {
parseFilterDetails,
parseFilterRange
} from "./helpers/filter-parsing";
import { Hardfork } from "@ganache/ethereum-options";

// Read in the current ganache version from core's package.json
const { version } = $INLINE_JSON("../../../../packages/ganache/package.json");
Expand Down
4 changes: 2 additions & 2 deletions src/chains/ethereum/ethereum/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { RecognizedString, WebSocket, HttpRequest } from "uWebSockets.js";
import { CodedError, ErrorCodes } from "@ganache/ethereum-utils";
import {
EthereumProviderOptions,
EthereumLegacyOptions
EthereumLegacyProviderOptions
} from "@ganache/ethereum-options";

export type ProviderOptions = EthereumProviderOptions | EthereumLegacyOptions;
type ProviderOptions = EthereumProviderOptions | EthereumLegacyProviderOptions;
export type Provider = EthereumProvider;
export const Provider = EthereumProvider;

Expand Down
4 changes: 2 additions & 2 deletions src/chains/ethereum/ethereum/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
EthereumProviderOptions,
EthereumInternalOptions,
EthereumOptionsConfig,
EthereumLegacyOptions
EthereumLegacyProviderOptions
} from "@ganache/ethereum-options";
import cloneDeep from "lodash.clonedeep";
import { PromiEvent, types, utils } from "@ganache/utils";
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class EthereumProvider
#wallet: Wallet;

constructor(
options: EthereumProviderOptions | EthereumLegacyOptions = {},
options: EthereumProviderOptions | EthereumLegacyProviderOptions = {},
executor: utils.Executor
) {
super();
Expand Down
2 changes: 1 addition & 1 deletion src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,6 @@ describe("api", () => {
}

assert.strictEqual(countMap.size, expectedObjectsInFinalTrace);
});
}).timeout(5000);
davidmurdoch marked this conversation as resolved.
Show resolved Hide resolved
});
});
31 changes: 13 additions & 18 deletions src/chains/ethereum/options/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WalletConfig, WalletOptions } from "./wallet-options";
import {
Base,
Defaults,
Definitions,
ExternalConfig,
InternalConfig,
Legacy,
Expand All @@ -18,14 +17,22 @@ import {
} from "@ganache/options";
import { UnionToIntersection } from "./helper-types";

export type EthereumOptions = {
type EthereumConfig = {
chain: ChainConfig;
database: DatabaseConfig;
logging: LoggingConfig;
miner: MinerConfig;
wallet: WalletConfig;
};

export const EthereumDefaults: Defaults<EthereumConfig> = {
mikeseese marked this conversation as resolved.
Show resolved Hide resolved
chain: ChainOptions,
database: DatabaseOptions,
logging: LoggingOptions,
miner: MinerOptions,
wallet: WalletOptions
};

type MakeLegacyOptions<C extends Base.Config> = UnionToIntersection<
{
[K in OptionName<C>]: K extends LegacyOptions<C>
Expand All @@ -34,7 +41,7 @@ type MakeLegacyOptions<C extends Base.Config> = UnionToIntersection<
}[keyof Options<C>]
>;

export type EthereumLegacyOptions = Partial<
export type EthereumLegacyProviderOptions = Partial<
MakeLegacyOptions<ChainConfig> &
MakeLegacyOptions<DatabaseConfig> &
MakeLegacyOptions<LoggingConfig> &
Expand All @@ -44,27 +51,15 @@ export type EthereumLegacyOptions = Partial<

export type EthereumProviderOptions = Partial<
{
[K in keyof EthereumOptions]: ExternalConfig<EthereumOptions[K]>;
[K in keyof EthereumConfig]: ExternalConfig<EthereumConfig[K]>;
}
>;

export type EthereumInternalOptions = {
[K in keyof EthereumOptions]: InternalConfig<EthereumOptions[K]>;
};

export type EthereumDefaults = {
mikeseese marked this conversation as resolved.
Show resolved Hide resolved
[K in keyof EthereumOptions]: Definitions<EthereumOptions[K]>;
};

export const ethereumDefaults: Defaults<EthereumOptions> = {
chain: ChainOptions,
database: DatabaseOptions,
logging: LoggingOptions,
miner: MinerOptions,
wallet: WalletOptions
[K in keyof EthereumConfig]: InternalConfig<EthereumConfig[K]>;
};

export const EthereumOptionsConfig = new OptionsConfig(ethereumDefaults);
export const EthereumOptionsConfig = new OptionsConfig(EthereumDefaults);

export * from "./chain-options";
export * from "./database-options";
Expand Down
8 changes: 7 additions & 1 deletion src/chains/ethereum/options/src/miner-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ export type MinerConfig = {

export const MinerOptions: Definitions<MinerConfig> = {
blockTime: {
normalize,
normalize: rawInput => {
if (rawInput < 0) {
mikeseese marked this conversation as resolved.
Show resolved Hide resolved
throw new Error("miner.blockTime must be 0 or a positive number.");
}

return rawInput;
},
cliDescription:
'Sets the `blockTime` in seconds for automatic mining. A blockTime of `0` enables "instamine mode", where new executable transactions will be mined instantly.',
default: () => 0,
Expand Down
Loading