Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update solidity, hardhat, slither CI #632

Merged
merged 9 commits into from
May 30, 2023

Conversation

zajck
Copy link
Member

@zajck zajck commented May 11, 2023

Closes #611

The latest solidity version is 0.8.20, but 0.8.18 is the latest fully supported by hardhat (and also recommended by slither).

In addition to updating the compiler version I made these changes:

  • updated hardhat
  • migrated from hardhat-waffle to hardhat-toolbox. This will allow us to use predicates when testing events. Migration lead to the following changes.
    • changed error bubbling up in JewelerLib.sol, MetaTransactionsHandlerFacet.sol and ProtocolInitializationHandlerFacet.sol
    • in hardhat.config.js we don't need to require separate packages anymore
    • added @ethereum-waffle/mock-contract so mocked contracts in bosonVoucherTest.js still work
    • changed some tests, where transactions are reverted without a reason since the syntax is a bit different

I tried compilation viaIR, which resulted in a larger contract size. Before using that feature we need to investigate what is the proper optimization sequence.

@zajck zajck added the v2.3.0 label May 11, 2023
@zajck zajck self-assigned this May 11, 2023
@anajuliabit
Copy link
Contributor

could you fix coverage?

@zajck zajck force-pushed the upgrade-solidity-and-hardhat-version branch from b284ad9 to 98a6d30 Compare May 12, 2023 06:04
anajuliabit
anajuliabit previously approved these changes May 12, 2023
Copy link
Contributor

@anajuliabit anajuliabit left a comment

Choose a reason for hiding this comment

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

LGTM

@zajck zajck mentioned this pull request May 12, 2023
anajuliabit
anajuliabit previously approved these changes May 29, 2023
@zajck zajck requested review from anajuliabit and mischat May 29, 2023 13:10
Copy link
Member

@mischat mischat left a comment

Choose a reason for hiding this comment

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

LGTM

// Reverts with default message
revert(FUNCTION_CALL_NOT_SUCCESSFUL);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

this seems like a step backwards, I wonder why this is like this ?

Copy link
Member Author

Choose a reason for hiding this comment

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

returnData contains some bytes at the beginning, which are not the actual revert reason.

When it's cast to string (string(returnData)) solidity does not really care that the bytes are not valid string bytes. So if that's then passed as a revert message, the client cannot decode it into a valid string.

For some reason, this wasn't a problem in the past (probably hardhat/ethers ignored the invalid part of the string), but now it is.

In any case, this is now the correct implementation for bubbling up the error, i.e. the error is exactly the same as the one, raised by the contract that reverted.

Copy link
Member Author

Choose a reason for hiding this comment

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

And without this code change, some tests fail.

revert(string(error));
assembly {
revert(add(32, error), mload(error))
}
Copy link
Member

Choose a reason for hiding this comment

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

This happens in a few places ...

@anajuliabit anajuliabit merged commit 13eea7a into main May 30, 2023
@anajuliabit anajuliabit deleted the upgrade-solidity-and-hardhat-version branch May 30, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix code scanning alert - Incorrect versions of Solidity
3 participants