Skip to content

Commit

Permalink
🚧 Hardhat compilation issues in compose (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Dec 7, 2023
1 parent cca41af commit 1305749
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 15 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/reusable-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
# Cache hardhat compilers
#
# This step will speed up workflow runs that use hardhat compilation
- name: Cache hardhat compilers
uses: actions/cache@v3
with:
path: .cache/hardhat
key: ${{ runner.os }}-hardhat-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-hardhat-
- name: Build
run: yarn build
env:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/reusable-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
# Cache hardhat compilers
#
# This step will speed up workflow runs that use hardhat compilation
- name: Cache hardhat compilers
uses: actions/cache@v3
with:
path: .cache/hardhat
key: ${{ runner.os }}-hardhat-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-hardhat-
- name: Lint
run: yarn lint

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ node_modules/
dist

# Github actions
.netrc
.netrc

# Cache
.cache
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ services:
volumes:
- ./node_modules/.cache/turbo:/app/node_modules/.cache/turbo
- ./packages:/app/packages
# Hardhat has an issue with caching compilers inside a docker container,
# failing with EACCES -13 error, pointing to a permissions issue with the cache folder.
#
# The workaround is to provide an outside volume to work
# as a cache directory for hardhat so that the permissions
# don't clash
- ./.cache/hardhat:/root/.cache/hardhat-nodejs
command: "npx turbo test $DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS"
1 change: 1 addition & 0 deletions examples/oft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@layerzerolabs/lz-evm-oapp-v2": "~1.5.69",
"@layerzerolabs/prettier-config-next": "^1.5.69",
"@layerzerolabs/solhint-config": "^1.5.69",
"@nomicfoundation/hardhat-ethers": "^3.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@rushstack/eslint-patch": "^1.5.1",
"ethers": "^5.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ua-utils-evm-hardhat-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1",
"@layerzerolabs/utils-evm-hardhat": "~0.0.1",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomicfoundation/hardhat-ethers": "^3.0.2",
"@types/chai-as-promised": "^7.1.7",
"@types/mocha": "^10.0.6",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"ethers": "^5.7.0",
"hardhat": "^2.19.2",
"hardhat-deploy": "^0.11.22",
"hardhat-deploy-ethers": "^0.3.0-beta.12",
"hardhat-deploy-ethers": "^0.4.1",
"sinon": "^17.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
Expand Down
2 changes: 0 additions & 2 deletions packages/ua-utils-evm-hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@layerzerolabs/ua-utils": "~0.1.0",
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm-hardhat": "~0.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@types/jest": "^29.5.10",
"cli-ux": "^6.0.9",
"dotenv": "^16.0.3",
Expand All @@ -70,7 +69,6 @@
"@layerzerolabs/ua-utils": "~0.1.0",
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm-hardhat": "~0.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"ethers": "^5.5.2",
"hardhat": "^2.19.2",
"hardhat-deploy": "^0.11.22"
Expand Down
1 change: 1 addition & 0 deletions packages/utils-evm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@layerzerolabs/test-utils": "~0.0.1",
"@layerzerolabs/utils": "~0.0.1",
"@layerzerolabs/utils-evm": "~0.0.1",
"@nomicfoundation/hardhat-ethers": "^3.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@types/mocha": "^10.0.6",
"chai": "^4.3.10",
Expand Down
10 changes: 8 additions & 2 deletions packages/utils-evm-test/test/errors/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,14 @@ describe('errors/parser', () => {
expect(parsedError.point).to.eql(point)
expect(parsedError.error).to.be.instanceOf(UnknownError)
expect(parsedError.error.reason).to.be.undefined
expect(parsedError.error.message).to.eql(`Unknown error: ${error}`)
})
expect(parsedError.error.message).to.match(/Unknown error: /)
}),
// Test case for when toString method of the error is not defined
{
seed: 223418789,
path: '40:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:1:77:77',
endOnFailure: true,
}
)
})

Expand Down
21 changes: 19 additions & 2 deletions packages/utils-evm/src/errors/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const createErrorParser =
if (customError != null) return { point, error: customError }

// If none of the decoding works, we'll send a generic error back
return { point, error: new UnknownError(`Unknown error: ${error}`) }
return { point, error: new UnknownError(`Unknown error: ${toStringSafe(error)}`) }
} catch {
// If we fail, we send an unknown error back
return {
point,
error: new UnknownError(`Unexpected error: ${error}`),
error: new UnknownError(`Unexpected error: ${toStringSafe(error)}`),
}
}
}
Expand Down Expand Up @@ -122,3 +122,20 @@ const getErrorDataCandidates = (error: unknown): string[] =>
[(error as any)?.error?.data?.data, (error as any)?.error?.data, (error as any)?.data].filter(
(candidate: unknown) => typeof candidate === 'string'
)

/**
* Solves an issue with objects that cannot be converted to primitive values
* and when stringified, they fail
*
* See https://stackoverflow.com/questions/41164750/cannot-convert-object-to-primitive-value
*
* @param {unknown} obj
* @returns {string} String representation of an object or `'[unknown]'`
*/
const toStringSafe = (obj: unknown): string => {
try {
return String(obj)
} catch {
return '[unknown]'
}
}
15 changes: 9 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,14 @@
mcl-wasm "^0.7.1"
rustbn.js "~0.2.0"

"@nomicfoundation/hardhat-ethers@^3.0.2":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-ethers/-/hardhat-ethers-3.0.5.tgz#0422c2123dec7c42e7fb2be8e1691f1d9708db56"
integrity sha512-RNFe8OtbZK6Ila9kIlHp0+S80/0Bu/3p41HUpaRIoHLm6X3WekTd83vob3rE54Duufu1edCiBDxspBzi2rxHHw==
dependencies:
debug "^4.1.1"
lodash.isequal "^4.5.0"

"@nomicfoundation/[email protected]":
version "0.1.1"
resolved "https://registry.npmjs.org/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz"
Expand Down Expand Up @@ -2101,7 +2109,7 @@

"@nomiclabs/hardhat-ethers@^2.2.3":
version "2.2.3"
resolved "https://registry.npmjs.org/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz"
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0"
integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg==

"@oclif/core@^1.1.1":
Expand Down Expand Up @@ -6804,11 +6812,6 @@ hardhat-contract-sizer@^2.10.0:
cli-table3 "^0.6.0"
strip-ansi "^6.0.0"

hardhat-deploy-ethers@^0.3.0-beta.12:
version "0.3.0-beta.13"
resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.3.0-beta.13.tgz#b96086ff768ddf69928984d5eb0a8d78cfca9366"
integrity sha512-PdWVcKB9coqWV1L7JTpfXRCI91Cgwsm7KLmBcwZ8f0COSm1xtABHZTyz3fvF6p42cTnz1VM0QnfDvMFlIRkSNw==

hardhat-deploy-ethers@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.4.1.tgz#dd70b0cc413ed99e98994047b383a004cf1c14f8"
Expand Down

0 comments on commit 1305749

Please sign in to comment.