Skip to content
  • Sergey Pepyakin's avatar
    HRMP channel deposits (#2225) · c644c39f
    Sergey Pepyakin authored
    * Drive by fixes
    
    The visibility modifiers are remnants of the previous structure where
    HRMP wasn't a standalone module, by rather a submodule of the router
    module.
    
    * Add Currency assoc type to Config
    
    This would allow us to reserve balance for deposits. This commit also
    integrates the HRMP module in rococo, test-runtime and mocks to use the
    balances pallet.
    
    * Fix a bug that doesn't increment the age
    
    In case the request is not confirmed, the age would be incremented but
    not persisted.
    
    * Fix cleaning the indexes
    
    Before that change, the cleaning of the channel indexes was wrong, because it
    naively removed entire rows that was pertaining to the para we delete.
    This approach is flawed because it doesn't account for the rows that are
    pertaining to other paras that contain the outgoing one.
    
    This clearly violates the invariant imposed on the indexes, that all
    the index rows must contain alive paras, but apart from that it also
    lead to the situation where ingress index would contain the a different
    set of channels that an egress have.
    
    * Reserve currency for opening the channels
    
    Note the ugly `unique_saturated_into` calls. The reason for them is the
    currency trait accepts and defines the `Balance` associated type and the
    deposit values are coming from the `HostConfiguration` where they are
    defined using the `Balance`.
    
    I figured that parameterising `HostConfiguration` would be annoying. On
    the other hand, I don't expect these `unique_saturated_into` calls to
    give us problems since it seems to be a reasonable assumption that this
    module will be instantiated within a runtime where the Currency provided
    will have a Balance that matches the one used in the configuration.
    
    * Tests: Adapt `run_to_block` so that it submits a proper config
    
    * Tests: exercise the deposit logic
    c644c39f