darwinia-network/darwinia

Support for widely used create2 factory on Darwinia and Pangolin

hujw77 opened this issue · 10 comments

Repo

https://github.com/Arachnid/deterministic-deployment-proxy

Issue

Due to gas prices exceeding 100 gwei on the Darwinia and Pangolin networks for an extended period, the widely used create2 factory that does not require a key (keyless) cannot be deployed.

Reference

The gas consumption of blocks in Darwinia is far less from the block gas target? Why the gas price is not decreasing? cc @boundless-forest

The current gas price mechnism of all the Darwinia chains uses the underlying substrate block weight fee calculator https://github.com/darwinia-network/darwinia/blob/main/runtime/darwinia/src/pallets/evm.rs#L150-L157, there is an initial fee value even if the block weight doesn't reach the target. This is designed to prevent the gas price from dropping to zero.Check out the test: https://github.com/darwinia-network/darwinia/blob/main/runtime/common/src/test.rs#L720-L735

the widely used create2 factory that does not require a key (keyless) cannot be deployed.

I am confused that why the gas price will affect the contract deployment. Can you explain more? Is there some hardcoded gas price requirement in that repo?

I am confused that why the gas price will affect the contract deployment. Can you explain more? Is there some hardcoded gas price requirement in that repo?

Hey, Ryan from Sphinx here. I wanted to chime in with some info on this.

On most networks, the deterministic create2 factory is deployed at the address 0x4e59b44847b379578588920ca78fbf26c0b4956c. Having this create2 factory deployed at the same address across networks is helpful because it allows for other contracts to be deployed at consistent addresses (we rely on this heavily at Sphinx). This factory contract has become very popular because it can be permissionlessly deployed by anyone to the expected address on any network as long as it meets certain compatibility conditions.

This contract's deployment works by using a transaction signed with the account 0x3fab184622dc19b6109349b94811493bf2a45362 that does not include a chain ID. Since the transaction does not include a chain ID, it can be replayed on any EVM-compatible network without access to the deployer's private key. This makes the contract permissionlessly deployable on any network.

The downside of this setup is that the transaction has a fixed gas price (100 gwei) and gas limit (100k). If a network's gas price permanently exceeds 100 gwei or has opcode gas fee changes that result in the cost of deploying the factory exceeding 100k, then the factory cannot be deployed on that network.

Since we heavily rely on this factory contract for Sphinx, we unfortunately cannot support your networks unless this issue is resolved.

+ curl -fsS https://pangolin-rpc.darwinia.network -d '{"id":1,"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222"]}' -H 'Content-Type: application/json'

I have done some tracking of the gas price increases over the last year and have sorted them out and summarised them here for your reference.

  1. Before #1066, the gas price of all the darwinia runtime is low, the darwinia and crab chain used fixed gas price 1GWEI and the dynamic gas price has been loaded in the pangolin network, but the initial gas price is 18_779GWEI(too high in today's view)
  2. In #1237, update the weight to fee polynomial params again, this also affects the gas price across all networks, the value remains to be used today.
  3. In #1103 enable the dynamic fee over all the networks and update the block gas limit to the 20m at the same time.

Will close after runtime upgrade on chain.

image

I think the Pangolin testnet gas price is low enough to test the contract. Please testing and feedback here. @hujw77

image

I think the Pangolin testnet gas price is low enough to test the contract. Please testing and feedback here. @hujw77

https://pangolin.subscan.io/tx/0xeddf9e61fb9d8f5111840daef55e5fde0041f5702856532cdbb5a02998033d26

No problem.