I'm trying to run truffle test
in a project I've just been handed.
I googled on the TypeErrors and found that it's probably due to the wrong solidity being used, so I tried downgrading ethers
which installed the latest to 5.0.31
, without success as I get the same errors.
From what I can tell, there are two issues - one due to me being on an M1, and the other due to a solidity version?
My package requirements are;
"dependencies": {
"@opengsn/contracts": "^2.2.2",
"@openzeppelin/contracts": "^4.1.0",
"ethers": "^5.0.29",
"truffle-hdwallet-provider": "^1.0.17"
},
"devDependencies": {
"chai": "^4.3.0",
"openzeppelin-test-helpers": "^0.5.1",
"truffle-flattener": "^1.6.0"
}
Here are the error messages:
> truffle test
Using network 'development'.
Compiling your contracts...
===========================
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
> Compiling ./contracts/MetaWhat.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./node_modules/@opengsn/contracts/src/BaseRelayRecipient.sol
> Compiling ./node_modules/@opengsn/contracts/src/interfaces/IRelayRecipient.sol
> Compiling ./node_modules/@openzeppelin/contracts/access/Ownable.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol
> Compiling ./node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Context.sol
> Compilation warnings encountered:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> project:/contracts/MetaWhat.sol
TypeError: Overriding function return types differ.
--> project:/contracts/MetaWhat.sol:197:5:
|
197 | function _msgSender() internal override(Context, BaseRelayRecipient) view returns (address payable) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Overridden function is here:
--> project:/node_modules/@openzeppelin/contracts/utils/Context.sol:16:5:
|
16 | function _msgSender() internal view virtual returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).
,TypeError: Overriding function return types differ.
--> project:/contracts/MetaWhat.sol:197:5:
|
197 | function _msgSender() internal override(Context, BaseRelayRecipient) view returns (address payable) {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: Overridden function is here:
--> project:/node_modules/@openzeppelin/contracts/utils/Context.sol:16:5:
|
16 | function _msgSender() internal view virtual returns (address) {
| ^ (Relevant source part starts here and spans across multiple lines).
,TypeError: Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
--> project:/node_modules/@opengsn/contracts/src/BaseRelayRecipient.sol:37:20:
|
37 | return msg.sender;
| ^^^^^^^^^^
Compilation failed. See above.
Truffle v5.4.32 (core: 5.4.32)
Node v16.13.2
UPDATE
I've managed to get rid of the first warnings regarding the requested image being wrong, looked at my docker images which looked fine so I simple uncommented this in the truffle-config.js
:
compilers: {
solc: {
version: '0.8.0',
// docker: true,
// settings: {
// optimizer: {
// enabled: false, // Default: false
// runs: 200, // Default: 200 | consensys default 0
// },
// },
},
},
Thanks to @Yilmaz for the general direction. I've also tried adding a range to the version, version: ">=0.4.22 <0.9.0"
without it making a difference.
Now, I still get the TypeError
.
UPDATE 2
It seems to be the GSN contract BaseRelayRecipient.sol
which is the culprit. The contract seems to have been upgraded recently to instead be named ERC2771Recipient, I have no idea how updating this contract I've been handed actually works so I won't be upgrading GSN at this moment, but continuing to try and get it to work...
function _msgSender() internal override virtual view returns (address payable ret) {
if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
// At this point we know that the sender is a trusted forwarder,
// so we trust that the last bytes of msg.data are the verified sender address.
// extract sender address from the end of msg.data
assembly {
ret := shr(96,calldataload(sub(calldatasize(),20)))
}
} else {
return msg.sender;
}
}
That last return is giving the TypeError: Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
But... I can't change the BaseRelayRecipient...? I know this setup was running just a few months back.