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

Commit

Permalink
Merge pull request #4203 from trufflesuite/develop
Browse files Browse the repository at this point in the history
chore(release): publish v7.7.4
  • Loading branch information
jeffsmale90 authored Feb 1, 2023
2 parents 6e73ca7 + 7130e58 commit e66ef38
Show file tree
Hide file tree
Showing 20 changed files with 191 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Check bundle size
# this should match the os and version used in the release.yml
if: startsWith(matrix.os, 'ubuntu-22.04') && startsWith(matrix.node, '14.')
if: startsWith(matrix.os, 'ubuntu-22.04') && startsWith(matrix.node, '14.') && matrix.node != '14.0.0'
# 1. build ganache
# 2. pack it into a tarball
# 3. measure the _unpacked_ tarball's size
Expand All @@ -65,7 +65,7 @@ jobs:
INFURA_KEY: "badc0de0deadc0debadc0de0deadc0de"
- name: Upload artifact
# this should match the os and version used in the release.yml
if: startsWith(matrix.os, 'ubuntu-22.04') && startsWith(matrix.node, '14.')
if: startsWith(matrix.os, 'ubuntu-22.04') && startsWith(matrix.node, '14.') && matrix.node != '14.0.0'
uses: actions/upload-artifact@v3
with:
name: Candidate
Expand Down
6 changes: 3 additions & 3 deletions src/chains/ethereum/ethereum/package-lock.json

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

2 changes: 1 addition & 1 deletion src/chains/ethereum/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"ws": "8.2.3"
},
"devDependencies": {
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.1",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.2",
"@types/encoding-down": "5.0.0",
"@types/fs-extra": "9.0.2",
"@types/keccak": "3.0.1",
Expand Down
12 changes: 8 additions & 4 deletions src/chains/ethereum/ethereum/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,14 @@ export default class Blockchain extends Emittery<BlockchainTypedEvents> {
options.miner.blockGasLimit,
initialAccounts
);
blocks.earliest = blocks.latest =
await this.#blockBeingSavedPromise.then(({ block }) => block);
blocks.latest = await this.#blockBeingSavedPromise.then(
({ block }) => block
);
// when we are forking, blocks.earliest is already set to what was
// retrieved from the fork
if (!blocks.earliest) {
blocks.earliest = blocks.latest;
}
}
}

Expand Down Expand Up @@ -710,8 +716,6 @@ export default class Blockchain extends Emittery<BlockchainTypedEvents> {
await mclInitPromise; // ensure that mcl is initialized!
}
}
// skip `vm.init`, since we don't use any of it
(vm as any)._isInitialized = true;
return vm;
};

Expand Down
33 changes: 28 additions & 5 deletions src/chains/ethereum/ethereum/src/data-managers/block-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TypedDatabaseTransaction
} from "@ganache/ethereum-transaction";
import { GanacheLevelUp } from "../database";
import { Ethereum } from "../api-types";

const LATEST_INDEX_KEY = BUFFER_ZERO;

Expand Down Expand Up @@ -274,17 +275,39 @@ export default class BlockManager extends Manager<Block> {
await this.#blockIndexes.put(LATEST_INDEX_KEY, number);
}

