darwinia-network / darwinia

Darwinia Chain, EVM+, Polkadot parachain and integrating with XCMP.
https://darwinia.network
GNU General Public License v3.0
238 stars 49 forks source link

Support for widely used create2 factory on Darwinia and Pangolin #1461

Closed hujw77 closed 4 months ago

hujw77 commented 5 months ago

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

hackfisher commented 5 months ago

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

boundless-forest commented 5 months ago

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

boundless-forest commented 5 months ago

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?

RPate97 commented 5 months ago

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.

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

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 https://github.com/darwinia-network/darwinia/pull/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 https://github.com/darwinia-network/darwinia/pull/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 https://github.com/darwinia-network/darwinia/pull/1103 enable the dynamic fee over all the networks and update the block gas limit to the 20m at the same time.
hackfisher commented 5 months ago

Will close after runtime upgrade on chain.

boundless-forest commented 5 months ago

image

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

hujw77 commented 5 months ago

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.

hujw77 commented 4 months ago

https://darwinia.subscan.io/tx/0xeddf9e61fb9d8f5111840daef55e5fde0041f5702856532cdbb5a02998033d26 Deployed.