iotaledger / inx-tendercoo

INX-Tendercoo enables a committee of validators to operate as a distributed Coordinator using Tendermint Core BFT consensus.
Apache License 2.0
1 stars 0 forks source link

Bootstrapping and linking to other network #67

Closed shufps closed 1 year ago

shufps commented 1 year ago

For the merge, we need to convert a Chrysalis2 snapshot to a Stardust snapshot and bootstrap the DeCoo at some index - in this example 7143515.

Milestone-Data:

milestoneIndex: 7143515
milestoneID: 0xb85efb96f7de93cde48af7aa89e589ce332a1c621c79eeca5b93e780a458d92d
messageID: 0xf6886cf7f7c202fe166246f94def3fbaeebff68cb144a048899d309afcf65a59

Chrysalis 2 Snapshot:

{
  "filePath": "/tmp/7143515_full.bin",
  "snapshotTime": "2023-08-04T07:37:05Z",
  "networkID": 1454675179895816119,
  "treasury": {
    "milestoneID": "67c735be88944aee351be88493a1da3548ddab4210fcde672f208c94953be95c",
    "tokens": 240069989541330
  },
  "ledgerIndex": 7143515,
  "snapshotIndex": 7143515,
  "UTXOsCount": 200929,
  "SEPsCount": 1,
  "milestoneDiffsCount": 0
}

Stardust Snapshot:

{
  "filePath": "/tmp/the_merge_snapshot.bin",
  "version": 2,
  "type": "full",
  "genesisMilestoneIndex": 7143515,
  "targetMilestoneIndex": 7143515,
  "targetMilestoneTimestamp": "2023-08-04T07:37:05Z",
  "targetMilestoneId": "0xb85efb96f7de93cde48af7aa89e589ce332a1c621c79eeca5b93e780a458d92d",
  "ledgerMilestoneIndex": 7143515,
  "treasuryOutput": {
    "milestoneId": "0x67c735be88944aee351be88493a1da3548ddab4210fcde672f208c94953be95c",
    "amount": "100000"
  },
  "protocolParameters": {
    "version": 2,
    "networkName": "stardust-mainnet-pre1",
    "bech32Hrp": "iota",
    "minPowScore": 1500,
    "belowMaxDepth": 15,
    "rentStructure": {
      "vByteCost": 100,
      "vByteFactorData": 1,
      "vByteFactorKey": 10
    },
    "tokenSupply": "2539517412586458"
  },
  "outputCount": 17310446,
  "milestoneDiffCount": 0,
  "solidEntryPointsCount": 1
}

Tendercoo Bootstrapping:

coo_start_index: 7143516
coo_start_milestone_block_id: f6886cf7f7c202fe166246f94def3fbaeebff68cb144a048899d309afcf65a59
coo_start_milestone_id: "0000000000000000000000000000000000000000000000000000000000000000"

(on Tendercoo, the coo_start_index is the next milestoneIndex to issue).

Problems we see:

1. Event for solid block

On bootstrapping the deCOO registers a event and waits for the block $messageID to become solid. Hornet doesn't fire an event for this blockID and tenderCOO waits forever.

This could be circumvented by using the bootstrapForce (and use it as CLI parameter at startup) here: https://github.com/iotaledger/inx-tendercoo/blob/develop/components/decoo/coordinator.go#L19

The clean way probably is to detect if the event is for the snapshots SEP and fire the event right away because it's always solid. Would be a Hornet change, I guess.

2. Requesting of non-existing block

If former is circumvented, Tendercoo tries to query the Block $messageID but it doesn't exist (and it's impossible to inject it because the structure of the block is totally different and we can't construct blocks with a certain ID).

The error:

failed to propose parent for milestone 7143516: failed to query BlockMetadata: rpc error: code = NotFound desc = block metadata 0xf6886cf7f7c202fe166246f94def3fbaeebff68cb144a048899d309afcf65a59 not found

This is printed in a endless loop (about 2-3s apart)

shufps commented 1 year ago

Update: After fixing something in the the-mergerator the check is working.

For the invalid milestone index problem, this could be the reason (in inx-app):

func (n *NodeBridge) ConfirmedMilestone() (*Milestone, error) {
    n.nodeStatusMutex.RLock()
    defer n.nodeStatusMutex.RUnlock()

    return milestoneFromINXMilestone(n.nodeStatus.GetConfirmedMilestone())
}

func (n *NodeBridge) ConfirmedMilestoneIndex() uint32 {
    confirmedMilestone, err := n.ConfirmedMilestone()
    if err != nil || confirmedMilestone == nil {
        return 0
    }

    return confirmedMilestone.Milestone.Index
}

The ConfirmedMilestoneIndex function tries to retrieve the Milestone but it doesn't exist.

shufps commented 1 year ago

works now :ok_hand: