From 5a88493120eb47f34e889c3ed50d41c4c9f3b536 Mon Sep 17 00:00:00 2001 From: Bui Quang Minh Date: Fri, 7 Jul 2023 11:47:33 +0700 Subject: [PATCH] consensus: add fast finality interface --- consensus/consensus.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 56d5c573cb..07cdc0ea30 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -18,9 +18,10 @@ package consensus import ( + "math/big" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" - "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" @@ -147,3 +148,21 @@ type PoSA interface { IsSystemTransaction(tx *types.Transaction, header *types.Header) (bool, error) IsSystemContract(to *common.Address) bool } + +type FastFinalityPoSA interface { + PoSA + + GetJustifiedBlock(chain ChainHeaderReader, blockNumber uint64, blockHash common.Hash) (uint64, common.Hash) + GetFinalizedBlock(chain ChainHeaderReader, blockNumber uint64, blockHash common.Hash) (uint64, common.Hash) + + // IsActiveValidatorAt always returns false before Shillin + IsActiveValidatorAt(chain ChainHeaderReader, header *types.Header) bool + + // VerifyVote check if the finality voter is in the validator set, it assumes the signature is + // already verified + VerifyVote(chain ChainHeaderReader, vote *types.VoteEnvelope) error +} + +type VotePool interface { + FetchVoteByBlockHash(blockHash common.Hash) []*types.VoteEnvelope +}