From 8ca502d1f2d9a830278a03764dbeb728b4a5b83e Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Tue, 17 Dec 2024 14:43:11 -0400 Subject: [PATCH 01/13] feat: implement `ParachainHost_para_backing_state` runtime call --- dot/parachain/types/async_backing.go | 73 ++++++++++++++++ dot/parachain/types/types.go | 83 ++++++++++++++++++ lib/runtime/constants.go | 6 ++ lib/runtime/test_helpers.go | 3 + lib/runtime/wazero/instance.go | 39 ++++++--- lib/runtime/wazero/instance_test.go | 85 +++++++++++++++++++ .../parachains_host_para_backing_state.yaml | 39 +++++++++ 7 files changed, 316 insertions(+), 12 deletions(-) create mode 100644 lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index 2463f8d645..10f74cb35c 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -17,3 +17,76 @@ type AsyncBackingParams struct { // When async backing is disabled, the only valid value is 0. AllowedAncestryLen uint32 `scale:"2"` } + +// InboundHrmpLimitations constraints on inbound HRMP channels. +type InboundHrmpLimitations struct { + // An exhaustive set of all valid watermarks, sorted ascending. + // + // It's only expected to contain block numbers at which messages were + // previously sent to a para, excluding most recent head. + ValidWatermarks []uint32 +} + +// OutboundHrmpChannelLimitations constraints on outbound HRMP channels. +type OutboundHrmpChannelLimitations struct { + // The maximum bytes that can be written to the channel. + BytesRemaining uint32 + // The maximum messages that can be written to the channel. + MessagesRemaining uint32 +} + +// Constraints on the actions that can be taken by a new parachain block. These +// limitations are implicitly associated with some particular parachain, which should +// be apparent from usage. +type Constraints struct { + // The minimum relay-parent number accepted under these constraints. + MinRelayParentNumber uint32 + // The maximum Proof-of-Validity size allowed, in bytes. + MaxPoVSize uint32 + // The maximum new validation code size allowed, in bytes. + MaxCodeSize uint32 + // The amount of UMP messages remaining. + UmpRemaining uint32 + // The amount of UMP bytes remaining. + UmpRemainingBytes uint32 + // The maximum number of UMP messages allowed per candidate. + MaxUmpNumPerCandidate uint32 + // Remaining DMP queue. Only includes sent-at block numbers. + DmpRemainingMessages []uint32 + // The limitations of all registered inbound HRMP channels. + HrmpInbound InboundHrmpLimitations + // The limitations of all registered outbound HRMP channels. + HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations + // The maximum number of HRMP messages allowed per candidate. + MaxHrmpNumPerCandidate uint32 + // The required parent head-data of the parachain. + RequiredParent HeadData + // The expected validation-code-hash of this parachain. + ValidationCodeHash ValidationCodeHash + // The code upgrade restriction signal as-of this parachain. + UpgradeRestriction *UpgradeRestriction + // The future validation code hash, if any, and at what relay-parent + // number the upgrade would be minimally applied. + FutureValidationCode *FutureValidationCode +} + +// FutureValidationCode represents a tuple of BlockNumber and ValidationCodeHash +type FutureValidationCode struct { + BlockNumber uint32 + ValidationCodeHash ValidationCodeHash +} + +type CandidatePendingAvailability struct { + CandidateHash CandidateHash + Descriptor CandidateDescriptorV2 + Commitments CandidateCommitments + RelayParentNumber BlockNumber + MaxPoVSize uint32 +} + +// BackingState holds the state of the backing system per-parachain, including +// state-machine constraints and candidates pending availability +type BackingState struct { + Constraints Constraints + PendingAvailability []CandidatePendingAvailability +} diff --git a/dot/parachain/types/types.go b/dot/parachain/types/types.go index d69e537178..64e40bae2f 100644 --- a/dot/parachain/types/types.go +++ b/dot/parachain/types/types.go @@ -155,6 +155,39 @@ func (cd CandidateDescriptor) CheckCollatorSignature() error { return sr25519.VerifySignature(cd.Collator[:], cd.Signature[:], payload) } +type CandidateDescriptorV2 struct { + // The ID of the para this is a candidate for. + ParaID ParaID + // RelayParent is the hash of the relay-chain block this should be executed in + // the context of. + RelayParent common.Hash + // Version field. The raw value here is not exposed, instead it is used + // to determine the `CandidateDescriptorVersion`, see `fn version()`. + // For the current version this field is set to `0` and will be incremented + // by next versions. + Version uint8 + // The core index where the candidate is backed. + CoreIndex uint16 + // The session index of the candidate relay parent. + SessionIndex SessionIndex + // Reserved bytes. + Reserved1 [25]uint8 + // PersistedValidationDataHash is the blake2-256 hash of the persisted validation data. This is extra data derived from + // relay-chain state which may vary based on bitfields included before the candidate. + // Thus, it cannot be derived entirely from the relay-parent. + PersistedValidationDataHash common.Hash + // PovHash is the hash of the `pov-block`. + PovHash common.Hash + // ErasureRoot is the root of a block's erasure encoding Merkle tree. + ErasureRoot common.Hash + // Reserved bytes. + Reserved2 [64]uint8 + // ParaHead is the hash of the para header that is being generated by this candidate. + ParaHead common.Hash + // ValidationCodeHash is the blake2-256 hash of the validation code bytes. + ValidationCodeHash ValidationCodeHash +} + // OccupiedCore Information about a core which is currently occupied. type OccupiedCore struct { // NOTE: this has no ParaId as it can be deduced from the candidate descriptor. @@ -740,6 +773,56 @@ type Subsystem interface { Stop() } +// Present is a variant of UpgradeRestriction enumerator that signals +// a upgrade restriction is present and there are no details about its +// specifics nor how long it could last +type Present struct{} + +// UpgradeRestriction a possible restriction that prevents a parachain +// from performing an upgrade +type UpgradeRestriction struct { + inner any +} + +type UpgradeRestrictionValues interface { + Present +} + +func setMyVaryingDataType[Value UpgradeRestrictionValues](mvdt *UpgradeRestriction, value Value) { + mvdt.inner = value +} + +func (mvdt *UpgradeRestriction) SetValue(value any) (err error) { + switch value := value.(type) { + case Present: + setMyVaryingDataType(mvdt, value) + return + default: + return fmt.Errorf("unsupported type") + } +} + +func (mvdt UpgradeRestriction) IndexValue() (index uint, value any, err error) { + switch mvdt.inner.(type) { + case Present: + return 0, mvdt.inner, nil + } + return 0, nil, scale.ErrUnsupportedVaryingDataTypeValue +} + +func (mvdt UpgradeRestriction) Value() (value any, err error) { + _, value, err = mvdt.IndexValue() + return +} + +func (mvdt UpgradeRestriction) ValueAt(index uint) (value any, err error) { + switch index { + case 0: + return Present{}, nil + } + return nil, scale.ErrUnknownVaryingDataTypeValue +} + // CandidateHashAndRelayParent is a pair of candidate hash and relay parent hash type CandidateHashAndRelayParent struct { CandidateHash CandidateHash diff --git a/lib/runtime/constants.go b/lib/runtime/constants.go index d1ba81f58a..0b1b4d4157 100644 --- a/lib/runtime/constants.go +++ b/lib/runtime/constants.go @@ -40,6 +40,11 @@ const ( WESTEND_RUNTIME_V190_FP = "westend_runtime-v190.compact.wasm" WESTEND_RUNTIME_V190_URL = "https://github.com/paritytech/polkadot-sdk/releases/download/" + "polkadot-v1.9.0/westend_runtime.compact.compressed.wasm?raw=true" + + WESTEND_RUNTIME_v1017001 = "westend_runtime-v1017000" + WESTEND_RUNTIME_v1017001_FP = "westend_runtime-v1017000.compact.wasm" + WESTEND_RUNTIME_v1017001_URL = "https://github.com/paritytech/polkadot-sdk/releases/download/" + + "polkadot-stable2412/westend_runtime.compact.compressed.wasm?raw=true" ) const ( @@ -108,4 +113,5 @@ const ( ParachainHostMinimumBackingVotes = "ParachainHost_minimum_backing_votes" // ParachainHostSessionExecutorParams is the runtime API call ParachainHost_session_executor_params ParachainHostSessionExecutorParams = "ParachainHost_session_executor_params" + ParachainHostParaBackingState = "ParachainHost_para_backing_state" ) diff --git a/lib/runtime/test_helpers.go b/lib/runtime/test_helpers.go index c7af14d664..69f07f3047 100644 --- a/lib/runtime/test_helpers.go +++ b/lib/runtime/test_helpers.go @@ -88,6 +88,9 @@ func GetRuntime(ctx context.Context, runtime string) ( case WESTEND_RUNTIME_v190: runtimeFilename = WESTEND_RUNTIME_V190_FP url = WESTEND_RUNTIME_V190_URL + case WESTEND_RUNTIME_v1017001: + runtimeFilename = WESTEND_RUNTIME_v1017001_FP + url = WESTEND_RUNTIME_v1017001_URL default: return "", fmt.Errorf("%w: %s", ErrRuntimeUnknown, runtime) } diff --git a/lib/runtime/wazero/instance.go b/lib/runtime/wazero/instance.go index 02882cdda4..ebb5c3a001 100644 --- a/lib/runtime/wazero/instance.go +++ b/lib/runtime/wazero/instance.go @@ -115,7 +115,7 @@ func NewInstanceFromTrie(t trie.Trie, cfg Config) (*Instance, error) { func newRuntime(ctx context.Context, code []byte, config wazero.RuntimeConfig, -) (api.Module, wazero.Runtime, wazero.CompiledModule, error) { +) (wazero.Runtime, wazero.CompiledModule, error) { rt := wazero.NewRuntimeWithConfig(ctx, config) const i32, i64 = api.ValueTypeI32, api.ValueTypeI64 @@ -645,29 +645,25 @@ func newRuntime(ctx context.Context, Compile(ctx) if err != nil { - return nil, nil, nil, err + return nil, nil, err } _, err = rt.InstantiateModule(ctx, hostCompiledModule, wazero.NewModuleConfig()) if err != nil { - return nil, nil, nil, err + return nil, nil, err } code, err = decompressWasm(code) if err != nil { - return nil, nil, nil, err + return nil, nil, err } guestCompiledModule, err := rt.CompileModule(ctx, code) if err != nil { - return nil, nil, nil, err - } - mod, err := rt.Instantiate(ctx, code) - if err != nil { - return nil, nil, nil, err + return nil, nil, err } - return mod, rt, guestCompiledModule, nil + return rt, guestCompiledModule, nil } // NewInstance instantiates a runtime from raw wasm bytecode @@ -679,7 +675,7 @@ func NewInstance(code []byte, cfg Config) (instance *Instance, err error) { ctx := context.Background() cache := wazero.NewCompilationCache() config := wazero.NewRuntimeConfig().WithCompilationCache(cache) - mod, rt, guestCompiledModule, err := newRuntime(ctx, code, config) + rt, guestCompiledModule, err := newRuntime(ctx, code, config) if err != nil { return nil, fmt.Errorf("creating runtime instance: %w", err) } @@ -696,7 +692,6 @@ func NewInstance(code []byte, cfg Config) (instance *Instance, err error) { SigVerifier: crypto.NewSignatureVerifier(logger), OffchainHTTPSet: offchain.NewHTTPSet(), }, - Module: mod, codeHash: cfg.CodeHash, metadata: wazeroMeta{ config: config, @@ -1420,6 +1415,26 @@ func (in *Instance) ParachainHostSessionExecutorParams(index parachaintypes.Sess return ¶ms, nil } +func (in *Instance) ParachainHostParaBackingState(paraID parachaintypes.ParaID) (*parachaintypes.BackingState, error) { + encodedParaID, err := scale.Marshal(paraID) + if err != nil { + return nil, fmt.Errorf("encoding parachain ID: %w", err) + } + + encodedBackingState, err := in.Exec(runtime.ParachainHostParaBackingState, encodedParaID) + if err != nil { + return nil, fmt.Errorf("exec: %w", err) + } + + var backingState *parachaintypes.BackingState + err = scale.Unmarshal(encodedBackingState, &backingState) + if err != nil { + return nil, fmt.Errorf("unmarshalling backing state: %w", err) + } + + return backingState, nil +} + func (*Instance) RandomSeed() { panic("unimplemented") } diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index 564e7671dc..91d13ae156 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -42,6 +42,9 @@ var parachainTestDataRaw string //go:embed testdata/parachains_configuration_v190.yaml var parachainsConfigV190TestDataRaw string +//go:embed testdata/parachains_host_para_backing_state.yaml +var parachainsHostParaBackingState string + type Storage struct { Name string `yaml:"name"` Key string `yaml:"key"` @@ -1710,6 +1713,88 @@ func TestInstance_ParachainHostSessionExecutorParams(t *testing.T) { require.Empty(t, params) } +func TestInstance_ParachainHostParaBackingState(t *testing.T) { + t.Parallel() + var backingStateData Data + err := yaml.Unmarshal([]byte(parachainsHostParaBackingState), &backingStateData) + require.NoError(t, err) + + paraID := parachaintypes.ParaID(1001) + tt := getParachainHostTrie(t, backingStateData.Storage) + rt := NewTestInstance(t, runtime.WESTEND_RUNTIME_v1017001, TestWithTrie(tt)) + + backingState, err := rt.ParachainHostParaBackingState(paraID) + require.NoError(t, err) + + upgradeRestriction := ¶chaintypes.UpgradeRestriction{} + require.NoError(t, upgradeRestriction.SetValue(parachaintypes.Present{})) + + expectedBakingState := ¶chaintypes.BackingState{ + Constraints: parachaintypes.Constraints{ + MinRelayParentNumber: 23920837, + MaxPoVSize: 5242880, + MaxCodeSize: 3145728, + UmpRemaining: 1398101, + UmpRemainingBytes: 8388608, + MaxUmpNumPerCandidate: 512, + MaxHrmpNumPerCandidate: 10, + RequiredParent: parachaintypes.HeadData{ + Data: common.MustHexToBytes("0x1b5270c5d767d30a43a1d3f66e4c8414bd9b9bd502d3620601a00b" + + "2d3484bf042a84aa0138b82ea524764ca4b2e88c7069dc898d23d1997e212b490a2349853161a7de" + + "0931ff60595b16ed500e749c3c145ec9ce1ef7dd81b6a1d266d791a65665917ccb0c066175726120" + + "24f53a11000000000452505352905fe786d355e3b806965ee4d2757e536d593a90530606cb6bc632" + + "bf72137c66653603b40505617572610101268a2683d59ea42fb24cf323c46e7b39374591ad61fa03" + + "ad0102fa65c32b5e292491eb6c32cc9d88fbf13bcda19231688079ba2759e263acc25fd4b8dc60938f"), + }, + UpgradeRestriction: upgradeRestriction, + ValidationCodeHash: parachaintypes.ValidationCodeHash( + common.MustHexToBytes( + "0x59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf347")), + }, + PendingAvailability: []parachaintypes.CandidatePendingAvailability{ + { + RelayParentNumber: 23920925, + MaxPoVSize: 5242880, + CandidateHash: parachaintypes.CandidateHash{ + Value: common.Hash( + common.MustHexToBytes("0x44f58a0b350c80250427227f0c7e81dabc3b85e33c1864ed115bb8759f60874f")), + }, + Descriptor: parachaintypes.CandidateDescriptorV2{ + ParaID: 1001, + RelayParent: common.MustHexToHash( + "0x40b834a772284d4e27a66564bd63e2a03f0711f67d7751bcad172dac4f73b11f"), + Version: 240, + CoreIndex: 57316, + SessionIndex: 1906958206, + Reserved1: [25]uint8(common.MustHexToBytes("0x27de1f4ef0afe2b4837f42aaf29690236b6bdb60c85b1d5b32")), + PersistedValidationDataHash: common.MustHexToHash( + "0x0157d5bc5c7d6a6bccf367fd61ef2151c58bf4b401e1fa00db83f55387658a7e"), + PovHash: common.MustHexToHash("0xf831bcc17aa290dad89ac3ca6a0a5370baf95937728cfac4a089474ca1229cc7"), + ErasureRoot: common.MustHexToHash("0x082963b364af8ee0a645f291bf8836ed7e8ed8e393c3aad44ad9c79b9506b578"), + Reserved2: [64]uint8(common.MustHexToBytes("0x64c84d5afd3da75a717f9689a299cb8aed9159db136440fe221c440" + + "0a15fb16bab9133fffe4364c80fd4035024e42a6d2f0aca23cd50028ee8a24397967f338e")), + ParaHead: common.MustHexToHash("0xbece074cebf86b95ea2ccab3ce28d1e90d89fca774d95b9ac9540b283484474d"), + ValidationCodeHash: parachaintypes.ValidationCodeHash( + common.MustHexToBytes("0x59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf347")), + }, + Commitments: parachaintypes.CandidateCommitments{ + HeadData: parachaintypes.HeadData{ + Data: common.MustHexToBytes("0xce21d522a334adb0a09f4b755409b17a85a67e8152fb76952e51bd61268e73b63a" + + "85aa011ebf7dad71dbf3579be222072c0587dc6c7c829a7319f8780b1ec8bca21f509d5582f701d2adaac9efbb6c" + + "696a7d5e20080988a20a3a68f25d6d7830d68b47ad0c06617572612074f53a110000000004525053529035f969d2" + + "20c83086d53d64c94d8bd0914d549eb02a48f2f5e841b1bf63a2aadc7604b40505617572610101a625c2ce9ec9b4" + + "3ddd7b97c328827b3e8b05dd6f28cec160f6fa3d08c756e038b14f63752c754463d510763e4702cb37c0660ab103" + + "7777091c97deb6004f8e8b"), + }, + HrmpWatermark: 23920925, + }, + }, + }, + } + + require.Equal(t, expectedBakingState, backingState) +} + func getParachainHostTrie(t *testing.T, testDataStorage []Storage) *inmemory_trie.InMemoryTrie { tt := inmemory_trie.NewEmptyTrie() diff --git a/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml b/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml new file mode 100644 index 0000000000..4cd3cd5d36 --- /dev/null +++ b/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml @@ -0,0 +1,39 @@ +# taken from https://polkadot.js.org/apps/#/chainstate (westend) + +storage: + # configuration.activeConfig + - key: "0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385" + value: "0x00003000005000005555150000008000fbff0100000200000a000000c80000006400000003000000020000000000500000c800000a00000000c0220fca950300000000000000000000c0220fca9503000000000000000000e8030000009001000a00000000900100008070000001c800000006000000580200000200000028000000000000000200000001000000020000000f0000000200000000010000000a0000000500000001050000000200000006000000000000001027000080b2e60e80c3c9018096980000000000000000000000000005000000" + # block number + - key: "0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac" + value: "0xc7006d01" + # shared allowed relay parents + - key: "0xb341e3a63e58a188839b242d17f8c9f89d1fb17def62216d598940d64654f69e" + value: "0x0cee630259bee2c83ef030667ca14d56a75e3a8b0e1caeb0205ecfb2af6f4acced8e34443e95a12ed5a5ce780567b34673fa9aecaa5aa0d029050102bebf4eb02120e803000008000400000000010400000000e903000008000401000000010401000000ea03000008000402000000010402000000ec03000008000403000000010403000000ed03000008000404000000010404000000e607000008000406000000010406000000fa070000080004110000000104110000009908000008000408000000010408000000606e01a1f0f1facbdf29225c6b0e9a705e752ee35a79a31c841363ecd7e28abdfbe4e82aa4686ddcac5a5a6a857568fcdd2c848f93a25cc3180964fa9fe2086b20e803000008000400000000010400000000e903000008000401000000010401000000ea03000008000402000000010402000000ec03000008000403000000010403000000ed03000008000404000000010404000000e607000008000406000000010406000000fa070000080004110000000104110000009908000008000408000000010408000000f73b1ec2bd153f8d3eff42aae02e3c8cc893b008449977640632c131f56f490dad6a6d4d4fe2a6be72b503ddebc045a7eb67e2b66cb6e509d3b6b77021b6909b20e803000008000400000000010400000000e903000008000401000000010401000000ea03000008000402000000010402000000ec03000008000403000000010403000000ed03000008000404000000010404000000e607000008000406000000010406000000fa070000080004110000000104110000009908000008000408000000010408000000c4006d01" + # paras heads for paraID 1001 + - key: "0xcd710b30bd2eab0352ddcc26417aa1941b3c252fcb29d88eff4f3de5de4476c3adc7217647a32b0be9030000" + value: "0x91031b5270c5d767d30a43a1d3f66e4c8414bd9b9bd502d3620601a00b2d3484bf042a84aa0138b82ea524764ca4b2e88c7069dc898d23d1997e212b490a2349853161a7de0931ff60595b16ed500e749c3c145ec9ce1ef7dd81b6a1d266d791a65665917ccb0c06617572612024f53a11000000000452505352905fe786d355e3b806965ee4d2757e536d593a90530606cb6bc632bf72137c66653603b40505617572610101268a2683d59ea42fb24cf323c46e7b39374591ad61fa03ad0102fa65c32b5e292491eb6c32cc9d88fbf13bcda19231688079ba2759e263acc25fd4b8dc60938f" + # paras current code hash for paraID 1001 + - key: "0xcd710b30bd2eab0352ddcc26417aa194e2d1c22ba0a888147714a3487bd51c63adc7217647a32b0be9030000" + value: "0x59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf347" + # paras upgrade restriction signal for paraID 1001 + - key: "0xcd710b30bd2eab0352ddcc26417aa194f27bbb460270642b5bcaf032ea04d56aadc7217647a32b0be9030000" + value: "0x00" + # dmp contents for paraID 1001 + - key: "0x63f78c98723ddc9073523ef3beefda0ca95dac46c07a40d91506e7637ec4ba57adc7217647a32b0be9030000" + value: "0x00" + # hrmp valid watermarks for paraID 1001 + - key: "0x6a0da05ca59913bc38a8630590f2627ce0e67da63472835bb0b737093a19ad4cadc7217647a32b0be9030000" + value: "0x00" + # hrmp egress channel for paraID 1001 + - key: "0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c507445948adc7217647a32b0be9030000" + value: "0x08e8030000ea030000" + # hrmp channel 1001 -> 1000 + - key: "0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013dcf47a11a24166564e9030000e8030000" + value: "0xe8030000009001000090010000000000000000000163d1c8be9b89007d87884f4b584da46e87926353bd7cbe69672a677ab1830b1f00c0220fca950300000000000000000000c0220fca9503000000000000000000" + # hrmp channel 1001 -> 1002 + - key: "0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013d3bb01d9a75043f08e9030000ea030000" + value: "0xe8030000009001000090010000000000000000000000c0220fca950300000000000000000000c0220fca9503000000000000000000" + # inclusion pending availability for paraID 1001 + - key: "0x196e027349017067f9eb56e2c4d9ded594d373b60dded722a8c2fa795bda8971adc7217647a32b0be9030000" + value: "0x040100000044f58a0b350c80250427227f0c7e81dabc3b85e33c1864ed115bb8759f60874fe903000040b834a772284d4e27a66564bd63e2a03f0711f67d7751bcad172dac4f73b11ff0e4df7edfa97127de1f4ef0afe2b4837f42aaf29690236b6bdb60c85b1d5b320157d5bc5c7d6a6bccf367fd61ef2151c58bf4b401e1fa00db83f55387658a7ef831bcc17aa290dad89ac3ca6a0a5370baf95937728cfac4a089474ca1229cc7082963b364af8ee0a645f291bf8836ed7e8ed8e393c3aad44ad9c79b9506b57864c84d5afd3da75a717f9689a299cb8aed9159db136440fe221c4400a15fb16bab9133fffe4364c80fd4035024e42a6d2f0aca23cd50028ee8a24397967f338ebece074cebf86b95ea2ccab3ce28d1e90d89fca774d95b9ac9540b283484474d59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf3470000009103ce21d522a334adb0a09f4b755409b17a85a67e8152fb76952e51bd61268e73b63a85aa011ebf7dad71dbf3579be222072c0587dc6c7c829a7319f8780b1ec8bca21f509d5582f701d2adaac9efbb6c696a7d5e20080988a20a3a68f25d6d7830d68b47ad0c06617572612074f53a110000000004525053529035f969d220c83086d53d64c94d8bd0914d549eb02a48f2f5e841b1bf63a2aadc7604b40505617572610101a625c2ce9ec9b43ddd7b97c328827b3e8b05dd6f28cec160f6fa3d08c756e038b14f63752c754463d510763e4702cb37c0660ab1037777091c97deb6004f8e8b000000001d016d0148000000482000001d016d011f016d0105000000" From b7a93fb6c9730b72ad8f68255d073f051102e640 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Tue, 17 Dec 2024 15:08:09 -0400 Subject: [PATCH 02/13] chore: stop keeping a live instance of the runtime under `wazero.Instance.Module` --- lib/runtime/wazero/imports_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/runtime/wazero/imports_test.go b/lib/runtime/wazero/imports_test.go index 0a11427ec0..15ea8d1530 100644 --- a/lib/runtime/wazero/imports_test.go +++ b/lib/runtime/wazero/imports_test.go @@ -31,6 +31,7 @@ import ( "github.com/ChainSafe/gossamer/pkg/trie/inmemory/proof" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tetratelabs/wazero" ) var DefaultVersion = &runtime.Version{ @@ -910,18 +911,22 @@ func Test_ext_misc_runtime_version_version_1(t *testing.T) { } } + mod, err := inst.Runtime.InstantiateModule( + context.Background(), inst.metadata.guestModule, wazero.NewModuleConfig()) + require.NoError(t, err) + allocator := allocator.NewFreeingBumpHeapAllocator(0) inst.Context.Allocator = allocator data := bytes dataLength := uint32(len(data)) - inputPtr, err := inst.Context.Allocator.Allocate(inst.Module.Memory(), dataLength) + inputPtr, err := inst.Context.Allocator.Allocate(mod.Memory(), dataLength) if err != nil { t.Errorf("allocating input memory: %v", err) } // Store the data into memory - mem := inst.Module.Memory() + mem := mod.Memory() ok := mem.Write(inputPtr, data) if !ok { panic("write overlow") @@ -929,10 +934,10 @@ func Test_ext_misc_runtime_version_version_1(t *testing.T) { dataSpan := newPointerSize(inputPtr, dataLength) ctx := context.WithValue(context.Background(), runtimeContextKey, inst.Context) - versionPtr := ext_misc_runtime_version_version_1(ctx, inst.Module, dataSpan) + versionPtr := ext_misc_runtime_version_version_1(ctx, mod, dataSpan) var option *[]byte - versionData := read(inst.Module, versionPtr) + versionData := read(mod, versionPtr) err = scale.Unmarshal(versionData, &option) require.NoError(t, err) require.NotNil(t, option) From 3db15409aa1c4f7051b10894e38903fa8c08e484 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Tue, 17 Dec 2024 15:11:08 -0400 Subject: [PATCH 03/13] chore: removes `Module` field from instance --- lib/runtime/wazero/instance.go | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/runtime/wazero/instance.go b/lib/runtime/wazero/instance.go index ebb5c3a001..16141c682b 100644 --- a/lib/runtime/wazero/instance.go +++ b/lib/runtime/wazero/instance.go @@ -50,7 +50,6 @@ type wazeroMeta struct { // Instance backed by wazero.Runtime type Instance struct { Runtime wazero.Runtime - Module api.Module Context *runtime.Context wasmByteCode []byte codeHash common.Hash From 8068ed5eaf1e84154dcddb4b7c5cf201de76254d Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 08:26:40 -0400 Subject: [PATCH 04/13] chore: addressing comments --- dot/parachain/types/async_backing.go | 6 +++--- lib/runtime/wazero/instance_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index 10f74cb35c..c7b6bacf26 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -24,7 +24,7 @@ type InboundHrmpLimitations struct { // // It's only expected to contain block numbers at which messages were // previously sent to a para, excluding most recent head. - ValidWatermarks []uint32 + ValidWatermarks []BlockNumber } // OutboundHrmpChannelLimitations constraints on outbound HRMP channels. @@ -40,7 +40,7 @@ type OutboundHrmpChannelLimitations struct { // be apparent from usage. type Constraints struct { // The minimum relay-parent number accepted under these constraints. - MinRelayParentNumber uint32 + MinRelayParentNumber BlockNumber // The maximum Proof-of-Validity size allowed, in bytes. MaxPoVSize uint32 // The maximum new validation code size allowed, in bytes. @@ -72,7 +72,7 @@ type Constraints struct { // FutureValidationCode represents a tuple of BlockNumber and ValidationCodeHash type FutureValidationCode struct { - BlockNumber uint32 + BlockNumber BlockNumber ValidationCodeHash ValidationCodeHash } diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index 91d13ae156..77e74d0bff 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -1729,7 +1729,7 @@ func TestInstance_ParachainHostParaBackingState(t *testing.T) { upgradeRestriction := ¶chaintypes.UpgradeRestriction{} require.NoError(t, upgradeRestriction.SetValue(parachaintypes.Present{})) - expectedBakingState := ¶chaintypes.BackingState{ + expectedBackingState := ¶chaintypes.BackingState{ Constraints: parachaintypes.Constraints{ MinRelayParentNumber: 23920837, MaxPoVSize: 5242880, @@ -1792,7 +1792,7 @@ func TestInstance_ParachainHostParaBackingState(t *testing.T) { }, } - require.Equal(t, expectedBakingState, backingState) + require.Equal(t, expectedBackingState, backingState) } func getParachainHostTrie(t *testing.T, testDataStorage []Storage) *inmemory_trie.InMemoryTrie { From c33e13234cab650f33560f45e24e6a002291d8bd Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 12:16:47 -0400 Subject: [PATCH 05/13] chore: address comments --- dot/parachain/types/async_backing.go | 52 +++++++++---------- dot/parachain/types/types.go | 24 ++++----- dot/parachain/types/types_test.go | 12 +++++ lib/runtime/wazero/instance_test.go | 5 +- .../parachains_host_para_backing_state.yaml | 3 -- 5 files changed, 51 insertions(+), 45 deletions(-) diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index c7b6bacf26..1bbe90fb5f 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -24,15 +24,15 @@ type InboundHrmpLimitations struct { // // It's only expected to contain block numbers at which messages were // previously sent to a para, excluding most recent head. - ValidWatermarks []BlockNumber + ValidWatermarks []BlockNumber `scale:"1"` } // OutboundHrmpChannelLimitations constraints on outbound HRMP channels. type OutboundHrmpChannelLimitations struct { // The maximum bytes that can be written to the channel. - BytesRemaining uint32 + BytesRemaining uint32 `scale:"1"` // The maximum messages that can be written to the channel. - MessagesRemaining uint32 + MessagesRemaining uint32 `scale:"2"` } // Constraints on the actions that can be taken by a new parachain block. These @@ -40,53 +40,53 @@ type OutboundHrmpChannelLimitations struct { // be apparent from usage. type Constraints struct { // The minimum relay-parent number accepted under these constraints. - MinRelayParentNumber BlockNumber + MinRelayParentNumber BlockNumber `scale:"1"` // The maximum Proof-of-Validity size allowed, in bytes. - MaxPoVSize uint32 + MaxPoVSize uint32 `scale:"2"` // The maximum new validation code size allowed, in bytes. - MaxCodeSize uint32 + MaxCodeSize uint32 `scale:"3"` // The amount of UMP messages remaining. - UmpRemaining uint32 + UmpRemaining uint32 `scale:"4"` // The amount of UMP bytes remaining. - UmpRemainingBytes uint32 + UmpRemainingBytes uint32 `scale:"5"` // The maximum number of UMP messages allowed per candidate. - MaxUmpNumPerCandidate uint32 + MaxUmpNumPerCandidate uint32 `scale:"6"` // Remaining DMP queue. Only includes sent-at block numbers. - DmpRemainingMessages []uint32 + DmpRemainingMessages []uint32 `scale:"7"` // The limitations of all registered inbound HRMP channels. - HrmpInbound InboundHrmpLimitations + HrmpInbound InboundHrmpLimitations `scale:"8"` // The limitations of all registered outbound HRMP channels. - HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations + HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations `scale:"9"` // The maximum number of HRMP messages allowed per candidate. - MaxHrmpNumPerCandidate uint32 + MaxHrmpNumPerCandidate uint32 `scale:"10"` // The required parent head-data of the parachain. - RequiredParent HeadData + RequiredParent HeadData `scale:"11"` // The expected validation-code-hash of this parachain. - ValidationCodeHash ValidationCodeHash + ValidationCodeHash ValidationCodeHash `scale:"12"` // The code upgrade restriction signal as-of this parachain. - UpgradeRestriction *UpgradeRestriction + UpgradeRestriction *UpgradeRestriction `scale:"13"` // The future validation code hash, if any, and at what relay-parent // number the upgrade would be minimally applied. - FutureValidationCode *FutureValidationCode + FutureValidationCode *FutureValidationCode `scale:"15"` } // FutureValidationCode represents a tuple of BlockNumber and ValidationCodeHash type FutureValidationCode struct { - BlockNumber BlockNumber - ValidationCodeHash ValidationCodeHash + BlockNumber BlockNumber `scale:"1"` + ValidationCodeHash ValidationCodeHash `scale:"2"` } type CandidatePendingAvailability struct { - CandidateHash CandidateHash - Descriptor CandidateDescriptorV2 - Commitments CandidateCommitments - RelayParentNumber BlockNumber - MaxPoVSize uint32 + CandidateHash CandidateHash `scale:"1"` + Descriptor CandidateDescriptorV2 `scale:"2"` + Commitments CandidateCommitments `scale:"3"` + RelayParentNumber BlockNumber `scale:"4"` + MaxPoVSize uint32 `scale:"5"` } // BackingState holds the state of the backing system per-parachain, including // state-machine constraints and candidates pending availability type BackingState struct { - Constraints Constraints - PendingAvailability []CandidatePendingAvailability + Constraints Constraints `scale:"1"` + PendingAvailability []CandidatePendingAvailability `scale:"2"` } diff --git a/dot/parachain/types/types.go b/dot/parachain/types/types.go index 64e40bae2f..4c11d51b27 100644 --- a/dot/parachain/types/types.go +++ b/dot/parachain/types/types.go @@ -157,35 +157,35 @@ func (cd CandidateDescriptor) CheckCollatorSignature() error { type CandidateDescriptorV2 struct { // The ID of the para this is a candidate for. - ParaID ParaID + ParaID ParaID `scale:"1"` // RelayParent is the hash of the relay-chain block this should be executed in // the context of. - RelayParent common.Hash + RelayParent common.Hash `scale:"2"` // Version field. The raw value here is not exposed, instead it is used // to determine the `CandidateDescriptorVersion`, see `fn version()`. // For the current version this field is set to `0` and will be incremented // by next versions. - Version uint8 + Version uint8 `scale:"3"` // The core index where the candidate is backed. - CoreIndex uint16 + CoreIndex uint16 `scale:"4"` // The session index of the candidate relay parent. - SessionIndex SessionIndex + SessionIndex SessionIndex `scale:"5"` // Reserved bytes. - Reserved1 [25]uint8 + Reserved1 [25]uint8 `scale:"6"` // PersistedValidationDataHash is the blake2-256 hash of the persisted validation data. This is extra data derived from // relay-chain state which may vary based on bitfields included before the candidate. // Thus, it cannot be derived entirely from the relay-parent. - PersistedValidationDataHash common.Hash + PersistedValidationDataHash common.Hash `scale:"7"` // PovHash is the hash of the `pov-block`. - PovHash common.Hash + PovHash common.Hash `scale:"8"` // ErasureRoot is the root of a block's erasure encoding Merkle tree. - ErasureRoot common.Hash + ErasureRoot common.Hash `scale:"9"` // Reserved bytes. - Reserved2 [64]uint8 + Reserved2 [64]uint8 `scale:"10"` // ParaHead is the hash of the para header that is being generated by this candidate. - ParaHead common.Hash + ParaHead common.Hash `scale:"11"` // ValidationCodeHash is the blake2-256 hash of the validation code bytes. - ValidationCodeHash ValidationCodeHash + ValidationCodeHash ValidationCodeHash `scale:"12"` } // OccupiedCore Information about a core which is currently occupied. diff --git a/dot/parachain/types/types_test.go b/dot/parachain/types/types_test.go index abdc4fe69d..63c7f5bc2a 100644 --- a/dot/parachain/types/types_test.go +++ b/dot/parachain/types/types_test.go @@ -426,3 +426,15 @@ func TestOccupiedCoreAssumption(t *testing.T) { }) } } + +func TestUpgradeRestrictionEncodingDecoding(t *testing.T) { + presentVariant := []byte{0} + var restriction UpgradeRestriction + + require.NoError(t, scale.Unmarshal(presentVariant, &restriction)) + + expectedRestriction := &UpgradeRestriction{} + require.NoError(t, expectedRestriction.SetValue(Present{})) + + require.Equal(t, expectedRestriction, &restriction) +} diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index 77e74d0bff..c63a77fa55 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -1726,9 +1726,6 @@ func TestInstance_ParachainHostParaBackingState(t *testing.T) { backingState, err := rt.ParachainHostParaBackingState(paraID) require.NoError(t, err) - upgradeRestriction := ¶chaintypes.UpgradeRestriction{} - require.NoError(t, upgradeRestriction.SetValue(parachaintypes.Present{})) - expectedBackingState := ¶chaintypes.BackingState{ Constraints: parachaintypes.Constraints{ MinRelayParentNumber: 23920837, @@ -1746,7 +1743,7 @@ func TestInstance_ParachainHostParaBackingState(t *testing.T) { "bf72137c66653603b40505617572610101268a2683d59ea42fb24cf323c46e7b39374591ad61fa03" + "ad0102fa65c32b5e292491eb6c32cc9d88fbf13bcda19231688079ba2759e263acc25fd4b8dc60938f"), }, - UpgradeRestriction: upgradeRestriction, + UpgradeRestriction: nil, ValidationCodeHash: parachaintypes.ValidationCodeHash( common.MustHexToBytes( "0x59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf347")), diff --git a/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml b/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml index 4cd3cd5d36..7d007b1211 100644 --- a/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml +++ b/lib/runtime/wazero/testdata/parachains_host_para_backing_state.yaml @@ -16,9 +16,6 @@ storage: # paras current code hash for paraID 1001 - key: "0xcd710b30bd2eab0352ddcc26417aa194e2d1c22ba0a888147714a3487bd51c63adc7217647a32b0be9030000" value: "0x59558a80dfcf74536b9f6fcba7416490211b22f29cc750a8bcb4993ea53cf347" - # paras upgrade restriction signal for paraID 1001 - - key: "0xcd710b30bd2eab0352ddcc26417aa194f27bbb460270642b5bcaf032ea04d56aadc7217647a32b0be9030000" - value: "0x00" # dmp contents for paraID 1001 - key: "0x63f78c98723ddc9073523ef3beefda0ca95dac46c07a40d91506e7637ec4ba57adc7217647a32b0be9030000" value: "0x00" From 4db6fcb34a1586f0264e114b3031496ccb84de4e Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 14:04:38 -0400 Subject: [PATCH 06/13] Trigger Build From ee0d791a0b0d27987156ca2c68074f2019eca62f Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 14:09:52 -0400 Subject: [PATCH 07/13] chore: remove unneeded scale tags --- dot/parachain/types/async_backing.go | 52 ++++++++++++++-------------- dot/parachain/types/types.go | 24 ++++++------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index 1bbe90fb5f..c7b6bacf26 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -24,15 +24,15 @@ type InboundHrmpLimitations struct { // // It's only expected to contain block numbers at which messages were // previously sent to a para, excluding most recent head. - ValidWatermarks []BlockNumber `scale:"1"` + ValidWatermarks []BlockNumber } // OutboundHrmpChannelLimitations constraints on outbound HRMP channels. type OutboundHrmpChannelLimitations struct { // The maximum bytes that can be written to the channel. - BytesRemaining uint32 `scale:"1"` + BytesRemaining uint32 // The maximum messages that can be written to the channel. - MessagesRemaining uint32 `scale:"2"` + MessagesRemaining uint32 } // Constraints on the actions that can be taken by a new parachain block. These @@ -40,53 +40,53 @@ type OutboundHrmpChannelLimitations struct { // be apparent from usage. type Constraints struct { // The minimum relay-parent number accepted under these constraints. - MinRelayParentNumber BlockNumber `scale:"1"` + MinRelayParentNumber BlockNumber // The maximum Proof-of-Validity size allowed, in bytes. - MaxPoVSize uint32 `scale:"2"` + MaxPoVSize uint32 // The maximum new validation code size allowed, in bytes. - MaxCodeSize uint32 `scale:"3"` + MaxCodeSize uint32 // The amount of UMP messages remaining. - UmpRemaining uint32 `scale:"4"` + UmpRemaining uint32 // The amount of UMP bytes remaining. - UmpRemainingBytes uint32 `scale:"5"` + UmpRemainingBytes uint32 // The maximum number of UMP messages allowed per candidate. - MaxUmpNumPerCandidate uint32 `scale:"6"` + MaxUmpNumPerCandidate uint32 // Remaining DMP queue. Only includes sent-at block numbers. - DmpRemainingMessages []uint32 `scale:"7"` + DmpRemainingMessages []uint32 // The limitations of all registered inbound HRMP channels. - HrmpInbound InboundHrmpLimitations `scale:"8"` + HrmpInbound InboundHrmpLimitations // The limitations of all registered outbound HRMP channels. - HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations `scale:"9"` + HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations // The maximum number of HRMP messages allowed per candidate. - MaxHrmpNumPerCandidate uint32 `scale:"10"` + MaxHrmpNumPerCandidate uint32 // The required parent head-data of the parachain. - RequiredParent HeadData `scale:"11"` + RequiredParent HeadData // The expected validation-code-hash of this parachain. - ValidationCodeHash ValidationCodeHash `scale:"12"` + ValidationCodeHash ValidationCodeHash // The code upgrade restriction signal as-of this parachain. - UpgradeRestriction *UpgradeRestriction `scale:"13"` + UpgradeRestriction *UpgradeRestriction // The future validation code hash, if any, and at what relay-parent // number the upgrade would be minimally applied. - FutureValidationCode *FutureValidationCode `scale:"15"` + FutureValidationCode *FutureValidationCode } // FutureValidationCode represents a tuple of BlockNumber and ValidationCodeHash type FutureValidationCode struct { - BlockNumber BlockNumber `scale:"1"` - ValidationCodeHash ValidationCodeHash `scale:"2"` + BlockNumber BlockNumber + ValidationCodeHash ValidationCodeHash } type CandidatePendingAvailability struct { - CandidateHash CandidateHash `scale:"1"` - Descriptor CandidateDescriptorV2 `scale:"2"` - Commitments CandidateCommitments `scale:"3"` - RelayParentNumber BlockNumber `scale:"4"` - MaxPoVSize uint32 `scale:"5"` + CandidateHash CandidateHash + Descriptor CandidateDescriptorV2 + Commitments CandidateCommitments + RelayParentNumber BlockNumber + MaxPoVSize uint32 } // BackingState holds the state of the backing system per-parachain, including // state-machine constraints and candidates pending availability type BackingState struct { - Constraints Constraints `scale:"1"` - PendingAvailability []CandidatePendingAvailability `scale:"2"` + Constraints Constraints + PendingAvailability []CandidatePendingAvailability } diff --git a/dot/parachain/types/types.go b/dot/parachain/types/types.go index 4c11d51b27..64e40bae2f 100644 --- a/dot/parachain/types/types.go +++ b/dot/parachain/types/types.go @@ -157,35 +157,35 @@ func (cd CandidateDescriptor) CheckCollatorSignature() error { type CandidateDescriptorV2 struct { // The ID of the para this is a candidate for. - ParaID ParaID `scale:"1"` + ParaID ParaID // RelayParent is the hash of the relay-chain block this should be executed in // the context of. - RelayParent common.Hash `scale:"2"` + RelayParent common.Hash // Version field. The raw value here is not exposed, instead it is used // to determine the `CandidateDescriptorVersion`, see `fn version()`. // For the current version this field is set to `0` and will be incremented // by next versions. - Version uint8 `scale:"3"` + Version uint8 // The core index where the candidate is backed. - CoreIndex uint16 `scale:"4"` + CoreIndex uint16 // The session index of the candidate relay parent. - SessionIndex SessionIndex `scale:"5"` + SessionIndex SessionIndex // Reserved bytes. - Reserved1 [25]uint8 `scale:"6"` + Reserved1 [25]uint8 // PersistedValidationDataHash is the blake2-256 hash of the persisted validation data. This is extra data derived from // relay-chain state which may vary based on bitfields included before the candidate. // Thus, it cannot be derived entirely from the relay-parent. - PersistedValidationDataHash common.Hash `scale:"7"` + PersistedValidationDataHash common.Hash // PovHash is the hash of the `pov-block`. - PovHash common.Hash `scale:"8"` + PovHash common.Hash // ErasureRoot is the root of a block's erasure encoding Merkle tree. - ErasureRoot common.Hash `scale:"9"` + ErasureRoot common.Hash // Reserved bytes. - Reserved2 [64]uint8 `scale:"10"` + Reserved2 [64]uint8 // ParaHead is the hash of the para header that is being generated by this candidate. - ParaHead common.Hash `scale:"11"` + ParaHead common.Hash // ValidationCodeHash is the blake2-256 hash of the validation code bytes. - ValidationCodeHash ValidationCodeHash `scale:"12"` + ValidationCodeHash ValidationCodeHash } // OccupiedCore Information about a core which is currently occupied. From cc3b5fa95eb62f6ba14963e77114422078821168 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 14:10:48 -0400 Subject: [PATCH 08/13] chore: make abbreviations capital letters --- dot/parachain/types/async_backing.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index c7b6bacf26..8f5c884464 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -18,8 +18,8 @@ type AsyncBackingParams struct { AllowedAncestryLen uint32 `scale:"2"` } -// InboundHrmpLimitations constraints on inbound HRMP channels. -type InboundHrmpLimitations struct { +// InboundHRMPLimitations constraints on inbound HRMP channels. +type InboundHRMPLimitations struct { // An exhaustive set of all valid watermarks, sorted ascending. // // It's only expected to contain block numbers at which messages were @@ -27,8 +27,8 @@ type InboundHrmpLimitations struct { ValidWatermarks []BlockNumber } -// OutboundHrmpChannelLimitations constraints on outbound HRMP channels. -type OutboundHrmpChannelLimitations struct { +// OutboundHRMPChannelLimitations constraints on outbound HRMP channels. +type OutboundHRMPChannelLimitations struct { // The maximum bytes that can be written to the channel. BytesRemaining uint32 // The maximum messages that can be written to the channel. @@ -54,9 +54,9 @@ type Constraints struct { // Remaining DMP queue. Only includes sent-at block numbers. DmpRemainingMessages []uint32 // The limitations of all registered inbound HRMP channels. - HrmpInbound InboundHrmpLimitations + HrmpInbound InboundHRMPLimitations // The limitations of all registered outbound HRMP channels. - HrmpChannelsOut map[ParaID]OutboundHrmpChannelLimitations + HrmpChannelsOut map[ParaID]OutboundHRMPChannelLimitations // The maximum number of HRMP messages allowed per candidate. MaxHrmpNumPerCandidate uint32 // The required parent head-data of the parachain. From 38c90e7a34dd675f00ba1e257974b1db6439816f Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 14:58:15 -0400 Subject: [PATCH 09/13] chore: addressing comments --- dot/parachain/types/async_backing.go | 17 +++++++++-------- lib/runtime/wazero/instance_test.go | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dot/parachain/types/async_backing.go b/dot/parachain/types/async_backing.go index 8f5c884464..f41f61bac8 100644 --- a/dot/parachain/types/async_backing.go +++ b/dot/parachain/types/async_backing.go @@ -20,7 +20,7 @@ type AsyncBackingParams struct { // InboundHRMPLimitations constraints on inbound HRMP channels. type InboundHRMPLimitations struct { - // An exhaustive set of all valid watermarks, sorted ascending. + // An exhaustive set of all valid watermarks, sorted in ascending order. // // It's only expected to contain block numbers at which messages were // previously sent to a para, excluding most recent head. @@ -46,19 +46,19 @@ type Constraints struct { // The maximum new validation code size allowed, in bytes. MaxCodeSize uint32 // The amount of UMP messages remaining. - UmpRemaining uint32 + UMPRemaining uint32 // The amount of UMP bytes remaining. - UmpRemainingBytes uint32 + UMPRemainingBytes uint32 // The maximum number of UMP messages allowed per candidate. - MaxUmpNumPerCandidate uint32 + MaxNumUMPPerCandidate uint32 // Remaining DMP queue. Only includes sent-at block numbers. - DmpRemainingMessages []uint32 + DMPRemainingMessages []uint32 // The limitations of all registered inbound HRMP channels. - HrmpInbound InboundHRMPLimitations + HRMPInbound InboundHRMPLimitations // The limitations of all registered outbound HRMP channels. - HrmpChannelsOut map[ParaID]OutboundHRMPChannelLimitations + HRMPChannelsOut map[ParaID]OutboundHRMPChannelLimitations // The maximum number of HRMP messages allowed per candidate. - MaxHrmpNumPerCandidate uint32 + MaxNumHRMPPerCandidate uint32 // The required parent head-data of the parachain. RequiredParent HeadData // The expected validation-code-hash of this parachain. @@ -76,6 +76,7 @@ type FutureValidationCode struct { ValidationCodeHash ValidationCodeHash } +// CandidatePendingAvailability represents informations about one candidate pending availability type CandidatePendingAvailability struct { CandidateHash CandidateHash Descriptor CandidateDescriptorV2 diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index c63a77fa55..27c0fc2513 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -1731,10 +1731,10 @@ func TestInstance_ParachainHostParaBackingState(t *testing.T) { MinRelayParentNumber: 23920837, MaxPoVSize: 5242880, MaxCodeSize: 3145728, - UmpRemaining: 1398101, - UmpRemainingBytes: 8388608, - MaxUmpNumPerCandidate: 512, - MaxHrmpNumPerCandidate: 10, + UMPRemaining: 1398101, + UMPRemainingBytes: 8388608, + MaxNumUMPPerCandidate: 512, + MaxNumHRMPPerCandidate: 10, RequiredParent: parachaintypes.HeadData{ Data: common.MustHexToBytes("0x1b5270c5d767d30a43a1d3f66e4c8414bd9b9bd502d3620601a00b" + "2d3484bf042a84aa0138b82ea524764ca4b2e88c7069dc898d23d1997e212b490a2349853161a7de" + From a1110a445f5896d0f01da61698159a5009e824df Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 15:43:33 -0400 Subject: [PATCH 10/13] Trigger Build From 4ac9f85047fb94461395e5d7ab84aa17ca047f8c Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Wed, 18 Dec 2024 20:41:02 -0400 Subject: [PATCH 11/13] Trigger Build From 45b856edf73d0dba135fae0a0ab5488f98ae4a59 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Mon, 6 Jan 2025 08:40:59 -0400 Subject: [PATCH 12/13] chore: fix runtime release url for testing --- .DS_Store | Bin 0 -> 6148 bytes lib/runtime/constants.go | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e61a7405d4ba9f66bd8fbb48b311e96fa699d594 GIT binary patch literal 6148 zcmeHKy-LJD5T5aZL`1k!xMn-SLcC5Z;}KuLdjW|D=RrcQ(Au;%`U-Y}4`Ofc!}!h4 zXc8`1ipUJ?ezWtllYEff3=#3{ZZRbq6H$sG$f690mDeqC4VfldCZ zNuE8SBU;jmZoAJv;hn>-ud4IBDC+{Y^flRgdVhF3@B0@&`qwutH9f>xaR!_LXTTY72803J*&^w#qR-BNGvEw- zGa%NRTvb7kj>97Zj%M2SuO((YI zgRSyc^TM$@_75?fI8*f58E^*r42*O+mizw#pUhyB-%s(CGvEyTGX^-x=lKjTWq0ew z>&aakFs?8}B(4z!0=@SWfQ6hR`_ZZXAUfhQ!$whd5qnGr`j0>)#3yIq7Z~^i*>*y3 literal 0 HcmV?d00001 diff --git a/lib/runtime/constants.go b/lib/runtime/constants.go index 0b1b4d4157..c1f7bac1ad 100644 --- a/lib/runtime/constants.go +++ b/lib/runtime/constants.go @@ -44,7 +44,7 @@ const ( WESTEND_RUNTIME_v1017001 = "westend_runtime-v1017000" WESTEND_RUNTIME_v1017001_FP = "westend_runtime-v1017000.compact.wasm" WESTEND_RUNTIME_v1017001_URL = "https://github.com/paritytech/polkadot-sdk/releases/download/" + - "polkadot-stable2412/westend_runtime.compact.compressed.wasm?raw=true" + "polkadot-stable2412/westend_runtime-v1017001.compact.compressed.wasm?raw=true" ) const ( From 0289438124f513167de122e5c85290d3eedc9e74 Mon Sep 17 00:00:00 2001 From: EclesioMeloJunior Date: Mon, 6 Jan 2025 11:05:50 -0400 Subject: [PATCH 13/13] chore: increase the subsystems to overseer request timeout --- .../collator-protocol/validator_side_test.go | 20 +++++++++---------- dot/parachain/types/subsystems.go | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dot/parachain/collator-protocol/validator_side_test.go b/dot/parachain/collator-protocol/validator_side_test.go index aa8e37c793..f5c763634f 100644 --- a/dot/parachain/collator-protocol/validator_side_test.go +++ b/dot/parachain/collator-protocol/validator_side_test.go @@ -416,17 +416,15 @@ func TestProcessBackedOverseerMessage(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() overseer := overseer.NewMockableOverseer(t, false) - overseer.ExpectActions([]func(msg any) bool{ - func(msg any) bool { - canSecondMessage, ok := msg.(backing.CanSecondMessage) - if !ok { - return false - } - canSecondMessage.ResponseCh <- c.canSecond - - return true - }, - }...) + overseer.ExpectActions(func(msg any) bool { + canSecondMessage, ok := msg.(backing.CanSecondMessage) + if !ok { + return false + } + canSecondMessage.ResponseCh <- c.canSecond + + return true + }) collationProtocolID := "/6761727661676500000000000000000000000000000000000000000000000000/1/collations/1" diff --git a/dot/parachain/types/subsystems.go b/dot/parachain/types/subsystems.go index 4278f23961..93ef41746f 100644 --- a/dot/parachain/types/subsystems.go +++ b/dot/parachain/types/subsystems.go @@ -23,5 +23,5 @@ const ( ProspectiveParachains SubSystemName = "ProspectiveParachains" ) -var SubsystemRequestTimeout = 1 * time.Second +var SubsystemRequestTimeout = 5 * time.Second var ErrSubsystemRequestTimeout = errors.New("subsystem request timed out")