Skip to content

Commit 183b319

Browse files
authored
ETCM-8754: feat: implement register transaction (#280)
1 parent 50d0f0a commit 183b319

File tree

17 files changed

+403
-64
lines changed

17 files changed

+403
-64
lines changed

node/runtime/src/mock.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub fn create_inherent_data_struct(
322322
let signed_message = RegisterValidatorSignedMessage {
323323
genesis_utxo,
324324
sidechain_pub_key: validator.cross_chain.public().into_inner().0.to_vec(),
325-
input_utxo: UtxoId::default(),
325+
registration_utxo: UtxoId::default(),
326326
};
327327

328328
let signed_message_encoded = minicbor::to_vec(signed_message.to_datum()).unwrap();
@@ -331,7 +331,7 @@ pub fn create_inherent_data_struct(
331331
let sidechain_signature = validator.cross_chain.sign(&signed_message_encoded[..]);
332332

333333
let registration_data = RegistrationData {
334-
consumed_input: signed_message.input_utxo,
334+
registration_utxo: signed_message.registration_utxo,
335335
sidechain_signature: SidechainSignature(
336336
sidechain_signature.into_inner().0[..64].to_vec(),
337337
),
@@ -344,7 +344,7 @@ pub fn create_inherent_data_struct(
344344
aura_pub_key: AuraPublicKey(validator.aura.public().as_slice().into()),
345345
grandpa_pub_key: GrandpaPublicKey(validator.grandpa.public().as_slice().into()),
346346
utxo_info: UtxoInfo::default(),
347-
tx_inputs: vec![signed_message.input_utxo],
347+
tx_inputs: vec![signed_message.registration_utxo],
348348
};
349349

350350
CandidateRegistrations {

res/bb-mock/default-registrations.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"mainchain_pub_key": "0xcef2d1630c034d3b9034eb7903d61f419a3074a1ad01d4550cc72f2b733de6e7",
88
"mainchain_signature": "0x9e417ede1ab0d710ce3d5854627baef9b32d4dd69ec75f20d1f28234f167b3f679dadafce995fc63a05eefefa322ebe84b5ffccf526481710d086a16aef61506",
99
"sidechain_signature": "0x568e305af7f6d51668a76f3aaa72aa3f0f3554be20f150dcabb759f8bff66b484bf66cf248916a40bda649b3ce302ecaf689b9c7b4abd66b44b2aeb039ff85a5",
10-
"input_utxo": "d3600cf1032b2f147d592332032975bc70aff78f78b5be96e4311c0b0b28d7d6#0",
10+
"registration_utxo": "d3600cf1032b2f147d592332032975bc70aff78f78b5be96e4311c0b0b28d7d6#0",
1111
"status": "Active",
1212
"aura_pub_key": "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
1313
"grandpa_pub_key": "88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee"
@@ -18,7 +18,7 @@
1818
"mainchain_pub_key": "0xd5f64925e8722583ab9f8bb633a6938780873cf59504b3d12527719d3310b0ff",
1919
"mainchain_signature": "0x5e4df30d46e850498ac7eb8694b4c08a835ec2a7bcbb65cd5c13ae46ab7d35cbd8b5f70d05b38359297af957d1c47b19c110fe24553b5a72afe4868a83211703",
2020
"sidechain_signature": "0xea3b7c8c73786108b56762b02228ed0bd2d77dc43561c67194d94dbc77264f2850f6be7a8077ee35b4a87c1c2ce081c5ea4d3b534283c2e8b7ec2a91ba812765",
21-
"input_utxo": "ff428f8f916a832d146e58f3656c17c769a6bbc44bba1693fe2a4f9c605b8f16#0",
21+
"registration_utxo": "ff428f8f916a832d146e58f3656c17c769a6bbc44bba1693fe2a4f9c605b8f16#0",
2222
"status": "Active",
2323
"aura_pub_key": "8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
2424
"grandpa_pub_key": "d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69"
@@ -29,7 +29,7 @@
2929
"mainchain_pub_key": "0x7521303029fc73ea2dd6a410c4c3cf570bf294a7e02942e049d50ba117acec22",
3030
"sidechain_signature": "0xad0e6a4de53e30e9069af07d1d746606be3c12e4a22d0b05288912685a6625d2702276c87f437f4cecd831bb452090b3810a46e19749a1d939fd950b41976160",
3131
"mainchain_signature": "0x0c12fec1383b2e03f69354b1ade8b8de02732345352695293b42b4e6390e8b389a5f7b5cfd0d9898af61ac3c117a0ba4c163bc91ce1f1a9f8e78c2c74b0b1c0c",
32-
"input_utxo": "8fa6c98eedd88bdc2f21bb3a788aadc2da490f71fd07bd96554193f08c7d9bc0#0",
32+
"registration_utxo": "8fa6c98eedd88bdc2f21bb3a788aadc2da490f71fd07bd96554193f08c7d9bc0#0",
3333
"status": "Active",
3434
"aura_pub_key": "90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22",
3535
"grandpa_pub_key": "439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234f"
@@ -40,7 +40,7 @@
4040
"mainchain_pub_key": "702b81ab2e86cf73a87062af1eb0da666d451976d9d91c63a119ed94e6a33dc0",
4141
"mainchain_signature": "0x5e78be6b5114220ffa03f5ff0a7bea41bb18c8b5fa059664aea26cb66dce095503454c2913e5788129c4ef815b239bd5e43c174a6fd83a03942a9ad95a5b980d",
4242
"sidechain_signature": "0xd24e93588137e649dc37ce05f82da976ab546f22d8a158d1b6e2ca545242230d1b17e7a8b805ea8e96a93237242316976075af490bec6951a24e5abd7a73520b",
43-
"input_utxo": "f86aa8ce9b88c861d5b954066cb683a587bb0cae5aae460252f60f780cc8f5a5#0",
43+
"registration_utxo": "f86aa8ce9b88c861d5b954066cb683a587bb0cae5aae460252f60f780cc8f5a5#0",
4444
"status": "Active",
4545
"aura_pub_key": "306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20",
4646
"grandpa_pub_key": "5e639b43e0052c47447dac87d6fd2b6ec50bdd4d0f614e4299c665249bbd09d9"
@@ -51,7 +51,7 @@
5151
"mainchain_pub_key": "6d4b0b7619803f187ccbbd74562a85e9721fee6733c934c081143cc569c96f8f",
5252
"mainchain_signature": "0x2f7e44816a33c341bc2a11fd1b951374c63752251926ec27b67a9421ae177898f02cc10d8875ae3c2951359705962ba0266a3a9b9a70ce166e609112920ae80e",
5353
"sidechain_signature": "0xf4b49b8f5dfd0f05162b681d5e88b1471a85858a8e4a80e25715f032da9b24a83311d2b3e34c972ff8e0474b37b6d34aefc79fd2eaca6b63e137ed90f64966c2",
54-
"input_utxo": "89905473b5e80c00421b84cf14129c7bc06ac002a3d94e73724680570f776ab8#0",
54+
"registration_utxo": "89905473b5e80c00421b84cf14129c7bc06ac002a3d94e73724680570f776ab8#0",
5555
"status": "Active",
5656
"aura_pub_key": "e659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e",
5757
"grandpa_pub_key": "1dfe3e22cc0d45c70779c1095f7489a8ef3cf52d62fbd8c2fa38c9f1723502b5"
@@ -62,7 +62,7 @@
6262
"mainchain_pub_key": "0x954640fc3b8fa8ed78e06cab158c1094335e6be29e2bde963a80da7d59e56576",
6363
"mainchain_signature": "583e69f307fe255613019bc916acb4068c9696dea79c4dc878524ccb20abdd47daead79be482d88b258fc3b06f4618eedb776d6676ee01eabea32ca5c3e1dc0b",
6464
"sidechain_signature": "da6c9f352ec215415339572202cb18744c329e494bf3bd913ca58542979a3fd11fef37af0a3890384a9d6aa5902de3187c582babadf69dbed2607081bc9235d6",
65-
"input_utxo": "74e962d27e22fab2cf183e4282d9f2c1154cf8f0e0e277ea5dc89382d353222b#0",
65+
"registration_utxo": "74e962d27e22fab2cf183e4282d9f2c1154cf8f0e0e277ea5dc89382d353222b#0",
6666
"aura_pub_key": "2c4ed1038f6e4131c21b6b89885ed232c5b81bae09009376e9079cc8aa518a1c",
6767
"grandpa_pub_key": "fa41bacb202b0529288b05af1b324f85fe561091c2d29d9df1df37c3aa687c23",
6868
"status": {
@@ -87,7 +87,7 @@
8787
"mainchain_pub_key": "0xcef2d1630c034d3b9034eb7903d61f419a3074a1ad01d4550cc72f2b733de6e7",
8888
"mainchain_signature": "0x9e417ede1ab0d710ce3d5854627baef9b32d4dd69ec75f20d1f28234f167b3f679dadafce995fc63a05eefefa322ebe84b5ffccf526481710d086a16aef61506",
8989
"sidechain_signature": "0x568e305af7f6d51668a76f3aaa72aa3f0f3554be20f150dcabb759f8bff66b484bf66cf248916a40bda649b3ce302ecaf689b9c7b4abd66b44b2aeb039ff85a5",
90-
"input_utxo": "d3600cf1032b2f147d592332032975bc70aff78f78b5be96e4311c0b0b28d7d6#0",
90+
"registration_utxo": "d3600cf1032b2f147d592332032975bc70aff78f78b5be96e4311c0b0b28d7d6#0",
9191
"status": "Active",
9292
"aura_pub_key": "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
9393
"grandpa_pub_key": "88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee"

toolkit/cli/commands/src/registration_signatures.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ impl Display for RegistrationCmdOutput {
6363
pub struct RegisterValidatorMessage {
6464
pub genesis_utxo: UtxoId,
6565
pub sidechain_pub_key: SidechainPublicKey,
66-
pub input_utxo: UtxoId,
66+
pub registration_utxo: UtxoId,
6767
}
6868

6969
impl RegisterValidatorMessage {
70-
pub fn new(genesis_utxo: UtxoId, pub_key: secp256k1::PublicKey, input_utxo: UtxoId) -> Self {
70+
pub fn new(
71+
genesis_utxo: UtxoId,
72+
pub_key: secp256k1::PublicKey,
73+
registration_utxo: UtxoId,
74+
) -> Self {
7175
RegisterValidatorMessage {
7276
genesis_utxo,
7377
sidechain_pub_key: SidechainPublicKey(pub_key.serialize().to_vec()),
74-
input_utxo,
78+
registration_utxo,
7579
}
7680
}
7781

@@ -110,10 +114,11 @@ mod tests {
110114
let genesis_utxo =
111115
UtxoId::from_str("e41c9b57841e582c207bb68d5e9736fb48c7af5f1ec29ade00692fa5e0e47efa#4")
112116
.unwrap();
113-
let input_utxo =
117+
let registration_utxo =
114118
UtxoId::from_str("8ea10040249ad3033ae7c4d4b69e0b2e2b50a90741b783491cb5ddf8ced0d861#4")
115119
.unwrap();
116-
let message = RegisterValidatorMessage::new(genesis_utxo, sidechain_pub_key, input_utxo);
120+
let message =
121+
RegisterValidatorMessage::new(genesis_utxo, sidechain_pub_key, registration_utxo);
117122
assert_eq!(hex::encode(to_datum_cbor_bytes(message)), "d8799fd8799fd8799f5820e41c9b57841e582c207bb68d5e9736fb48c7af5f1ec29ade00692fa5e0e47efaff04ff582102dbfc8b66c22f931a6647fd86db2fc073dd564b99837226a1bdfe7a99578854ecd8799fd8799f58208ea10040249ad3033ae7c4d4b69e0b2e2b50a90741b783491cb5ddf8ced0d861ff04ffff")
118123
}
119124
}

toolkit/mainchain-follower/db-sync-follower/src/candidates/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct ParsedCandidate {
3333
#[derive(Debug)]
3434
struct RegisteredCandidate {
3535
mainchain_pub_key: MainchainPublicKey,
36-
consumed_input: UtxoId,
36+
registration_utxo: UtxoId,
3737
tx_inputs: Vec<UtxoId>,
3838
sidechain_signature: SidechainSignature,
3939
mainchain_signature: MainchainSignature,
@@ -166,7 +166,7 @@ impl CandidatesDataSourceImpl {
166166

167167
fn make_registration_data(c: RegisteredCandidate) -> RegistrationData {
168168
RegistrationData {
169-
consumed_input: c.consumed_input,
169+
registration_utxo: c.registration_utxo,
170170
sidechain_signature: c.sidechain_signature,
171171
mainchain_signature: c.mainchain_signature,
172172
cross_chain_signature: c.cross_chain_signature,
@@ -216,7 +216,7 @@ impl CandidatesDataSourceImpl {
216216
stake_ownership,
217217
sidechain_pub_key,
218218
sidechain_signature,
219-
consumed_input,
219+
registration_utxo,
220220
own_pkh: _own_pkh,
221221
aura_pub_key,
222222
grandpa_pub_key,
@@ -231,7 +231,7 @@ impl CandidatesDataSourceImpl {
231231
sidechain_pub_key,
232232
aura_pub_key,
233233
grandpa_pub_key,
234-
consumed_input,
234+
registration_utxo,
235235
tx_inputs: c.tx_inputs,
236236
utxo_info: c.utxo_info,
237237
})

toolkit/mainchain-follower/db-sync-follower/src/candidates/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn leader_candidate_spo_a() -> CandidateRegistrations {
298298
mainchain_pub_key: MainchainPublicKey(hex!("bfbee74ab533f40979101057f96de62e95233f2a5216eb16b54106f09fd7350d")),
299299
registrations: vec![
300300
RegistrationData {
301-
consumed_input: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 1),
301+
registration_utxo: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 1),
302302
sidechain_signature: SidechainSignature(hex!("f8ec6c7f935d387aaa1693b3bf338cbb8f53013da8a5a234f9c488bacac01af259297e69aee0df27f553c0a1164df827d016125c16af93c99be2c19f36d2f66e").to_vec()),
303303
mainchain_signature: MainchainSignature(hex!("28d1c3b7df297a60d24a3f88bc53d7029a8af35e8dd876764fd9e7a24203a3482a98263cc8ba2ddc7dc8e7faea31c2e7bad1f00e28c43bc863503e3172dc6b0a").to_vec()),
304304
cross_chain_signature: CrossChainSignature(hex!("f8ec6c7f935d387aaa1693b3bf338cbb8f53013da8a5a234f9c488bacac01af259297e69aee0df27f553c0a1164df827d016125c16af93c99be2c19f36d2f66e").to_vec()),
@@ -328,7 +328,7 @@ fn leader_candidate_spo_b() -> CandidateRegistrations {
328328
mainchain_pub_key: MainchainPublicKey(hex!("cfbee74ab533f40979101057f96de62e95233f2a5216eb16b54106f09fd7350d")),
329329
registrations: vec![
330330
RegistrationData {
331-
consumed_input: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 1),
331+
registration_utxo: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 1),
332332
sidechain_signature: SidechainSignature(hex!("f8ec6c7f935d387aaa1693b3bf338cbb8f53013da8a5a234f9c488bacac01af259297e69aee0df27f553c0a1164df827d016125c16af93c99be2c19f36d2f66e").to_vec()),
333333
mainchain_signature: MainchainSignature(hex!("28d1c3b7df297a60d24a3f88bc53d7029a8af35e8dd876764fd9e7a24203a3482a98263cc8ba2ddc7dc8e7faea31c2e7bad1f00e28c43bc863503e3172dc6b0a").to_vec()),
334334
cross_chain_signature: CrossChainSignature(hex!("f8ec6c7f935d387aaa1693b3bf338cbb8f53013da8a5a234f9c488bacac01af259297e69aee0df27f553c0a1164df827d016125c16af93c99be2c19f36d2f66e").to_vec()),
@@ -358,7 +358,7 @@ fn leader_candidate_spo_c() -> CandidateRegistrations {
358358
mainchain_pub_key: MainchainPublicKey(hex!("3fd6618bfcb8d964f44beba4280bd91c6e87ac5bca4aa1c8f1cde9e85352660b")),
359359
registrations: vec![
360360
RegistrationData {
361-
consumed_input: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 2),
361+
registration_utxo: UtxoId::new(hex!("cdefe62b0a0016c2ccf8124d7dda71f6865283667850cc7b471f761d2bc1eb13"), 2),
362362
sidechain_signature: SidechainSignature(hex!("3e8a8b29e513a08d0a66e22422a1a85d1bf409987f30a8c6fcab85ba38a85d0d27793df7e7fb63ace12203b062feb7edb5e6664ac1810b94c38182acc6167425").to_vec()),
363363
mainchain_signature: MainchainSignature(hex!("1fd2f1e5ad14c829c7359474764701cd74ab9c433c29b0bbafaa6bcf22376e9d651391d08ae6f40b418d2abf827c4c1fcb007e779a2beba7894d68012942c708").to_vec()),
364364
cross_chain_signature: CrossChainSignature(hex!("3e8a8b29e513a08d0a66e22422a1a85d1bf409987f30a8c6fcab85ba38a85d0d27793df7e7fb63ace12203b062feb7edb5e6664ac1810b94c38182acc6167425").to_vec()),

toolkit/mainchain-follower/mock/src/candidate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct MockRegistration {
1515
pub mainchain_pub_key: ByteString,
1616
pub mainchain_signature: ByteString,
1717
pub sidechain_signature: ByteString,
18-
pub input_utxo: UtxoId,
18+
pub registration_utxo: UtxoId,
1919
pub status: MockRegistrationStatus,
2020
pub aura_pub_key: ByteString,
2121
pub grandpa_pub_key: ByteString,
@@ -46,7 +46,7 @@ impl From<MockRegistration> for CandidateRegistrations {
4646
"Invalid mock configuration. 'mainchain_pub_key' public key should be 32 bytes.",
4747
));
4848
let registrations = vec![RegistrationData {
49-
consumed_input: mock.input_utxo,
49+
registration_utxo: mock.registration_utxo,
5050
sidechain_signature: SidechainSignature(mock.sidechain_signature.0.clone()),
5151
mainchain_signature: MainchainSignature(mock.mainchain_signature.0),
5252
cross_chain_signature: CrossChainSignature(mock.sidechain_signature.0.clone()),
@@ -64,7 +64,7 @@ impl From<MockRegistration> for CandidateRegistrations {
6464
slot_number: McSlotNumber(123456),
6565
tx_index_within_block: McTxIndexInBlock(12),
6666
},
67-
tx_inputs: vec![mock.input_utxo],
67+
tx_inputs: vec![mock.registration_utxo],
6868
aura_pub_key: AuraPublicKey(mock.aura_pub_key.0),
6969
grandpa_pub_key: GrandpaPublicKey(mock.grandpa_pub_key.0),
7070
}];

toolkit/offchain/src/d_param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ mod tests {
407407
payment_key_utxos: vec![
408408
lesser_payment_utxo(),
409409
greater_payment_utxo(),
410-
make_utxo(11u8, 0, 100000, &payment_addr()),
410+
make_utxo(11u8, 0, 1000000, &payment_addr()),
411411
],
412412
network: NetworkIdKind::Testnet,
413413
protocol_parameters: protocol_parameters(),

toolkit/offchain/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub mod ogmios_mock;
1414
pub mod permissioned_candidates;
1515
/// Utilities for handling Plutus script data
1616
mod plutus_script;
17+
/// Supports candidate registration
18+
mod register;
1719
/// Provides synthetized scripts data
1820
pub mod scripts_data;
1921
#[cfg(test)]

0 commit comments

Comments
 (0)