Skip to content
69 changes: 62 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ members = [
"primitives/rpc",
"primitives/self-contained",
"template/node",
"template/runtime",
"template/runtime/common",
"template/runtime/accountid20",
"template/runtime/accountid32",
]
resolver = "2"

Expand Down Expand Up @@ -153,7 +155,9 @@ pallet-evm-precompile-simple = { version = "2.0.0-dev", path = "frame/evm/precom
pallet-evm-test-vector-support = { version = "1.0.0-dev", path = "frame/evm/test-vector-support" }
pallet-hotfix-sufficients = { version = "1.0.0", path = "frame/hotfix-sufficients", default-features = false }
# Frontier Template
frontier-template-runtime = { path = "template/runtime", default-features = false }
frontier-template-runtime-accountid20 = { path = "template/runtime/accountid20", default-features = false }
frontier-template-runtime-accountid32 = { path = "template/runtime/accountid32", default-features = false }
frontier-template-runtime-common = { path = "template/runtime/common", default-features = false }
# Arkworks
ark-bls12-377 = { version = "0.4.0", default-features = false, features = ["curve"] }
ark-bw6-761 = { version = "0.4.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ sp-consensus = { workspace = true }
sp-io = { workspace = true }
substrate-test-runtime-client = { workspace = true }
# Frontier
frontier-template-runtime = { workspace = true, features = ["default"] }
frontier-template-runtime-accountid32 = { workspace = true, features = ["default"] }
2 changes: 1 addition & 1 deletion client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use substrate_test_runtime_client::{
};
// Frontier
use fp_storage::{EthereumStorageSchema, ETHEREUM_CURRENT_TRANSACTION_STATUS, PALLET_ETHEREUM};
use frontier_template_runtime::RuntimeApi;
use frontier_template_runtime_accountid32::RuntimeApi;

use crate::frontier_db_cmd::{Column, FrontierDbCmd, Operation};

Expand Down
2 changes: 1 addition & 1 deletion client/mapping-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tempfile = "3.3.0"
tokio = { version = "1.24", features = ["sync"] }
#Frontier
fp-storage = { workspace = true, features = ["default"] }
frontier-template-runtime = { workspace = true, features = ["default"] }
frontier-template-runtime-accountid32 = { workspace = true, features = ["default"] }
# Substrate
sc-block-builder = { workspace = true }
sc-client-db = { workspace = true }
Expand Down
12 changes: 8 additions & 4 deletions client/mapping-sync/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ mod tests {
// Backend
let backend = builder.backend();
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let (client, _) = builder
.build_with_native_executor::<frontier_template_runtime_accountid32::RuntimeApi, _>(
None,
);
let mut client = Arc::new(client);
// Overrides
let mut overrides_map = BTreeMap::new();
Expand Down Expand Up @@ -386,8 +388,10 @@ mod tests {
// Backend
let backend = builder.backend();
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let (client, _) = builder
.build_with_native_executor::<frontier_template_runtime_accountid32::RuntimeApi, _>(
None,
);
let mut client = Arc::new(client);
// Overrides
let mut overrides_map = BTreeMap::new();
Expand Down
43 changes: 40 additions & 3 deletions docs/accounts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Frontier provides two different strategies for handling `H160` addresses.

# H256 -> H160 mapping
# `H256` -> `H160` mapping (`AccountId32`)

The first strategy consists of of a truncated hash scheme, where the first 160 LE bytes of a `H256` address are used to form the `H160` address.

Expand All @@ -11,8 +11,45 @@ The Runtime's `Signature` type is configured as [`sp_runtime::MultiSignature`](h
- `Ed25519`
- `ECDSA`

# Native H160 via AccountId20
# Native `H160` (`AccountId20`)

The second strategy consists of using `fp-account` so that `AccountId20` is the Account type used for `frame_system::pallet::Config::AccountId`.

The Runtime's `Signature` type is configured as `EthereumSigner`, which means only `ECDSA` signatures are supported.
The Runtime's `Signature` type is configured as `EthereumSigner`, which means only `ECDSA` signatures are supported.

Frontier's Template will pre-fund several well-known addresses that (mostly) contain the letters "th" in their names to remind you that they are for ethereum-compatible usage. These addresses are derived from Substrate's canonical mnemonic: `bottom drive obey lake curtain smoke basket hold race lonely fit walk`
```
# Alith:
- Address: 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
- PrivKey: 0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133

# Baltathar:
- Address: 0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0
- PrivKey: 0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b

# Charleth:
- Address: 0x798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc
- PrivKey: 0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b

# Dorothy:
- Address: 0x773539d4Ac0e786233D90A233654ccEE26a613D9
- PrivKey: 0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68

# Ethan:
- Address: 0xFf64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB
- PrivKey: 0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4

# Faith:
- Address: 0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d
- PrivKey: 0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df
```

# Template Runtimes

Frontier provides two different runtimes, one for each strategy.
You can choose which one want to build by using the `--feature` flag. For example:
```
$ cargo build --release # this builds a runtime with AccountId32
$ cargo build --release --features accountid32 # this also builds a runtime with AccountId32
$ cargo build --release --features accountid20 # this build a runtime with AccountId20
```
5 changes: 5 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ To build the chain, execute the following commands from the project root:
$ cargo build --release
```

By default, this will build a runtime with `AccountId32` as the account type. The same happens if you build it with `--features accountid32`.
Alternatively, you can use the `--features accountid20` to choose `AccountId20` instead.

Please refer to [`docs/accounts.md`](../docs/accounts.md) for more information on account types.

To execute the chain, run:

```
Expand Down
19 changes: 15 additions & 4 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sp-consensus-aura = { workspace = true, features = ["default"] }
sp-consensus-grandpa = { workspace = true, features = ["default"] }
sp-core = { workspace = true, features = ["default"] }
sp-inherents = { workspace = true, features = ["default"] }
sp-keyring = { workspace = true }
sp-offchain = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
sp-session = { workspace = true, features = ["default"] }
Expand Down Expand Up @@ -79,19 +80,29 @@ fp-account = { workspace = true }
fp-dynamic-fee = { workspace = true, features = ["default"] }
fp-evm = { workspace = true, features = ["default"] }
fp-rpc = { workspace = true, features = ["default"] }
frontier-template-runtime = { workspace = true, features = ["default"] }
frontier-template-runtime-accountid20 = { workspace = true, features = ["default"] }
frontier-template-runtime-accountid32 = { workspace = true, features = ["default"] }

[build-dependencies]
substrate-build-script-utils = { workspace = true }

[features]
default = ["with-rocksdb-weights"]
with-rocksdb-weights = ["frontier-template-runtime/with-rocksdb-weights"]
with-paritydb-weights = ["frontier-template-runtime/with-paritydb-weights"]
accountid20 = []
accountid32 = []
with-rocksdb-weights = [
"frontier-template-runtime-accountid20/with-rocksdb-weights",
"frontier-template-runtime-accountid32/with-rocksdb-weights",
]
with-paritydb-weights = [
"frontier-template-runtime-accountid20/with-paritydb-weights",
"frontier-template-runtime-accountid32/with-rocksdb-weights",
]
rpc-binary-search-estimate = ["fc-rpc/rpc-binary-search-estimate"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"frontier-template-runtime/runtime-benchmarks",
"frontier-template-runtime-accountid20/runtime-benchmarks",
"frontier-template-runtime-accountid32/runtime-benchmarks",
]
Loading