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

Fix: truffle console crash when metadata is missing in JSON artifact #5819

Merged
merged 3 commits into from
Jan 4, 2023
Merged

Fix: truffle console crash when metadata is missing in JSON artifact #5819

merged 3 commits into from
Jan 4, 2023

Conversation

dPreininger
Copy link
Contributor

PR description

As per the issue #5812 , truffle console command would throw an error and exit, if the metadata field was not present in all JSON blob files generated in the build process. The metadata field is not present in JSON files derived from Vyper source files.

Testing instructions

  1. Either compile a Vyper smart contract or delete metadata field in one of the generated JSON blobs from Solidity smart contracts.
  2. Run truffle migrate. IMPORTANT: do not run truffle develop, as some configurations (truffle-config.js) were not affected by this bug (see issue for more details).
  3. Run truffle console. The command executes without errors.

Documentation, breaking changes and new features

This PR does not introduce any breaking changes or new features. The documentation does not need to be changed either.

Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, @dPreininger. There are two small comment nits I'd like updated.

packages/core/lib/console.js Outdated Show resolved Hide resolved
packages/core/lib/console.js Outdated Show resolved Hide resolved
dPreininger and others added 2 commits January 4, 2023 12:40
Co-authored-by: cds-amal <[email protected]>
Co-authored-by: cds-amal <[email protected]>
@dPreininger
Copy link
Contributor Author

I have committed the suggestions.

@cds-amal cds-amal changed the title Fix: truffle console crashed if JSON blob file didn't contain metadata Fix: truffle console crash when metadata is missing in JSON artifact Jan 4, 2023
Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding and fixing this bug, @dPreininger !

Copy link
Contributor

@eggplantzzz eggplantzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it does the job - I wonder what limitations we have in using these artifacts when they don't contain metadata, I'm not sure where we use this field in Truffle

@cds-amal cds-amal merged commit b169455 into trufflesuite:develop Jan 4, 2023
@dPreininger
Copy link
Contributor Author

@eggplantzzz I have actually looked through the code and found only 2 instances of metadata being used (besides this console.js file):
packages/codec/lib/compilations/utils.ts
packages/compile-solidity/src/run.ts

and 2 more test files:
packages/compile-solidity-tests/test/metadata.ts -> this is a test file
packages/contract-schema/test/solc.js -> this is a test file

I might have missed some more usages, but it seems to me that it was only really used to filter out Console contract.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants