Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
c4f6fbce
Commit
c4f6fbce
authored
4 years ago
by
Wei Tang
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
pallet-evm: customizable chain id (#6537)
parent
e61f3776
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/frame/evm/src/backend.rs
+2
-1
2 additions, 1 deletion
substrate/frame/evm/src/backend.rs
substrate/frame/evm/src/lib.rs
+12
-1
12 additions, 1 deletion
substrate/frame/evm/src/lib.rs
with
14 additions
and
2 deletions
substrate/frame/evm/src/backend.rs
+
2
−
1
View file @
c4f6fbce
...
...
@@ -5,6 +5,7 @@ use serde::{Serialize, Deserialize};
use
codec
::{
Encode
,
Decode
};
use
sp_core
::{
U256
,
H256
,
H160
};
use
sp_runtime
::
traits
::
UniqueSaturatedInto
;
use
frame_support
::
traits
::
Get
;
use
frame_support
::
storage
::{
StorageMap
,
StorageDoubleMap
};
use
sha3
::{
Keccak256
,
Digest
};
use
evm
::
backend
::{
Backend
as
BackendT
,
ApplyBackend
,
Apply
};
...
...
@@ -91,7 +92,7 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> {
}
fn
chain_id
(
&
self
)
->
U256
{
U256
::
from
(
sp_io
::
misc
::
c
hain
_id
())
U256
::
from
(
T
::
C
hain
Id
::
get
())
}
fn
exists
(
&
self
,
_address
:
H160
)
->
bool
{
...
...
This diff is collapsed.
Click to expand it.
substrate/frame/evm/src/lib.rs
+
12
−
1
View file @
c4f6fbce
...
...
@@ -118,6 +118,15 @@ impl Precompiles for () {
}
}
/// Substrate system chain ID.
pub
struct
SystemChainId
;
impl
Get
<
u64
>
for
SystemChainId
{
fn
get
()
->
u64
{
sp_io
::
misc
::
chain_id
()
}
}
static
ISTANBUL_CONFIG
:
Config
=
Config
::
istanbul
();
/// EVM module trait
...
...
@@ -134,6 +143,8 @@ pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
type
Event
:
From
<
Event
<
Self
>>
+
Into
<<
Self
as
frame_system
::
Trait
>
::
Event
>
;
/// Precompiles associated with this EVM engine.
type
Precompiles
:
Precompiles
;
/// Chain ID of EVM.
type
ChainId
:
Get
<
U256
>
;
/// EVM config used in the module.
fn
config
()
->
&
'static
Config
{
...
...
@@ -159,7 +170,7 @@ decl_storage! {
trait
Store
for
Module
<
T
:
Trait
>
as
EVM
{
Accounts
get
(
fn
accounts
):
map
hasher
(
blake2_128_concat
)
H160
=>
Account
;
AccountCodes
get
(
fn
account_codes
):
map
hasher
(
blake2_128_concat
)
H160
=>
Vec
<
u8
>
;
AccountStorages
get
(
fn
account_storages
):
AccountStorages
get
(
fn
account_storages
):
double_map
hasher
(
blake2_128_concat
)
H160
,
hasher
(
blake2_128_concat
)
H256
=>
H256
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment