Repository: celestiaorg/celestia-node
Pull request #1916 (2023-03-16 11:57:58)

refactor(fraud): extract fraud package to libs
## Overview
Relates to https://github.com/celestiaorg/celestia-node/pull/1825

## Checklist
- [x] New and updated code has appropriate documentation
- [x] New and updated code has new and/or updated testing
- [x] Required CI checks are passing
- [x] Visual proof for any user facing features like CLI or documentation updates
- [x] Linked issues closed with keywords

Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl>

codecov-commenter: ## [Codecov](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg) Report
> Merging [#1916](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg) (e1d076c) into [main](https://codecov.io/gh/celestiaorg/celestia-node/commit/596c16bc9702ba4712467855beaecd432e27b023?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg) (596c16b) will **decrease** coverage by `0.14%`.
> The diff coverage is `57.89%`.

> :exclamation: Current head e1d076c differs from pull request most recent head dd5c55e. Consider uploading reports for the commit dd5c55e to get more accurate results

```diff
@@            Coverage Diff             @@
##             main    #1916      +/-   ##
==========================================
- Coverage   57.81%   57.68%   -0.14%     
==========================================
  Files         245      245              
  Lines       16156    16161       +5     
==========================================
- Hits         9341     9322      -19     
- Misses       5869     5890      +21     
- Partials      946      949       +3     
```


| [Impacted Files](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg) | Coverage Δ | |
|---|---|---|
| [das/daser.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-ZGFzL2Rhc2VyLmdv) | `67.03% <ø> (ø)` | |
| [libs/fraud/helpers.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9oZWxwZXJzLmdv) | `82.35% <ø> (ø)` | |
| [libs/fraud/metrics.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9tZXRyaWNzLmdv) | `65.38% <ø> (ø)` | |
| [libs/fraud/proof.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9wcm9vZi5nbw==) | `70.96% <ø> (ø)` | |
| [libs/fraud/registry.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9yZWdpc3RyeS5nbw==) | `91.30% <ø> (ø)` | |
| [libs/fraud/requester.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9yZXF1ZXN0ZXIuZ28=) | `48.14% <ø> (ø)` | |
| [libs/fraud/service.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9zZXJ2aWNlLmdv) | `75.65% <ø> (ø)` | |
| [libs/fraud/store.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9zdG9yZS5nbw==) | `58.33% <ø> (ø)` | |
| [libs/fraud/subscription.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9zdWJzY3JpcHRpb24uZ28=) | `69.23% <ø> (ø)` | |
| [libs/fraud/sync.go](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg#diff-bGlicy9mcmF1ZC9zeW5jLmdv) | `58.47% <ø> (ø)` | |
| ... and [15 more](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg) | |

... and [3 files with indirect coverage changes](https://codecov.io/gh/celestiaorg/celestia-node/pull/1916/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg)

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=celestiaorg)


Patch:
diff --git a/api/docgen/examples.go b/api/docgen/examples.go
index b4c9f7e5..d59ae437 100644
--- a/api/docgen/examples.go
+++ b/api/docgen/examples.go
@@ -7,7 +7,7 @@ import (
 	"golang.org/x/text/cases"
 	"golang.org/x/text/language"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 )
 
 var ExampleValues = map[reflect.Type]interface{}{
@@ -15,12 +15,12 @@ var ExampleValues = map[reflect.Type]interface{}{
 	reflect.TypeOf(uint64(42)): uint64(42),
 	reflect.TypeOf(uint32(42)): uint32(42),
 	// reflect.TypeOf(int32(42)):   int32(42),
-	reflect.TypeOf(int64(42)):         int64(42),
-	reflect.TypeOf(byte(7)):           byte(7),
-	reflect.TypeOf(float64(42)):       float64(42),
-	reflect.TypeOf(true):              true,
-	reflect.TypeOf([]byte{}):          []byte("byte array"),
-	reflect.TypeOf(fraud.BadEncoding): fraud.BadEncoding,
+	reflect.TypeOf(int64(42)):             int64(42),
+	reflect.TypeOf(byte(7)):               byte(7),
+	reflect.TypeOf(float64(42)):           float64(42),
+	reflect.TypeOf(true):                  true,
+	reflect.TypeOf([]byte{}):              []byte("byte array"),
+	reflect.TypeOf(byzantine.BadEncoding): byzantine.BadEncoding,
 }
 
 func ExampleValue(t, parent reflect.Type) (interface{}, error) {
diff --git a/das/daser.go b/das/daser.go
index 97b7f996..96e81f96 100644
--- a/das/daser.go
+++ b/das/daser.go
@@ -9,8 +9,8 @@ import (
 	"github.com/ipfs/go-datastore"
 	logging "github.com/ipfs/go-log/v2"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
diff --git a/fraud/gossip_score.go b/libs/fraud/gossip_score.go
similarity index 100%
rename from fraud/gossip_score.go
rename to libs/fraud/gossip_score.go
diff --git a/fraud/helpers.go b/libs/fraud/helpers.go
similarity index 100%
rename from fraud/helpers.go
rename to libs/fraud/helpers.go
diff --git a/fraud/interface.go b/libs/fraud/interface.go
similarity index 92%
rename from fraud/interface.go
rename to libs/fraud/interface.go
index 1dd4ffe6..8df44c2b 100644
--- a/fraud/interface.go
+++ b/libs/fraud/interface.go
@@ -5,13 +5,13 @@ import (
 
 	logging "github.com/ipfs/go-log/v2"
 
-	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/header"
 )
 
 var log = logging.Logger("fraud")
 
 // headerFetcher aliases a function that is used to fetch an ExtendedHeader from store by height.
-type headerFetcher func(context.Context, uint64) (*header.ExtendedHeader, error)
+type headerFetcher func(context.Context, uint64) (header.Header, error)
 
 // ProofUnmarshaler aliases a function that parses data to `Proof`.
 type ProofUnmarshaler func([]byte) (Proof, error)
diff --git a/fraud/metrics.go b/libs/fraud/metrics.go
similarity index 100%
rename from fraud/metrics.go
rename to libs/fraud/metrics.go
diff --git a/fraud/pb/proof.pb.go b/libs/fraud/pb/proof.pb.go
similarity index 91%
rename from fraud/pb/proof.pb.go
rename to libs/fraud/pb/proof.pb.go
index d5e992ab..2d5b6794 100644
--- a/fraud/pb/proof.pb.go
+++ b/libs/fraud/pb/proof.pb.go
@@ -1,5 +1,5 @@
 // Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: fraud/pb/proof.proto
+// source: libs/fraud/pb/proof.proto
 
 package fraud_pb
 
@@ -30,7 +30,7 @@ func (m *FraudMessageRequest) Reset()         { *m = FraudMessageRequest{} }
 func (m *FraudMessageRequest) String() string { return proto.CompactTextString(m) }
 func (*FraudMessageRequest) ProtoMessage()    {}
 func (*FraudMessageRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_318cb87a8bb2d394, []int{0}
+	return fileDescriptor_8ed4b0aa9157349f, []int{0}
 }
 func (m *FraudMessageRequest) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -75,7 +75,7 @@ func (m *ProofResponse) Reset()         { *m = ProofResponse{} }
 func (m *ProofResponse) String() string { return proto.CompactTextString(m) }
 func (*ProofResponse) ProtoMessage()    {}
 func (*ProofResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_318cb87a8bb2d394, []int{1}
+	return fileDescriptor_8ed4b0aa9157349f, []int{1}
 }
 func (m *ProofResponse) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -126,7 +126,7 @@ func (m *FraudMessageResponse) Reset()         { *m = FraudMessageResponse{} }
 func (m *FraudMessageResponse) String() string { return proto.CompactTextString(m) }
 func (*FraudMessageResponse) ProtoMessage()    {}
 func (*FraudMessageResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_318cb87a8bb2d394, []int{2}
+	return fileDescriptor_8ed4b0aa9157349f, []int{2}
 }
 func (m *FraudMessageResponse) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -168,23 +168,23 @@ func init() {
 	proto.RegisterType((*FraudMessageResponse)(nil), "fraud.pb.FraudMessageResponse")
 }
 
-func init() { proto.RegisterFile("fraud/pb/proof.proto", fileDescriptor_318cb87a8bb2d394) }
-
-var fileDescriptor_318cb87a8bb2d394 = []byte{
-	// 203 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x49, 0x2b, 0x4a, 0x2c,
-	0x4d, 0xd1, 0x2f, 0x48, 0xd2, 0x2f, 0x28, 0xca, 0xcf, 0x4f, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9,
-	0x17, 0xe2, 0x00, 0x8b, 0xea, 0x15, 0x24, 0x29, 0xb9, 0x72, 0x09, 0xbb, 0x81, 0xd8, 0xbe, 0xa9,
-	0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x7a, 0x5c, 0x42,
-	0x50, 0x66, 0x6a, 0x4a, 0x00, 0x48, 0x63, 0x48, 0x65, 0x41, 0xaa, 0x04, 0xa3, 0x02, 0xb3, 0x06,
-	0x67, 0x10, 0x16, 0x19, 0x25, 0x4b, 0x2e, 0x5e, 0x30, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf,
-	0x38, 0x55, 0x48, 0x88, 0x8b, 0x05, 0xaa, 0x85, 0x51, 0x83, 0x33, 0x08, 0xcc, 0x16, 0x12, 0xe1,
-	0x62, 0x0d, 0x4b, 0xcc, 0x29, 0x4d, 0x95, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x09, 0x82, 0x70, 0x94,
-	0xdc, 0xb9, 0x44, 0x50, 0x5d, 0x00, 0x35, 0x41, 0x9f, 0x8b, 0x0d, 0x6c, 0x64, 0x31, 0xd8, 0x5a,
-	0x6e, 0x23, 0x71, 0x3d, 0x98, 0xa3, 0xf5, 0x50, 0xac, 0x0a, 0x82, 0x2a, 0x73, 0x92, 0x38, 0xf1,
-	0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8,
-	0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x24, 0x36, 0xb0, 0xaf, 0x8d, 0x01, 0x01, 0x00,
-	0x00, 0xff, 0xff, 0xa2, 0xc2, 0x65, 0x25, 0x0d, 0x01, 0x00, 0x00,
+func init() { proto.RegisterFile("libs/fraud/pb/proof.proto", fileDescriptor_8ed4b0aa9157349f) }
+
+var fileDescriptor_8ed4b0aa9157349f = []byte{
+	// 208 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xc9, 0x4c, 0x2a,
+	0xd6, 0x4f, 0x2b, 0x4a, 0x2c, 0x4d, 0xd1, 0x2f, 0x48, 0xd2, 0x2f, 0x28, 0xca, 0xcf, 0x4f, 0xd3,
+	0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x00, 0x8b, 0xea, 0x15, 0x24, 0x29, 0xb9, 0x72, 0x09,
+	0xbb, 0x81, 0xd8, 0xbe, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5,
+	0x25, 0x42, 0x7a, 0x5c, 0x42, 0x50, 0x66, 0x6a, 0x4a, 0x00, 0x48, 0x63, 0x48, 0x65, 0x41, 0xaa,
+	0x04, 0xa3, 0x02, 0xb3, 0x06, 0x67, 0x10, 0x16, 0x19, 0x25, 0x4b, 0x2e, 0x5e, 0x30, 0x27, 0x28,
+	0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x48, 0x88, 0x8b, 0x05, 0xaa, 0x85, 0x51, 0x83, 0x33,
+	0x08, 0xcc, 0x16, 0x12, 0xe1, 0x62, 0x0d, 0x4b, 0xcc, 0x29, 0x4d, 0x95, 0x60, 0x52, 0x60, 0xd6,
+	0xe0, 0x09, 0x82, 0x70, 0x94, 0xdc, 0xb9, 0x44, 0x50, 0x5d, 0x00, 0x35, 0x41, 0x9f, 0x8b, 0x0d,
+	0x6c, 0x64, 0x31, 0xd8, 0x5a, 0x6e, 0x23, 0x71, 0x3d, 0x98, 0xa3, 0xf5, 0x50, 0xac, 0x0a, 0x82,
+	0x2a, 0x73, 0x92, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18,
+	0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x24, 0x36, 0xb0,
+	0xaf, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x45, 0x72, 0xa0, 0x12, 0x01, 0x00, 0x00,
 }
 
 func (m *FraudMessageRequest) Marshal() (dAtA []byte, err error) {
diff --git a/fraud/pb/proof.proto b/libs/fraud/pb/proof.proto
similarity index 100%
rename from fraud/pb/proof.proto
rename to libs/fraud/pb/proof.proto
diff --git a/fraud/proof.go b/libs/fraud/proof.go
similarity index 94%
rename from fraud/proof.go
rename to libs/fraud/proof.go
index 6bcfa80f..c26e1b4e 100644
--- a/fraud/proof.go
+++ b/libs/fraud/proof.go
@@ -8,7 +8,7 @@ import (
 	"go.opentelemetry.io/otel"
 	"go.opentelemetry.io/otel/metric/global"
 
-	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/header"
 )
 
 var (
@@ -40,10 +40,6 @@ func (pt ProofType) String() string {
 	return string(pt)
 }
 
-const (
-	BadEncoding ProofType = "badencoding"
-)
-
 // Proof is a generic interface that will be used for all types of fraud proofs in the network.
 type Proof interface {
 	// Type returns the exact type of fraud proof.
@@ -56,7 +52,7 @@ type Proof interface {
 	// Validate throws an error if some conditions don't pass and thus fraud proof is not valid.
 	// NOTE: header.ExtendedHeader should pass basic validation otherwise it will panic if it's
 	// malformed.
-	Validate(*header.ExtendedHeader) error
+	Validate(header.Header) error
 
 	encoding.BinaryMarshaler
 	encoding.BinaryUnmarshaler
diff --git a/fraud/registry.go b/libs/fraud/registry.go
similarity index 100%
rename from fraud/registry.go
rename to libs/fraud/registry.go
diff --git a/fraud/requester.go b/libs/fraud/requester.go
similarity index 95%
rename from fraud/requester.go
rename to libs/fraud/requester.go
index 18b68a86..75a1d2d4 100644
--- a/fraud/requester.go
+++ b/libs/fraud/requester.go
@@ -9,7 +9,7 @@ import (
 
 	"github.com/celestiaorg/go-libp2p-messenger/serde"
 
-	pb "github.com/celestiaorg/celestia-node/fraud/pb"
+	pb "github.com/celestiaorg/celestia-node/libs/fraud/pb"
 )
 
 const (
diff --git a/fraud/store.go b/libs/fraud/store.go
similarity index 100%
rename from fraud/store.go
rename to libs/fraud/store.go
diff --git a/fraud/store_test.go b/libs/fraud/store_test.go
similarity index 100%
rename from fraud/store_test.go
rename to libs/fraud/store_test.go
diff --git a/fraud/subscription.go b/libs/fraud/subscription.go
similarity index 100%
rename from fraud/subscription.go
rename to libs/fraud/subscription.go
diff --git a/fraud/sync.go b/libs/fraud/sync.go
similarity index 98%
rename from fraud/sync.go
rename to libs/fraud/sync.go
index d4ba4ba2..e82e33f5 100644
--- a/fraud/sync.go
+++ b/libs/fraud/sync.go
@@ -15,7 +15,7 @@ import (
 
 	"github.com/celestiaorg/go-libp2p-messenger/serde"
 
-	pb "github.com/celestiaorg/celestia-node/fraud/pb"
+	pb "github.com/celestiaorg/celestia-node/libs/fraud/pb"
 )
 
 // syncFraudProofs encompasses the behavior for fetching fraud proofs from other peers.
diff --git a/nodebuilder/das/constructors.go b/nodebuilder/das/constructors.go
index 5247a135..14298b27 100644
--- a/nodebuilder/das/constructors.go
+++ b/nodebuilder/das/constructors.go
@@ -7,8 +7,8 @@ import (
 	"github.com/ipfs/go-datastore"
 
 	"github.com/celestiaorg/celestia-node/das"
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/p2p/shrexsub"
diff --git a/nodebuilder/das/module.go b/nodebuilder/das/module.go
index dbe13684..311ad697 100644
--- a/nodebuilder/das/module.go
+++ b/nodebuilder/das/module.go
@@ -6,9 +6,10 @@ import (
 	"go.uber.org/fx"
 
 	"github.com/celestiaorg/celestia-node/das"
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	fraudServ "github.com/celestiaorg/celestia-node/nodebuilder/fraud"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 )
 
 func ConstructModule(tp node.Type, cfg *Config) fx.Option {
@@ -43,7 +44,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
 			fx.Provide(fx.Annotate(
 				newDASer,
 				fx.OnStart(func(startCtx, ctx context.Context, fservice fraud.Service, das *das.DASer) error {
-					return fraudServ.Lifecycle(startCtx, ctx, fraud.BadEncoding, fservice,
+					return fraudServ.Lifecycle(startCtx, ctx, byzantine.BadEncoding, fservice,
 						das.Start, das.Stop)
 				}),
 				fx.OnStop(func(ctx context.Context, das *das.DASer) error {
diff --git a/nodebuilder/fraud/constructors.go b/nodebuilder/fraud/constructors.go
index fc22e6af..6f62fcb6 100644
--- a/nodebuilder/fraud/constructors.go
+++ b/nodebuilder/fraud/constructors.go
@@ -1,13 +1,15 @@
 package fraud
 
 import (
+	"context"
+
 	"github.com/ipfs/go-datastore"
 	pubsub "github.com/libp2p/go-libp2p-pubsub"
 	"github.com/libp2p/go-libp2p/core/host"
 	"go.uber.org/fx"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/nodebuilder/p2p"
 )
@@ -28,7 +30,10 @@ func newFraudService(syncerEnabled bool) func(
 		ds datastore.Batching,
 		network p2p.Network,
 	) (Module, fraud.Service, error) {
-		pservice := fraud.NewProofService(sub, host, hstore.GetByHeight, ds, syncerEnabled, network.String())
+		getter := func(ctx context.Context, height uint64) (libhead.Header, error) {
+			return hstore.GetByHeight(ctx, height)
+		}
+		pservice := fraud.NewProofService(sub, host, getter, ds, syncerEnabled, network.String())
 		lc.Append(fx.Hook{
 			OnStart: pservice.Start,
 			OnStop:  pservice.Stop,
diff --git a/nodebuilder/fraud/fraud.go b/nodebuilder/fraud/fraud.go
index fd9cb3ed..7a932a54 100644
--- a/nodebuilder/fraud/fraud.go
+++ b/nodebuilder/fraud/fraud.go
@@ -3,7 +3,7 @@ package fraud
 import (
 	"context"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 )
 
 var _ Module = (*API)(nil)
diff --git a/nodebuilder/fraud/lifecycle.go b/nodebuilder/fraud/lifecycle.go
index a94bc617..f3c74e9c 100644
--- a/nodebuilder/fraud/lifecycle.go
+++ b/nodebuilder/fraud/lifecycle.go
@@ -6,7 +6,7 @@ import (
 
 	"github.com/ipfs/go-datastore"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 )
 
 // Lifecycle controls the lifecycle of service depending on fraud proofs.
diff --git a/nodebuilder/fraud/mocks/api.go b/nodebuilder/fraud/mocks/api.go
index cc94a4e7..a57a688e 100644
--- a/nodebuilder/fraud/mocks/api.go
+++ b/nodebuilder/fraud/mocks/api.go
@@ -10,8 +10,8 @@ import (
 
 	gomock "github.com/golang/mock/gomock"
 
-	fraud "github.com/celestiaorg/celestia-node/fraud"
 	fraud0 "github.com/celestiaorg/celestia-node/nodebuilder/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 )
 
 // MockModule is a mock of Module interface.
diff --git a/nodebuilder/fraud/module.go b/nodebuilder/fraud/module.go
index d1eb8011..c3c8971c 100644
--- a/nodebuilder/fraud/module.go
+++ b/nodebuilder/fraud/module.go
@@ -4,7 +4,7 @@ import (
 	logging "github.com/ipfs/go-log/v2"
 	"go.uber.org/fx"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
 )
 
diff --git a/nodebuilder/fraud/service.go b/nodebuilder/fraud/service.go
index ed2e3295..6ac1338e 100644
--- a/nodebuilder/fraud/service.go
+++ b/nodebuilder/fraud/service.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"encoding/json"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 )
 
 var _ Module = (*Service)(nil)
diff --git a/nodebuilder/header/module.go b/nodebuilder/header/module.go
index 383d8db8..3f6bf4ed 100644
--- a/nodebuilder/header/module.go
+++ b/nodebuilder/header/module.go
@@ -8,8 +8,8 @@ import (
 	pubsub "github.com/libp2p/go-libp2p-pubsub"
 	"go.uber.org/fx"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/libs/header/p2p"
 	"github.com/celestiaorg/celestia-node/libs/header/store"
@@ -17,6 +17,7 @@ import (
 	modfraud "github.com/celestiaorg/celestia-node/nodebuilder/fraud"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
 	modp2p "github.com/celestiaorg/celestia-node/nodebuilder/p2p"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 )
 
 var log = logging.Logger("module/header")
@@ -75,7 +76,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
 				fservice fraud.Service,
 				syncer *sync.Syncer[*header.ExtendedHeader],
 			) error {
-				return modfraud.Lifecycle(startCtx, ctx, fraud.BadEncoding, fservice,
+				return modfraud.Lifecycle(startCtx, ctx, byzantine.BadEncoding, fservice,
 					syncer.Start, syncer.Stop)
 			}),
 			fx.OnStop(func(ctx context.Context, syncer *sync.Syncer[*header.ExtendedHeader]) error {
diff --git a/nodebuilder/p2p/pubsub.go b/nodebuilder/p2p/pubsub.go
index fd31bdc0..d8d302a5 100644
--- a/nodebuilder/p2p/pubsub.go
+++ b/nodebuilder/p2p/pubsub.go
@@ -15,7 +15,7 @@ import (
 	"go.uber.org/fx"
 	"golang.org/x/crypto/blake2b"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	headp2p "github.com/celestiaorg/celestia-node/libs/header/p2p"
 )
 
diff --git a/nodebuilder/settings.go b/nodebuilder/settings.go
index a41831b1..14d73a9f 100644
--- a/nodebuilder/settings.go
+++ b/nodebuilder/settings.go
@@ -13,7 +13,7 @@ import (
 	semconv "go.opentelemetry.io/otel/semconv/v1.11.0"
 	"go.uber.org/fx"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	"github.com/celestiaorg/celestia-node/nodebuilder/das"
 	modheader "github.com/celestiaorg/celestia-node/nodebuilder/header"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
diff --git a/nodebuilder/state/module.go b/nodebuilder/state/module.go
index b8553715..bce96b3f 100644
--- a/nodebuilder/state/module.go
+++ b/nodebuilder/state/module.go
@@ -6,9 +6,10 @@ import (
 	logging "github.com/ipfs/go-log/v2"
 	"go.uber.org/fx"
 
-	"github.com/celestiaorg/celestia-node/fraud"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	fraudServ "github.com/celestiaorg/celestia-node/nodebuilder/fraud"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 	"github.com/celestiaorg/celestia-node/state"
 )
 
@@ -26,7 +27,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
 		fx.Provide(fx.Annotate(
 			coreAccessor,
 			fx.OnStart(func(startCtx, ctx context.Context, fservice fraud.Service, ca *state.CoreAccessor) error {
-				return fraudServ.Lifecycle(startCtx, ctx, fraud.BadEncoding, fservice, ca.Start, ca.Stop)
+				return fraudServ.Lifecycle(startCtx, ctx, byzantine.BadEncoding, fservice, ca.Start, ca.Stop)
 			}),
 			fx.OnStop(func(ctx context.Context, ca *state.CoreAccessor) error {
 				return ca.Stop(ctx)
diff --git a/share/eds/byzantine/bad_encoding.go b/share/eds/byzantine/bad_encoding.go
index 0ba2a34b..6bee1ff4 100644
--- a/share/eds/byzantine/bad_encoding.go
+++ b/share/eds/byzantine/bad_encoding.go
@@ -9,12 +9,17 @@ import (
 	"github.com/celestiaorg/celestia-app/pkg/wrapper"
 	"github.com/celestiaorg/rsmt2d"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
+	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	pb "github.com/celestiaorg/celestia-node/share/eds/byzantine/pb"
 	"github.com/celestiaorg/celestia-node/share/ipld"
 )
 
+const (
+	BadEncoding fraud.ProofType = "badencoding"
+)
+
 func init() {
 	fraud.Register(&BadEncodingProof{})
 }
@@ -52,7 +57,7 @@ func CreateBadEncodingProof(
 
 // Type returns type of fraud proof.
 func (p *BadEncodingProof) Type() fraud.ProofType {
-	return fraud.BadEncoding
+	return BadEncoding
 }
 
 // HeaderHash returns block hash.
@@ -105,7 +110,11 @@ func (p *BadEncodingProof) UnmarshalBinary(data []byte) error {
 // Validate checks that provided Merkle Proofs correspond to the shares,
 // rebuilds bad row or col from received shares, computes Merkle Root
 // and compares it with block's Merkle Root.
-func (p *BadEncodingProof) Validate(header *header.ExtendedHeader) error {
+func (p *BadEncodingProof) Validate(hdr libhead.Header) error {
+	header, ok := hdr.(*header.ExtendedHeader)
+	if !ok {
+		panic(fmt.Sprintf("invalid header type: expected %T, got %T", header, hdr))
+	}
 	if header.Height() != int64(p.BlockHeight) {
 		return errors.New("fraud: incorrect block height")
 	}


Test patch:
diff --git a/das/daser_test.go b/das/daser_test.go
index 2dd43894..bf4dd34a 100644
--- a/das/daser_test.go
+++ b/das/daser_test.go
@@ -16,15 +16,16 @@ import (
 	"github.com/stretchr/testify/require"
 	"github.com/tendermint/tendermint/types"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
 	"github.com/celestiaorg/celestia-node/header/headertest"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/availability/full"
 	"github.com/celestiaorg/celestia-node/share/availability/light"
 	"github.com/celestiaorg/celestia-node/share/availability/mocks"
 	availability_test "github.com/celestiaorg/celestia-node/share/availability/test"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 	"github.com/celestiaorg/celestia-node/share/getters"
 )
 
@@ -155,7 +156,10 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
 	mockGet, sub, _ := createDASerSubcomponents(t, bServ, 15, 15)
 
 	// create fraud service and break one header
-	f := fraud.NewProofService(ps, net.Hosts()[0], mockGet.GetByHeight, ds, false, "private")
+	getter := func(ctx context.Context, height uint64) (libhead.Header, error) {
+		return mockGet.GetByHeight(ctx, height)
+	}
+	f := fraud.NewProofService(ps, net.Hosts()[0], getter, ds, false, "private")
 	require.NoError(t, f.Start(ctx))
 	mockGet.headers[1], _ = headertest.CreateFraudExtHeader(t, mockGet.headers[1], bServ)
 	newCtx := context.Background()
@@ -165,7 +169,7 @@ func TestDASer_stopsAfter_BEFP(t *testing.T) {
 	require.NoError(t, err)
 
 	resultCh := make(chan error)
-	go fraud.OnProof(newCtx, f, fraud.BadEncoding,
+	go fraud.OnProof(newCtx, f, byzantine.BadEncoding,
 		func(fraud.Proof) {
 			resultCh <- daser.Stop(newCtx)
 		})
diff --git a/fraud/service.go b/libs/fraud/service.go
similarity index 100%
rename from fraud/service.go
rename to libs/fraud/service.go
diff --git a/fraud/service_test.go b/libs/fraud/service_test.go
similarity index 95%
rename from fraud/service_test.go
rename to libs/fraud/service_test.go
index a1f405e3..245eeaa5 100644
--- a/fraud/service_test.go
+++ b/libs/fraud/service_test.go
@@ -15,7 +15,8 @@ import (
 	mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
 	"github.com/stretchr/testify/require"
 
-	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/header"
+	"github.com/celestiaorg/celestia-node/libs/header/test"
 )
 
 func TestService_Subscribe(t *testing.T) {
@@ -127,8 +128,8 @@ func TestService_ReGossiping(t *testing.T) {
 	pserviceB := NewProofService(
 		psB,
 		net.Hosts()[1],
-		func(ctx context.Context, u uint64) (*header.ExtendedHeader, error) {
-			return &header.ExtendedHeader{}, nil
+		func(ctx context.Context, u uint64) (header.Header, error) {
+			return &test.DummyHeader{}, nil
 		},
 		sync.MutexWrap(datastore.NewMapDatastore()),
 		false,
@@ -143,8 +144,8 @@ func TestService_ReGossiping(t *testing.T) {
 	pserviceC := NewProofService(
 		psC,
 		net.Hosts()[2],
-		func(ctx context.Context, u uint64) (*header.ExtendedHeader, error) {
-			return &header.ExtendedHeader{}, nil
+		func(ctx context.Context, u uint64) (header.Header, error) {
+			return &test.DummyHeader{}, nil
 		},
 		sync.MutexWrap(datastore.NewMapDatastore()),
 		false,
diff --git a/fraud/testing.go b/libs/fraud/testing.go
similarity index 92%
rename from fraud/testing.go
rename to libs/fraud/testing.go
index bfed3eef..24cfca0c 100644
--- a/fraud/testing.go
+++ b/libs/fraud/testing.go
@@ -14,8 +14,8 @@ import (
 	mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
 	"github.com/stretchr/testify/require"
 
-	"github.com/celestiaorg/celestia-node/header"
 	"github.com/celestiaorg/celestia-node/header/headertest"
+	"github.com/celestiaorg/celestia-node/libs/header"
 )
 
 type DummyService struct {
@@ -34,7 +34,7 @@ func (d *DummyService) Get(context.Context, ProofType) ([]Proof, error) {
 }
 
 type mockStore struct {
-	headers    map[int64]*header.ExtendedHeader
+	headers    map[int64]header.Header
 	headHeight int64
 }
 
@@ -42,7 +42,7 @@ type mockStore struct {
 // headers.
 func createStore(t *testing.T, numHeaders int) *mockStore {
 	store := &mockStore{
-		headers:    make(map[int64]*header.ExtendedHeader),
+		headers:    make(map[int64]header.Header),
 		headHeight: 0,
 	}
 
@@ -59,7 +59,7 @@ func createStore(t *testing.T, numHeaders int) *mockStore {
 	return store
 }
 
-func (m *mockStore) GetByHeight(_ context.Context, height uint64) (*header.ExtendedHeader, error) {
+func (m *mockStore) GetByHeight(_ context.Context, height uint64) (header.Header, error) {
 	return m.headers[int64(height)], nil
 }
 
@@ -101,7 +101,7 @@ func (m *mockProof) Height() uint64 {
 	return 1
 }
 
-func (m *mockProof) Validate(*header.ExtendedHeader) error {
+func (m *mockProof) Validate(header.Header) error {
 	if !m.Valid {
 		return errors.New("mockProof: proof is not valid")
 	}
diff --git a/nodebuilder/header/module_test.go b/nodebuilder/header/module_test.go
index f995a4fb..18d72eaf 100644
--- a/nodebuilder/header/module_test.go
+++ b/nodebuilder/header/module_test.go
@@ -13,8 +13,8 @@ import (
 	"go.uber.org/fx"
 	"go.uber.org/fx/fxtest"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	libhead "github.com/celestiaorg/celestia-node/libs/header"
 	"github.com/celestiaorg/celestia-node/libs/header/p2p"
 	"github.com/celestiaorg/celestia-node/libs/header/store"
diff --git a/nodebuilder/tests/fraud_test.go b/nodebuilder/tests/fraud_test.go
index 75615938..ac6858d1 100644
--- a/nodebuilder/tests/fraud_test.go
+++ b/nodebuilder/tests/fraud_test.go
@@ -10,12 +10,12 @@ import (
 	"github.com/libp2p/go-libp2p/core/peer"
 	"github.com/stretchr/testify/require"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header/headertest"
 	"github.com/celestiaorg/celestia-node/nodebuilder"
 	"github.com/celestiaorg/celestia-node/nodebuilder/core"
 	"github.com/celestiaorg/celestia-node/nodebuilder/node"
 	"github.com/celestiaorg/celestia-node/nodebuilder/tests/swamp"
+	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 )
 
 /*
@@ -67,7 +67,7 @@ func TestFraudProofBroadcasting(t *testing.T) {
 
 	// subscribe to fraud proof before node starts helps
 	// to prevent flakiness when fraud proof is propagating before subscribing on it
-	subscr, err := full.FraudServ.Subscribe(ctx, fraud.BadEncoding)
+	subscr, err := full.FraudServ.Subscribe(ctx, byzantine.BadEncoding)
 	require.NoError(t, err)
 
 	p := <-subscr
@@ -88,7 +88,7 @@ func TestFraudProofBroadcasting(t *testing.T) {
 	full = sw.NewNodeWithStore(node.Full, store)
 
 	require.Error(t, full.Start(ctx))
-	proofs, err := full.FraudServ.Get(ctx, fraud.BadEncoding)
+	proofs, err := full.FraudServ.Get(ctx, byzantine.BadEncoding)
 	require.NoError(t, err)
 	require.NotNil(t, proofs)
 	require.NoError(t, <-fillDn)
@@ -144,7 +144,7 @@ func TestFraudProofSyncing(t *testing.T) {
 	ln := sw.NewNodeWithStore(node.Light, nodebuilder.MockStore(t, lightCfg))
 	require.NoError(t, full.Start(ctx))
 
-	subsFN, err := full.FraudServ.Subscribe(ctx, fraud.BadEncoding)
+	subsFN, err := full.FraudServ.Subscribe(ctx, byzantine.BadEncoding)
 	require.NoError(t, err)
 
 	select {
@@ -159,7 +159,7 @@ func TestFraudProofSyncing(t *testing.T) {
 
 	// internal subscription for the fraud proof is done in order to ensure that light node
 	// receives the BEFP.
-	subsLN, err := ln.FraudServ.Subscribe(ctx, fraud.BadEncoding)
+	subsLN, err := ln.FraudServ.Subscribe(ctx, byzantine.BadEncoding)
 	require.NoError(t, err)
 
 	// ensure that the full and light node are connected to speed up test
diff --git a/share/eds/retriever_test.go b/share/eds/retriever_test.go
index 4c1985b3..0308bb99 100644
--- a/share/eds/retriever_test.go
+++ b/share/eds/retriever_test.go
@@ -17,9 +17,9 @@ import (
 	"github.com/celestiaorg/nmt"
 	"github.com/celestiaorg/rsmt2d"
 
-	"github.com/celestiaorg/celestia-node/fraud"
 	"github.com/celestiaorg/celestia-node/header"
 	"github.com/celestiaorg/celestia-node/header/headertest"
+	"github.com/celestiaorg/celestia-node/libs/fraud"
 	"github.com/celestiaorg/celestia-node/share"
 	"github.com/celestiaorg/celestia-node/share/eds/byzantine"
 	"github.com/celestiaorg/celestia-node/share/ipld"
@@ -157,7 +157,7 @@ func generateByzantineError(
 	h, err := store.GetByHeight(ctx, 1)
 	require.NoError(t, err)
 
-	faultHeader, _ := headertest.CreateFraudExtHeader(t, h, bServ)
+	faultHeader, _ := headertest.CreateFraudExtHeader(t, h.(*header.ExtendedHeader), bServ)
 	_, err = NewRetriever(bServ).Retrieve(ctx, faultHeader.DAH)
 	return faultHeader, err
 }