Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How will it be implemented?

Code Block
def merge(conflictResolver: ConflictResolver[C])(parentHash: Blake2b256Hash, hashA: Blake2b256Hash, hashB: Blake2b256Hash): Option[Blake2b256Hash]


Conflict Resolution

The current implementation does a mapping:

Code Block
  private def buildBlockAncestorChannels[F[_]: Monad: BlockStore](
      blockAncestorsMeta: List[BlockMetadata]
  ): F[Set[ByteString]] =
    for {
      maybeAncestors <- blockAncestorsMeta.traverse(
                         blockAncestorMeta => BlockStore[F].get(blockAncestorMeta.blockHash)
                       )
      ancestors      = maybeAncestors.flatten
      ancestorEvents = ancestors.flatMap(_.getBody.deploys.flatMap(_.deployLog))
      ancestorChannels = ancestorEvents.flatMap {
        case Event(Produce(produce: ProduceEvent)) =>
          Set(produce.channelsHash)
        case Event(Consume(consume: ConsumeEvent)) =>
          consume.channelsHashes.toSet
        case Event(Comm(CommEvent(Some(consume: ConsumeEvent), produces))) =>
          consume.channelsHashes.toSet ++ produces.map(_.channelsHash).toSet
        case _ => throw new RuntimeException("incorrect ancestor events")
      }.toSet
    } yield ancestorChannels

This throws away all of the additional information carried in Event.

A plan to enable a denser perceived DAG is to introduce more introspection and a broader set of conflict resolution rules.

Two rules that will be implemented soon are:

  • peeking values
  • invoking persistent continuations

These do not require additional context information and can be resolved at channel level.

IOW the planned changes to conflict resolution should not block the future work on trie merging.

It would make sense to move the mechanism itself to a dedicated interface which will be used inĀ merge.

Open topics

  • is it possible to use this mechanism to merge multiple tries at once