async getEarliest() {
const fallback = this.#blockchain.fallback;
if (fallback) {
const json = await fallback.request<Ethereum.Block<true, "public">>(
"eth_getBlockByNumber",
[Tag.earliest, true],
// TODO: re-enable cache once this is fixed
// https://github.com/trufflesuite/ganache/issues/3773
{ disableCache: true }
);
if (json) {
const common = fallback.getCommonForBlockNumber(
this.#common,
BigInt(json.number)
);
return new Block(BlockManager.rawFromJSON(json, common), common);
}
} else {
// if we're forking, there shouldn't be an earliest block saved to the db,
// it's always retrieved from the fork
for await (const data of this.base.createValueStream({ limit: 1 })) {
return new Block(data as Buffer, this.#common);
}
}
}

/**
* Updates the this.latest and this.earliest properties with data
* from the database.
*/
async updateTaggedBlocks() {
const [earliest, latestBlockNumber] = await Promise.all([
(async () => {
for await (const data of this.base.createValueStream({ limit: 1 })) {
return new Block(data as Buffer, this.#common);
}
})(),
this.getEarliest(),
this.#blockIndexes.get(LATEST_INDEX_KEY).catch(e => null)
]);

Expand Down
16 changes: 16 additions & 0 deletions src/chains/ethereum/ethereum/tests/forking/block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ describe("forking", function () {
assert.deepStrictEqual(block.parentHash, remoteBlock.hash);
});

it("after initialization our earliest block should be the fork earliest block, parentHash should match", async () => {
const res = await request.post(URL).send({
jsonrpc: "2.0",
id: "1",
method: "eth_getBlockByNumber",
params: ["earliest", true]
});
const remoteBlock = JSON.parse(res.text).result;
const block = await provider.send("eth_getBlockByNumber", [
"earliest",
true
]);
assert.deepStrictEqual(parseInt(block.number), parseInt(remoteBlock.number));
assert.deepStrictEqual(block.hash, remoteBlock.hash);
});

//todo: reinstate this test after https://github.com/trufflesuite/ganache/issues/3616 is fixed
it.skip("should get a block from the original chain", async () => {
const res = await request.post(URL).send({
Expand Down
24 changes: 3 additions & 21 deletions src/chains/filecoin/filecoin/package-lock.json

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

2 changes: 1 addition & 1 deletion src/chains/filecoin/filecoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@filecoin-shipyard/lotus-client-schema": "2.0.0",
"@ganache/filecoin-options": "0.7.0",
"@ganache/utils": "0.7.0",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.1",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.2",
"@types/abstract-leveldown": "7.2.0",
"@types/bn.js": "5.1.0",
"@types/deep-equal": "1.0.1",
Expand Down
12 changes: 6 additions & 6 deletions src/chains/tezos/tezos/package-lock.json

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

2 changes: 1 addition & 1 deletion src/chains/tezos/tezos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"emittery": "0.10.0"
},
"devDependencies": {
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.1",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.2",
"@types/mocha": "9.0.0",
"cheerio": "1.0.0-rc.3",
"cross-env": "7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/cli/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default function (
})
.check(argv => {
const { "server.port": port, "server.host": host } = argv;
if (port < 1 || port > 65535) {
if (port < 0 || port > 65535) {
throw new Error(`Invalid port number '${port}'`);
}

Expand Down
13 changes: 7 additions & 6 deletions src/packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,18 @@ if (argv.action === "start") {
return;
}
started = true;
const { address: host, port } = server.address();
switch (flavor) {
case FilecoinFlavorName: {
await initializeFilecoin(
server.provider as FilecoinProvider,
cliSettings
);
await initializeFilecoin(server.provider as FilecoinProvider, {
host,
port
});
break;
}
case EthereumFlavorName:
default: {
initializeEthereum(server.provider as EthereumProvider, cliSettings);
initializeEthereum(server.provider as EthereumProvider, { host, port });
break;
}
}
Expand All @@ -157,7 +158,7 @@ if (argv.action === "start") {
// instance), so we need to notify that we are ready.
const isDetachedInstance = process.send !== undefined;
if (isDetachedInstance) {
notifyDetachedInstanceReady();
notifyDetachedInstanceReady(port);
}
});
} else if (argv.action === "stop") {
Expand Down
21 changes: 11 additions & 10 deletions src/packages/cli/src/detach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type DetachedInstance = {
};

const FILE_ENCODING = "utf8";
const READY_MESSAGE = "ready";
const START_ERROR =
"An error occurred spawning a detached instance of Ganache:";
const dataPath = envPaths(`Ganache/instances`, { suffix: "" }).data;
Expand All @@ -32,10 +31,10 @@ function getInstanceFilePath(instanceName: string): string {
/**
* Notify that the detached instance has started and is ready to receive requests.
*/
export function notifyDetachedInstanceReady() {
// in "detach" mode, the parent will wait until the "ready" message is
export function notifyDetachedInstanceReady(port: number) {
// in "detach" mode, the parent will wait until the port is
// received before disconnecting from the child process.
process.send(READY_MESSAGE);
process.send(port);
}

/**
Expand Down Expand Up @@ -113,11 +112,13 @@ export async function startDetachedInstance(
// event is emitted) will be streamed to stderr on the parent.
child.stderr.pipe(process.stderr);

await new Promise<void>((resolve, reject) => {
child.on("message", message => {
if (message === READY_MESSAGE) {
resolve();
}
// Wait for the child process to send its port, which indicates that the
// Ganache server has started and is ready to receive RPC requests. It signals
// by sending the port number to which it was bound back to us; this is needed
// because Ganache may bind to a random port if the user specified port 0.
const port = await new Promise<number>((resolve, reject) => {
child.on("message", port => {
resolve(port as number);
});

child.on("error", err => {
Expand Down Expand Up @@ -146,7 +147,7 @@ export async function startDetachedInstance(
child.disconnect();

const flavor = instanceInfo.flavor;
const { host, port } = instanceInfo.server;
const { host } = instanceInfo.server;
const cmd =
process.platform === "win32"
? path.basename(process.execPath)
Expand Down
12 changes: 6 additions & 6 deletions src/packages/core/package-lock.json

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

2 changes: 1 addition & 1 deletion src/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@ganache/options": "0.7.0",
"@ganache/tezos": "0.7.0",
"@ganache/utils": "0.7.0",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.1",
"@trufflesuite/uws-js-unofficial": "20.10.0-unofficial.2",
"aggregate-error": "3.1.0",
"emittery": "0.10.0"
},
Expand Down
Loading

0 comments on commit e66ef38

Please sign in to comment.