forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable fraud service to full & light nodes and extend abci.FraudProof…
… with go-fraud Proof interface (cosmos#891) As part of go-fraud library implementation, this PR adds: * ProofService to full and light nodes * Extends abci.FraudProof interface with go-fraud Proof interface Fixes cosmos#892 cosmos#893 cosmos#894 --------- Co-authored-by: Ganesha Upadhyaya <[email protected]>
- Loading branch information
1 parent
d6d030a
commit 5bf92b8
Showing
8 changed files
with
159 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package node | ||
|
||
import ( | ||
"github.com/celestiaorg/go-fraud" | ||
"github.com/celestiaorg/go-fraud/fraudserv" | ||
"github.com/ipfs/go-datastore" | ||
|
||
"github.com/rollkit/rollkit/p2p" | ||
) | ||
|
||
type ProofServiceFactory struct { | ||
client *p2p.Client | ||
getter fraud.HeaderFetcher | ||
ds datastore.Datastore | ||
syncerEnabled bool | ||
proofType fraud.ProofType | ||
} | ||
|
||
func NewProofServiceFactory(c *p2p.Client, getter fraud.HeaderFetcher, ds datastore.Datastore, syncerEnabled bool, proofType fraud.ProofType) ProofServiceFactory { | ||
return ProofServiceFactory{ | ||
client: c, | ||
getter: getter, | ||
ds: ds, | ||
syncerEnabled: syncerEnabled, | ||
proofType: proofType, | ||
} | ||
} | ||
|
||
func (factory *ProofServiceFactory) CreateProofService() *fraudserv.ProofService { | ||
return fraudserv.NewProofService( | ||
factory.client.PubSub(), | ||
factory.client.Host(), | ||
factory.getter, | ||
factory.ds, | ||
factory.syncerEnabled, | ||
factory.proofType.String(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/celestiaorg/go-header" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
"github.com/celestiaorg/go-fraud" | ||
) | ||
|
||
// Implements Proof interface from https://github.com/celestiaorg/go-fraud/ | ||
|
||
const StateFraudProofType fraud.ProofType = "state-fraud" | ||
|
||
type StateFraudProof struct { | ||
abci.FraudProof | ||
} | ||
|
||
func init() { | ||
fraud.Register(&StateFraudProof{}) | ||
} | ||
|
||
func (fp *StateFraudProof) Type() fraud.ProofType { | ||
return StateFraudProofType | ||
} | ||
|
||
func (fp *StateFraudProof) HeaderHash() []byte { | ||
return fp.FraudulentBeginBlock.Hash | ||
} | ||
|
||
func (fp *StateFraudProof) Height() uint64 { | ||
return uint64(fp.BlockHeight) | ||
} | ||
|
||
func (fp *StateFraudProof) Validate(header.Header) error { | ||
// TODO (ganesh): fill this later | ||
return nil | ||
} | ||
|
||
func (fp *StateFraudProof) MarshalBinary() (data []byte, err error) { | ||
return fp.Marshal() | ||
} | ||
|
||
func (fp *StateFraudProof) UnmarshalBinary(data []byte) error { | ||
return fp.Unmarshal(data) | ||
} | ||
|
||
var _ fraud.Proof = &StateFraudProof{} |