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

Celo RPC API is incompatible with ethers.js #1945

Closed
piersy opened this issue Sep 12, 2022 · 4 comments
Closed

Celo RPC API is incompatible with ethers.js #1945

piersy opened this issue Sep 12, 2022 · 4 comments
Labels
triage Issue needs triaging

Comments

@piersy
Copy link
Contributor

piersy commented Sep 12, 2022

Description

Celo's block type differs from the block used in ethereum, this causes our RPC API to be incompatible with ethers.js (and most likely many other web3 clients)

See these issues where people have encountered problems
ethers-io/ethers.js#1735
ethers-io/ethers.js#2919
ethers-io/ethers.js#2558
#1738

Celo's block header lacks the following fields that exist in ethereum.

UncleHash
Difficulty
GasLimit
MixDigest
Nonce
BaseFee

So in order to provide an API that is compatible with ethers.js we should seek to somehow re-instate these missing fields. We could do this by actually adding the fields to the block or simply by filling them with fake data in RPC responses.

Although BaseFee and GasLimit are not currently part of the Celo block they are parameters of the system and are managed by smart contracts. So these can be added to the block in a meaningful way.

It's not so clear however what to do with UncleHash, Difficulty, MixDigest and Nonce, since these fields really do not exist in the Celo system. We could add them to the block or RPC responses, but we would need to fill them with dummy data. This could be more problematic than just not having them since people may then try to make important decisions based off the dummy data. Or may find that the dummy data causes other problems within their system.

@sashaaldrick
Copy link

This is preventing us from deploying on Celo/Alfajores atm as we require hardhat forking and ethers compatibility, see NomicFoundation/hardhat#1966

@jaredcassidyluna
Copy link

ethers.js expects even length hex number for gasLimit:

We have been using ethers.js with an override to the formatter function to allow it to be used without gasLimit being present in the rpc responce.

About 2 days ago we started picking up errors on alfajores, I have removed our override and the error is still coming up

ethersProvider.getBlockWithTransactions(currentBlockHeight)

[Formatter.data (node_modules/@ethersproject/providers/lib/formatter.js:183:19),Object.gasLimit (node_modules/@ethersproject/providers/lib/formatter.js:399:20),Function.Formatter.check (node_modules/@ethersproject/providers/lib/formatter.js:380:40),Formatter._block (node_modules/@ethersproject/providers/lib/formatter.js:255:32),Formatter.blockWithTransactions (node_modules/@ethersproject/providers/lib/formatter.js:263:21),JsonRpcProvider.<anonymous> (node_modules/@ethersproject/providers/lib/base-provider.js:2077:71),step (node_modules/@ethersproject/providers/lib/base-provider.js:48:23),Object.next (node_modules/@ethersproject/providers/lib/base-provider.js:29:53),fulfilled (node_modules/@ethersproject/providers/lib/base-provider.js:20:58),processTicksAndRejections (internal/process/task_queues.js:93:5)] {
  checkKey: 'gasLimit',
  checkValue: '0x2160ec0'
} Error: invalid data; odd-length - 0x2160ec0

It seems that ethers.js expects this hex number to be of even length
ethers-io/ethers.js#614

@stephancill
Copy link

Any update on this issue? +1 for blocking deployment

@carterqw2 carterqw2 added triage Issue needs triaging and removed blockchain labels Feb 9, 2023
@carterqw2
Copy link
Contributor

Celo is compatible with Ethers.js since December. Announcement here.
If you’d like to share any feedback feel free to post it in this Github discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issue needs triaging
Projects
None yet
Development

No branches or pull requests

5 participants