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

Release - 1.2.8 #3510

Merged
merged 13 commits into from
May 20, 2020
Merged

Release - 1.2.8 #3510

merged 13 commits into from
May 20, 2020

Conversation

ryanio
Copy link
Collaborator

@ryanio ryanio commented May 8, 2020

Description

This PR introduces web3.js version 1.2.8 beginning with 1.2.8-rc.0.

Features

Alongside some Typescript improvements and patches for the Websocket Provider reconnection logic introduced in 1.2.7, this release contains two larger changes:

  • Ethers ABI Coder has received a full version increment, from 4.0.0-beta.3 to 5.0.0-beta.153. Since 2018, Web3 has relied on @ricmoo's great Ethers project to manage encoding and decoding data passed between Web3 and the EVM. This update should allow Web3 to absorb the latest work at Ethers going forward.
  • The ENS module now supports ENS's contenthash feature (EIP 1577), which allows you to associate an IPFS or Swarm hash with an ENS domain. There's a nice introduction to content hashes in this ENS medium post. Docs for the newly added methods can be found here.

Added

Changed

Fixed

Type of change

  • Release

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build-all and tested the resulting files from dist folder in a browser.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have tested my code on the live network.

@ryanio ryanio added In Progress Currently being worked on Release labels May 8, 2020
@cgewecke
Copy link
Collaborator

cgewecke commented May 8, 2020

As part of the RC process, am doing some test installations in other projects and running their tests to see if everything.

  • installs properly
  • builds
  • tests pass

This list will be actively edited:

Project Desc Status
oz-test-helpers Test utils. Subset of their suite is web3 contracts
gnosis/dex-react TS React app ~200 tests + webpack build + jest
synthetix (buidler branch) ~1000 units (check ABICoder change)

Implementation notes for future reference:

  • Synthetix yarn resolutions required for:
    • nomiclabs/
    • openzeppelin-solidity-2.3.0
    • chainlink/
    • truffle/
  • oz-test-helpers
    • truffle/
    • openzeppelin/
  • gnosis/dex-react
    • walletconnect
    • gnosis/pm

@coveralls
Copy link

coveralls commented May 8, 2020

Coverage Status

Coverage increased (+0.05%) to 89.602% when pulling da8122c on release/1.2.8 into 4ec98d4 on 1.x.

@cgewecke
Copy link
Collaborator

cgewecke commented May 13, 2020

Found a behavioral difference in the new abi decoder while running the synthetix unit tests,

Negative numbers passed as uint params are now flagged as "out of bounds". They used to be allowed.

The new behavior seems safer - perhaps we can just mention the difference in the release notes?

[EDIT] One case where this change might be problematic is for testing underflow logic itself, as here at openzeppelin/math. Wouldn't immediately impact them because they're on @truffle/contract and Web3@1.2.1 fwiw.

JS test

it('should revert when owner set the Target threshold to negative', async () => {
  const thresholdPercent = -1;
  await assert.revert(feePool.setTargetThreshold(thresholdPercent, { from: owner }));
});

Solidity
NB: the test above throws: Threshold too high, e.g. -1 is an underflow

function setTargetThreshold(uint _percent) external optionalProxy_onlyOwner {
        require(_percent >= 0, "Threshold should be positive"); 
        require(_percent <= 50, "Threshold too high");
        targetThreshold = _percent.mul(SafeDecimalMath.unit()).div(100);
}

Error

  1) Contract: FeePool
       when integrating with modern contracts
         FeeClaimablePenaltyThreshold
           should revert when owner set the Target threshold to negative:
     AssertionError: expected 'value out-of-bounds (argument="_percent", value=-1, code=INVALID_ARGUMENT, version=abi/5.0.0-beta.153)' to include 'revert'
      at Object.assertRevert [as revert] (test/utils/index.js:402:11)
      at process._tickCallback (internal/process/next_tick.js:68:7)

@cgewecke
Copy link
Collaborator

Looks like the some of the types changes might be breaking....

gnosis/dex-react tsc fails with:

ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/deposit/DepositApi.ts
ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/deposit/DepositApi.ts(70,31):
TS2352: Conversion of type 'Contract' to type 'ExtendedContract<BatchExchange>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'Contract' is not comparable to type 'Pick<BatchExchange, "methods" | "defaultAccount" | "defaultBlock" | "defaultCommon" | "defaultHardfork" | "defaultChain" | "transactionPollingTimeout" | "transactionConfirmationBlocks" | ... 4 more ... | "getPastEvents">'.
    Types of property 'methods' are incompatible.
      Type '{ [key: string]: ContractSendMethod; }' is missing the following properties from type '{ IMPROVEMENT_DENOMINATOR(): TransactionObject<string>; getSecondsRemainingInBatch(): TransactionObject<string>; requestWithdraw(token: string, amount: string | number): TransactionObject<...>; ... 37 more ...; getCurrentObjectiveValue(): TransactionObject<...>; }': IMPROVEMENT_DENOMINATOR, getSecondsRemainingInBatch, requestWithdraw, FEE_FOR_LISTING_TOKEN_IN_OWL, and 37 more.

ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/erc20/Erc20Api.ts
ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/erc20/Erc20Api.ts(106,31):
TS2352: Conversion of type 'Contract' to type 'ExtendedContract<Erc20>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'Contract' is not comparable to type 'Pick<Erc20, "methods" | "defaultAccount" | "defaultBlock" | "defaultCommon" | "defaultHardfork" | "defaultChain" | "transactionPollingTimeout" | "transactionConfirmationBlocks" | ... 4 more ... | "getPastEvents">'.
    Types of property 'methods' are incompatible.
      Type '{ [key: string]: ContractSendMethod; }' is missing the following properties from type '{ name(): TransactionObject<string>; approve(_spender: string, _value: string | number): TransactionObject<boolean>; totalSupply(): TransactionObject<...>; ... 5 more ...; allowance(_owner: string, _spender: string): TransactionObject<...>; }': name, approve, totalSupply, transferFrom, and 5 more.

ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/tcr/MultiTcrApi.ts
ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/tcr/MultiTcrApi.ts(37,31):
TS2352: Conversion of type 'Contract' to type 'ExtendedContract<Tcr>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type 'Contract' is not comparable to type 'Pick<Tcr, "methods" | "defaultAccount" | "defaultBlock" | "defaultCommon" | "defaultHardfork" | "defaultChain" | "transactionPollingTimeout" | "transactionConfirmationBlocks" | ... 4 more ... | "getPastEvents">'.
    Types of property 'methods' are incompatible.
      Property 'getTokens' is missing in type '{ [key: string]: ContractSendMethod; }' but required in type '{ getTokens(_listId: string | number): TransactionObject<string[]>; }'.

ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/wallet/WalletApi.ts
ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/wallet/WalletApi.ts(184,27):
TS2339: Property 'connected' does not exist on type 'HttpProvider | IpcProvider | WebsocketProvider | AbstractProvider'.
  Property 'connected' does not exist on type 'AbstractProvider'.
Child HtmlWebpackCompiler:
     1 asset
    Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
    [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/html/index.html 1.74 KiB {0} [built]
Child favicons-webpack-plugin:
     1 asset
    Entrypoint logo.svg = 58d2a652c3e9d3d2d6b3
    [0] ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"/Users/cgewecke/code/ef/synII/dex-react/node_modules/.cache/favicons-webpack-plugin"}!./node_modules/favicons-webpack-plugin/src/loader.js?{"prefix":"assets/","options":{"appName":"Mesa - Gnosis Protocol DApp","appDescription":"Mesa - Gnosis Protocol DApp","developerName":"Mesa - Gnosis Protocol DApp","developerURL":null,"background":"#dfe6ef","themeColor":"#476481","icons":{"coast":false,"yandex":false},"version":"0.11.1"},"path":""}!./src/assets/img/logo.svg 3.34 MiB {0} [built]
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Can be tricked into passing by:

  • Adding an optional connected property to AbstractProvider here:

https://github.com/ethereum/web3.js/blob/d6eda4df04214fb2441b92fa56b856190e3629e5/packages/web3-core/types/index.d.ts#L419-L423

  • Appending | any to the contract.methods re-definition here:

https://github.com/ethereum/web3.js/blob/137ca7ba2167f5f022d18025ed3135c69476652e/packages/web3-eth-contract/types/index.d.ts#L49-L51

@ricmoo
Copy link
Contributor

ricmoo commented May 13, 2020

I think the version of the ABI coder Web3 was previously using was quite old, so there may be other important differences to try out.

  • bit widths; passing 257 in a uint8 should fail
  • bytesXX must be exactly the correct length; the older ethers coder may have automatically padded, depending on what version (e.g. bytes2 should be “0x1234”, not “0x12”)

@alcuadrado
Copy link

alcuadrado commented May 14, 2020

I think it's worth reconsidering the option of vendoring that part of ethers v4. Otherwise, the risk of accidentally introducing a breaking change is high.

@cgewecke
Copy link
Collaborator

cgewecke commented May 14, 2020

@alcuadrado

Are there any precautions which could be taken which would make you feel more at ease with this?

The case for upgrading (e.g. not vendoring) is to make encoding/decoding here more closely aligned with ongoing work at Ethers and and inherit improvements there.

In two cases identified so far, web3 is accepting invalid inputs and a behavior change might be reasonable to consider as bug fixes:

  • throw when passing negative numbers as unsigned ints
  • throw when passing numbers outside allowable bit ranges for params

A third change is automatic padding for byte values - it looks like efforts here to address that might be incomplete (but could be fixed).

We've run the Synthetix and mosaicdao/mosaic unit tests (~1300) with 1.2.8-rc.0 and they're (basically) passing...

Definitely agree that there's risk and some unknowns here. But am wondering how you would upgrade this dependency at all given the versioning constraints here. Do you think on balance this is not worth doing?

@alcuadrado
Copy link

I'm ok with the upgrade @cgewecke. It will have to happen eventually.

I was just putting the other alternative on the table again, in case the upgrade path isn't complete fast enough. This was in the context of web3's future uncertainty and the npm stats issue. Otherwise, I wouldn't care about the time it takes to ship this change and just upgrade.

@cgewecke
Copy link
Collaborator

@ricmoo

From memory, does this seem like a complete list of the input validation changes between ABI Coder V4 / V5?

  • byte lengths enforced for bytesX and variants
  • bit widths enforced for uintX and variants
  • positive number enforced for uint

It looks like the approach we'd take here to minimize breaks is to pad bytes where possible and treat the additional strictness elsewhere as bug fixes.

@ryanio ryanio mentioned this pull request May 15, 2020
13 tasks
@ryanio
Copy link
Collaborator Author

ryanio commented May 18, 2020

Thanks everyone. I have released 1.2.8-rc.1 with the following:

  • Update AbiCoder param formatting (#3522)
  • Update AbstractProvider and contract.methods TS definitions (#3521)
  • Fix setContenthash docs formatting (#3511)

Copy link
Collaborator

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

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

Re-ran synthetix and gnosis/dex-react outside tests with 1.2.8-rc.1 and they're both good.

LGTM.

@ryanio ryanio removed the In Progress Currently being worked on label May 20, 2020
@ryanio ryanio merged commit 740a982 into 1.x May 20, 2020
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.

5 participants