Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a function for easy Extrinsic decoding of Block #562

Open
haerdib opened this issue May 2, 2023 · 0 comments
Open

Introduce a function for easy Extrinsic decoding of Block #562

haerdib opened this issue May 2, 2023 · 0 comments
Labels
F7-enhancement Enhances an already existing functionality Q3-substantial

Comments

@haerdib
Copy link
Contributor

haerdib commented May 2, 2023

With #541 we decode blocks with OpaqueExtrinsic. As this is not human readable, it would be nice for the users to still have a convenient function to decode the block / extrsinic.

See also the config:

type Block = Block<Self::Header, OpaqueExtrinsic>;

I see two solutions for this:

  1. Design a helper function that lets the user decode an Opaque Extrinsic (input) into a self defined Extrinsic (generic input).
  2. A getter generic getter function, that expects an Extrinsic Type input. Something like this
fn get_signed_runtime_block<Extrinsic: DeserializeOwned>(&self, hash: Option<Hash>) {
    let block_type = ac_primitives::Block<config::Header, Extrinsic>;
     ....
}

Where the user could define the block type with Runtime::RuntimeBlock. Or a convenience function where a Vec of OpaqueExtrinsic gets decoded to a Vec of "real" extrinsic.

Examples for making it clear what's the difference between Opaque and not:
RuntimeBlock:

Some(Block { header: Header { parent_hash: 0xd80617a625261c16d705a3dac9acfd59906e8c2e12a3e8b595e2a8d284b43606, number: 3, state_root: 0x0d16fa7598d4b802c357b90815b82692d0acc84216896f06cff459b793ba8862, extrinsics_root: 0x1f0210efea3486f0c2452bc87b511a127d055f4ddb825d83c54ed040920ff1a7, digest: Digest { logs: [DigestItem::PreRuntime([66, 65, 66, 69], [1, 0, 0, 0, 0, 58, 155, 110, 33, 0, 0, 0, 0, 248, 194, 255, 172, 156, 240, 170, 13, 11, 179, 186, 106, 94, 193, 229, 233, 175, 119, 218, 242, 176, 184, 137, 139, 53, 173, 150, 248, 34, 63, 120, 6, 207, 45, 204, 81, 189, 224, 4, 244, 19, 248, 62, 187, 55, 63, 165, 186, 14, 121, 212, 210, 45, 87, 144, 231, 141, 2, 43, 90, 171, 238, 67, 12, 213, 98, 162, 82, 97, 67, 193, 166, 105, 209, 13, 68, 164, 51, 216, 164, 7, 157, 197, 12, 240, 107, 31, 184, 28, 177, 121, 125, 71, 230, 212, 12]), DigestItem::Seal([66, 65, 66, 69], [142, 123, 71, 63, 12, 254, 31, 33, 132, 40, 175, 199, 98, 102, 126, 150, 13, 4, 20, 181, 175, 103, 111, 128, 147, 185, 42, 151, 64, 177, 202, 28, 115, 128, 195, 231, 212, 47, 32, 165, 37, 237, 250, 120, 141, 147, 15, 168, 27, 94, 117, 252, 205, 109, 77, 124, 147, 22, 233, 60, 60, 43, 127, 139])] } }, extrinsics: [UncheckedExtrinsic(None, RuntimeCall::Timestamp(Call::set { now: 1682690478001 }))] }) 

Opaque Extrinsic Block:

Some(SubstrateBlock { header: SubstrateHeader { parent_hash: 0xcf7dcf0e87422167a4fc033dc77fa5c6a6c3e73d4ac451b56f150dd6b3afe7e8, number: 2, state_root: 0xd1af5a7496757c79d7c64ece5dc5cad5a2f35d9e677113e1a8e412607f228b9b, extrinsics_root: 0x9c52e3c8b4b6fce5852d35b58e3a01bf5f52b2538aa543a0dd4b001445f62fc8, digest: Digest { logs: [PreRuntime([66, 65, 66, 69], [1, 0, 0, 0, 0, 162, 84, 112, 33, 0, 0, 0, 0, 172, 245, 187, 4, 171, 140, 237, 185, 227, 230, 1, 154, 239, 137, 177, 75, 63, 65, 92, 105, 165, 138, 96, 114, 45, 190, 225, 197, 130, 82, 219, 119, 143, 50, 209, 253, 104, 177, 130, 147, 90, 113, 187, 91, 188, 27, 46, 162, 176, 112, 122, 241, 142, 220, 216, 38, 177, 200, 1, 151, 63, 125, 11, 9, 165, 178, 165, 1, 109, 248, 134, 156, 171, 122, 155, 123, 208, 181, 189, 172, 169, 164, 112, 90, 226, 59, 65, 4, 159, 206, 15, 27, 33, 45, 91, 10]), Seal([66, 65, 66, 69], [74, 199, 233, 119, 144, 50, 95, 196, 248, 112, 81, 52, 94, 221, 229, 203, 33, 176, 34, 83, 91, 112, 131, 12, 71, 167, 176, 126, 11, 121, 128, 94, 107, 62, 186, 18, 151, 3, 226, 172, 248, 134, 71, 226, 102, 173, 61, 210, 140, 131, 82, 105, 169, 38, 7, 125, 15, 23, 152, 96, 116, 14, 94, 136])] } }, extrinsics: [SubstrateOpaqueExtrinsic([4, 3, 0, 11, 112, 202, 95, 220, 135, 1])] }) 
@haerdib haerdib added F7-enhancement Enhances an already existing functionality Q3-substantial labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F7-enhancement Enhances an already existing functionality Q3-substantial
Projects
None yet
Development

No branches or pull requests

1 participant