Base layer pallet which implement base features such as emitting MessageSent
event and verifying committee's signature.
Pallet-Bcmp
must No Re-Creation or it will cause to LOST ASSET.
Consumer pallet depends on pallet-bcmp and supports custom features.
1. Write custom consumer pallet. ie: consumer-template.
a. Consumer pallet must depend on pallet-bcmp
to emit MessageSent
event and other receive message logic.
c. AnchorAddress
at config should set by constant to ensure same as address which was registered at pallet-bcmp
.
parameter_types! {
pub const PureMessage: H256 = pallet_bcmp::PURE_MESSAGE;
pub const DefaultAdmin: Option<AccountId> = consts::DefaultAdmin;
}
impl pallet_bcmp::Config for Runtime {
type RuntimeEvent = ******;
type Currency = ******;
type PureMessage = PureMessage;
type DefaultAdmin = DefaultAdmin;
// Consumers can instance for (Consumer1, Consumer2, ..)
type Consumers = BcmpConsumer;
type WeightInfo = pallet_bcmp::weight::BcmpWeight<Runtime>;
}
parameter_types! {
pub const AnchorAddress: H256 = ******;
}
impl pallet_bcmp_consumer::Config for Runtime {
type RuntimeEvent = ******;
type Currency = ******;
type AnchorAddress = AnchorAddress;
}
Bcmp's PureMessage
must use pallet_bcmp::PURE_MESSAGE
constant.
Bcmp's DefaultAdmin
is supplied for No-Sudo
chain, it will init WhiteList
storage if the value is Some.
Bcmp's Consumers
support instance by (Consumer1, Consumer2, ..), anyone in tuple should implement ConsumerLayer
trait.
Consumer's AnchorAddress
can generate by keccak256(&b"PALLET_CONSUMER"))
.
- Step1: Set whitelist by call
set_whitelist
. We support two ways to set whitelist:Root
orRole::Admin
. if you want to call by the latter,DefaultAdmin
of pallet-bcmp should set with Some Value. -
- You can use
Role::Admin
account to set other authority account.
- You can use
- Step2: Call
set_this_chain_id
with the Id represent this chain, iesha2_256("Bool-Local".as_bytes())[..4]
to u32(big-endian). - Step3: Call
set_chain_id
to support other chain. -
- It will be failed if you don't set support chain id when enable path for anchor later.
-
- Step4(Optional): Call
set_fee_config
to manage targe chain's fee config, default config to calculate fee is return0
.
- Step4(Optional): Call
-
- Step5(Optional): Call
emergency_control
to controlsend_message
andreceive_message
to pause handle processing logic, requireRoot
orRole::Admin
.
- Step5(Optional): Call
- Step1: Create target committee and waiting for committee's pubkey has been generated.
- Step2: Call
register_anchor
at pallet-bcmp. -
anchor
is a constant at consumer's config.
-
cmt_pk
was generated at Step1.
- Step3: Call
enable_path
at pallet-bcmp to bind other chain's anchor and committee.
- Call
send_message
at pallet-bcmp-consumer, it should call pallet-bcmp'ssend_message
finally to emitMessageSent
event. fee
parameter can calculate at bcmp-fee-config.
- After deliverer call the
receive_message
at pallet-bcmp, it will call consumer pallet'sreceive_op
at traitConsumerLayer
if dispatchMessage
's elementdst_anchor
successfully.