Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Integrate frontier #334

Merged
merged 51 commits into from
Nov 3, 2020
Merged

Integrate frontier #334

merged 51 commits into from
Nov 3, 2020

Conversation

boundless-forest
Copy link
Member

Desc

This is the first PR to integrate the frontier into the Darwinia network.

Finished Tasks

  1. Clone the whole frontier repo and ensure it works in a template single node. The only change i made in the frontier-cloned now was the Trait for ethereum-pallet.
/// Trait for Ethereum pallet.
/// Old version
pub trait Trait: frame_system::Trait<Hash=H256> + pallet_balances::Trait + pallet_timestamp::Trait + pallet_evm::Trait {

New version for darwinia network
pub trait Trait: frame_system::Trait<Hash=H256> + darwinia_balances::Trait::<RingInstance> + pallet_timestamp::Trait + pallet_evm::Trait {
  1. Change the default address mapping functions from original HashedAddressMapping<BlakeTwo256> to ConcatAddressMapping.

  2. A new EVM precompiled contract TransferBack added. The contract name and implementation might be changed later in future prs.

@aurexav
Copy link
Member

aurexav commented Oct 16, 2020

I think consensus + frame + rpc is enough.

@boundless-forest
Copy link
Member Author

I think consensus + frame + rpc is enough.

OK, I am going to clear the useless files and commit later.

@aurexav
Copy link
Member

aurexav commented Oct 16, 2020

Which frontier version are we using?

I'll review this later.

@boundless-forest
Copy link
Member Author

Which frontier version are we using?

I'll review this later.

Please check the first commit msg Squashed 'frontier/' content from commit 51bd10f.

@hackfisher
Copy link
Contributor

hackfisher commented Oct 16, 2020

Better to move frontier/frame/ethereum to frame/dvm

For frontier/rpc and frontier/consensus, maybe rpc/dvm and consensus/dvm is better.

DVM is the abbreviation of Darwinia Smart-contract VM, which is compatible and fork of EVM.

@boundless-forest
Copy link
Member Author

boundless-forest commented Oct 16, 2020

Better to move frontier/frame/ethereum to frame/evm

For frontier/rpc and frontier/consensus, maybe rpc/evm and consensus/evm is better.

Yeap, It looks more clear to put frontier-related pallets under root/frame/.

How about putting frontier/rpc, frontier/frame/ethereum, frontier/consensus into a single subdirectory of root/frame named vm. Because of these three pallets all tight-related with one topic.

darwinia-common
    - bin
    - frame
          - balances
          - dvm
                - ethereum
                - consensus
                - rpc

@hackfisher
Copy link
Contributor

Better to move frontier/frame/ethereum to frame/evm
For frontier/rpc and frontier/consensus, maybe rpc/evm and consensus/evm is better.

Yeap, It looks more clear to put frontier-related pallets under root/frame/.

How about putting frontier/rpc, frontier/frame/ethereum, frontier/consensus into a single subdirectory of root/frame named vm. Because of these three pallets all tight-related with one topic.

darwinia-common
    - bin
    - frame
          - balances
          - dvm
                - ethereum
                - consensus
                - rpc

Yes, I think it is a good idea to do it in this way, just like another example in substrate:

https://github.com/paritytech/substrate/blob/master/frame/contracts/rpc/src/lib.rs

There are some rpc package from ethereum web3 which might be not directly to evm pallet, and more like primitives, can also moved to primitives folder

@boundless-forest
Copy link
Member Author

Better to move frontier/frame/ethereum to frame/evm
For frontier/rpc and frontier/consensus, maybe rpc/evm and consensus/evm is better.

Yeap, It looks more clear to put frontier-related pallets under root/frame/.
How about putting frontier/rpc, frontier/frame/ethereum, frontier/consensus into a single subdirectory of root/frame named vm. Because of these three pallets all tight-related with one topic.

darwinia-common
    - bin
    - frame
          - balances
          - dvm
                - ethereum
                - consensus
                - rpc

Yes, I think it is a good idea to do it in this way, just like another example in substrate:

https://github.com/paritytech/substrate/blob/master/frame/contracts/rpc/src/lib.rs

There are some rpc package from ethereum web3 which might be not directly to evm pallet, and more like primitives, can also moved to primitives folder

So, I guess the final skeleton looks like the file tree I painted above just now? If I am not misunderstand, I will work on this change. Thank you for making sure it again.

Cargo.lock Outdated Show resolved Hide resolved
bin/node-template/node/src/service.rs Show resolved Hide resolved
bin/node-template/runtime/src/lib.rs Outdated Show resolved Hide resolved
bin/node-template/runtime/src/lib.rs Outdated Show resolved Hide resolved
@hackfisher
Copy link
Contributor

@wuminzhe IMO Withdraw is not a good name for the precompiled contract, withdraw seems to be "transfer to my own address", but this precompiled contract it to "transfer to any substrate address"

@boundless-forest boundless-forest marked this pull request as ready for review October 20, 2020 03:14
@boundless-forest boundless-forest force-pushed the integrate-frontier-substrate-2.0.0 branch from 47aa3fb to 7e52571 Compare October 20, 2020 05:30
@hackfisher
Copy link
Contributor

darwinia_address

@boundless-forest
Copy link
Member Author

Is it necessary to set the accountId Prefix to 11 length bytes? For the length of the checksum as short as possible?

4 bytes length Prefix might more understandable. Why not leave an 8 length checksum at the end and keep 4 bytes length prefix at the head.

@hackfisher
Copy link
Contributor

hackfisher commented Oct 20, 2020

Is it necessary to set the accountId Prefix to 11 length bytes? For the length of the checksum as short as possible?

4 bytes length Prefix might more understandable. Why not leave an 8 length checksum at the end and keep 4 bytes length prefix at the head.

1 byte is enough for checksum purpose.

The others are just leaving there for future extension such as version etc. It is not necessary, but make sense IMO.

@wuminzhe
Copy link
Contributor

@hackfisher What precompile name will be better? Transfer?

@hackfisher
Copy link
Contributor

@hackfisher What precompile name will be better? Transfer?

I have no idea, but I will suggestBalanceTransfer or NativeTransfer if no more choices available.

frame/dvm/ethereum/Cargo.toml Outdated Show resolved Hide resolved
@boundless-forest
Copy link
Member Author

@hackfisher What precompile name will be better? Transfer?

I have no idea, but I will suggestBalanceTransfer or NativeTransfer if no more choices available.

The final name: NativeTransfer.

@boundless-forest boundless-forest force-pushed the integrate-frontier-substrate-2.0.0 branch from c624492 to e7f6860 Compare October 21, 2020 13:38
@boundless-forest
Copy link
Member Author

@AurevoirXavier @hackfisher @wuminzhe This PR based on the latest code is ready to review by all guys.

@boundless-forest boundless-forest force-pushed the integrate-frontier-substrate-2.0.0 branch from 959e745 to bc8ef74 Compare October 26, 2020 00:59
@boundless-forest boundless-forest marked this pull request as ready for review October 26, 2020 01:47
@aurexav aurexav marked this pull request as draft October 26, 2020 02:29
@aurexav aurexav marked this pull request as ready for review November 3, 2020 09:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EVM] Clone the frontier library to darwinia-common. Make it compiles successfully.
4 participants