dedis / dela

DEDIS Ledger Architecture
https://dedis.github.io/dela
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

PBFT: Leader eviction is too harsh #216

Open nkcr opened 2 years ago

nkcr commented 2 years ago

Introduction

A node will choose a new leader once the following happens:

  1. A timeout is reached after no new blocks were committed, and
  2. Right after the timeout is reached, the pool contains one or more transaction(s)

In pseudo-code:

for {
    select {
        case <- time.After(timeout):
        if pool.Len() != 0 {
          // trigger a view change
        }
        case <- s.newBlocks:
        // ok, continue
    }
}

Choosing a new leader is a heavy operation that should be triggered only when the situation truly requires it.

The current process can be a problem for the following reason:

  1. In the unfortunate situation where a transaction is added to the pool right after the timeout: even if the leader is honest, it might just process the transaction too late.
  2. This check only ensures that some transactions are included periodically, but doesn't prevent the leader from censoring specific transactions.

I won't try to solve 2) for the moment. Let's focus on 1), which can be stated as follow: "a view change should be triggered only once a node finds out that the the pool of transaction, if not empty, hasn't be updated after some timeout".

Solution 1 - Add a second timeout

Once the timeout is reached, wait on another timeout and check if some transaction were processed in the meantime:

for {
    select {
        case <- time.After(timeout):
        n := pool.Len()
        if n != 0 {
            // gives some time to the leader to process txs
            time.Sleep(timeout2)

            if pool.Len() < n {
                // ok
                return nil
            }

            // view change
        }
        case <- s.newBlocks:
        // ok, continue
    }
}

Pros:

Cons:

Solution 2 - Update the pool implementation

Adds a functionality to the pool that can notify for "rotten transaction".

for {
    select {
        case <- pool.RottenTx
            // view change
        }
        case <- s.newBlocks:
        // ok, continue
    }
}

Pros:

Cons:

pierluca commented 1 year ago

Meeting notes , 12/12/2022

Participants:

@jbsv , @nkcr , @pierluca

File involved:

https://github.com/dedis/dela/blob/master/core/ordering/cosipbft/mod.go#L485 https://github.com/dedis/dela/blob/master/core/ordering/cosipbft/mod_test.go#L97

Possible solution

Other considerations: Pool interface