polkascan/py-scale-codec

DigestItem should be t`ype mapping`

Irish-bee opened this issue · 4 comments

in subatrate:

pub enum DigestItem {
	/// A pre-runtime digest.
	///
	/// These are messages from the consensus engine to the runtime, although
	/// the consensus engine can (and should) read them itself to avoid
	/// code and state duplication. It is erroneous for a runtime to produce
	/// these, but this is not (yet) checked.
	///
	/// NOTE: the runtime is not allowed to panic or fail in an `on_initialize`
	/// call if an expected `PreRuntime` digest is not present. It is the
	/// responsibility of a external block verifier to check this. Runtime API calls
	/// will initialize the block without pre-runtime digests, so initialization
	/// cannot fail when they are missing.
	PreRuntime(ConsensusEngineId, Vec<u8>),

	/// A message from the runtime to the consensus engine. This should *never*
	/// be generated by the native code of any consensus engine, but this is not
	/// checked (yet).
	Consensus(ConsensusEngineId, Vec<u8>),

	/// Put a Seal on it. This is only used by native code, and is never seen
	/// by runtimes.
	Seal(ConsensusEngineId, Vec<u8>),

	/// Some other thing. Unsupported and experimental.
	Other(Vec<u8>),

	/// An indication for the light clients that the runtime execution
	/// environment is updated.
	///
	/// Currently this is triggered when:
	/// 1. Runtime code blob is changed or
	/// 2. `heap_pages` value is changed.
	RuntimeEnvironmentUpdated,
}

but in the py-scale-codec:

class LogDigest(Enum):

    value_list = ['Other', 'AuthoritiesChange', 'ChangesTrieRoot', 'SealV0', 'Consensus', 'Seal', 'PreRuntime']

    def __init__(self, data, **kwargs):
        self.log_type = None
        self.index_value = None
        super().__init__(data, **kwargs)

    def process(self):
        self.index = int(self.get_next_bytes(1).hex())
        self.index_value = self.value_list[self.index]
        self.log_type = self.process_type(self.value_list[self.index])

        return {'type': self.value_list[self.index], 'value': self.log_type.value}

The DigestItem you have pointed out is indeed outdated. But this class is actually not used anymore for a while and the actual definition is here:

In fact the type is a CompatibleDigestItem, for reasons mentioned in: paritytech/substrate@8a60b68

I will remove this deprecated class from the code, thanks for reporting!

The DigestItem you have pointed out is indeed outdated. But this class is actually not used anymore for a while and the actual definition is here:

In fact the type is a CompatibleDigestItem, for reasons mentioned in: paritytech/substrate@8a60b68

I will remove this deprecated class from the code, thanks for reporting!

The log is not further parsed in the block:

{'extrinsic_hash': None, 'extrinsic_length': 403, 'call': {'call_index': '0x1100', 'call_function': 'enter', 'call_module': 'ParaInherent', 'call_args': [{'name': 'data', 'type': 'ParachainsInherentData<Header>', 'value': {'bitfields': [{'payload': '0b01', 'validator_index': 0, 'signature': '0xf49dcf120a006ebbec55908c0a9d244215cdb9ff9c066bcfaf0afd3dc6835144b55b41b6431c07169a2fe461eaccf53493473cce20fa3b8a157447e8a18b0e88'}], 'backed_candidates': [], 'disputes': [], 'parent_header': {'parent_hash': '0xb1fe09540b6bed0a77469e07a31dc1fe60c8f2ce7d500859fef667b64a50213e', 'number': 90844, 'state_root': '0x5f35c68e3ce6d10a4127c63440d2e9d63fc6ac9fc26038f7273f47215ee84ada', 'extrinsics_root': '0xb74810a76a8d1d7de534ff6ca41359523904c4d1f98ba972da292e2f2ba6e55b', 'digest': {'logs': [{'PreRuntime': ('0x42414245', '0x03010000000dbc43100000000040501d802a2b01695b3188c0aaef71703829408db70bc0ba17a4c7bec9f6d65dfb693f13838e3e04ba64319fe8f2a94d745bee5113d2e9f1d35f39dae68b530a5a64955ab1db31848b9564ee973230bbce8dafebc4751f8e56049f8f05d8c40f')}, {'Consensus': ('0x42454546', '0x032e5891fe09d028e87c8f8a69d61144e141c4182927543d4f3bec5755dd5a05e4')}, {'Seal': ('0x42414245', '0x58fb5b1603898bc715e5571f70853b7709c459c4e2987e24d9c905abd8a89b08a8482e9ac5d88c0121a589a9035bacb80ebee6d0d1550a5133b97ac5e1a7c28b')}]}}}}], 'call_hash': '0xbb438251b7c0f3e3a14d55f897ec402f432c0f9721d203e0ea2bcf8d254f0df5'}}

Which network are we talking about?

Which network are we talking about?
The latest substarte, and the type_registry is default