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

[R4R]~{feature} set native token as MNT #2

Merged
merged 69 commits into from
Oct 12, 2023
Merged

Conversation

Ethanncnm
Copy link
Contributor

@Ethanncnm Ethanncnm commented Aug 22, 2023

Core changes:

  1. Update the Optimism predeploy process for solidity contracts including BVM_ETH.
  2. add MNT deposit and withdrawal logic.
  3. change ETH deposit and withdrawal process which use BVM_ETH on L2. And change the op-geth mint logic to make BVM_ETH could be mined by op-geth.

Issue link:

* @dev The ETH predeploy provides an ERC20 interface for ETH deposited to Layer 2. Note that
* unlike on Layer 1, Layer 2 accounts do not have a balance field.
*/
contract BVM_ETH is OptimismMintableERC20 {
Copy link
Contributor

Choose a reason for hiding this comment

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

BVM_ETH already exist on mainnet. Do we need to upgrade the contract code with setCode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file which in contracts-bedrock path is used for local dev network.And I think it still need to be upgraded by setCode, it rely on a new abstract contract named OptimismMintableERC20.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file which in contracts-bedrock path is used for local dev network.

What do you mean by this? All the contracts locate in this path.

Why do we need to upgrade the old BVM_ETH contract code? Do the old code missing any methods? Could you clarify this?

Copy link
Contributor

Choose a reason for hiding this comment

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

bedrock upgrade will write all precompile contracts into genesis, and at meantime, it can be set as a upgradable contract. so we can jump the setcode step when we achieve this by a new genesis.json

op-bindings/predeploys/addresses.go Outdated Show resolved Hide resolved
op-bindings/predeploys/addresses.go Outdated Show resolved Hide resolved
op-bindings/predeploys/addresses.go Outdated Show resolved Hide resolved
op-chain-ops/genesis/config.go Outdated Show resolved Hide resolved
op-chain-ops/genesis/setters.go Outdated Show resolved Hide resolved
packages/contracts/src/predeploys.ts Show resolved Hide resolved
)

func ProveAndFinalizeWithdrawalForSingleTx(t *testing.T, l1Client *ethclient.Client, ethPrivKey *ecdsa.PrivateKey, l2WithdrawalReceipt *types.Receipt) (*types.Receipt, *types.Receipt) {
params, proveReceipt := ProveWithdrawalForSingleTx(t, l1Client, ethPrivKey, l2WithdrawalReceipt)
Copy link
Contributor

Choose a reason for hiding this comment

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

After ProveWithdrawalForSingleTx, wait for some L1 blocks, then FinalizeWithdrawalForSingleTx

  • add a duration?

Ethanncnm and others added 3 commits September 1, 2023 16:36
Co-authored-by: shijiang.guo <shijiang@192.168.0.101>
@@ -105,11 +107,12 @@ func MigrateWithdrawal(
}

gasLimit := MigrateWithdrawalGasLimit(data, chainID)

// TODO just put zero amount on the `NewWithdrawal` function for fixing compile error.
Copy link
Contributor

Choose a reason for hiding this comment

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

The above three TODO will be resolved in #12

@@ -237,6 +237,14 @@ func BuildL1DeveloperGenesis(config *DeployConfig) (*core.Genesis, error) {
memDB.SetState(*proxyAddr, common.Hash{31: 0x01}, symbol)
memDB.SetState(*proxyAddr, common.Hash{31: 0x02}, decimals)
}
if name == "L1MantleToken" {
name, _ := state.EncodeStringValue("Mantle Token", 0)
symbol, _ := state.EncodeStringValue("MNT", 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the error here need to be handled?

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
Copy link
Contributor

Choose a reason for hiding this comment

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

go fmt imports

op-e2e/withdrawal_lib.go Outdated Show resolved Hide resolved
packages/contracts-bedrock/contracts/L1/L1ERC721Bridge.sol Outdated Show resolved Hide resolved
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol Outdated Show resolved Hide resolved
@Ethanncnm
Copy link
Contributor Author

Now all the former test cases are all solved. And after merging this PR , we will improve the coverage in the future.

img_v2_240e5a42-5d2a-4fa9-9810-032738aa8fbh

@Tri-stone Tri-stone merged commit 0866109 into develop Oct 12, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants