Skip to content

Commit

Permalink
Remove Evidence while keeping ABCI compatibility. (cosmos#915)
Browse files Browse the repository at this point in the history
Removes Evidence from Block struct. Comments out relevant code lines
with:
```// Note: Temporarily remove Evidence cosmos#896```

for adding back in the future when needed.


Closes: cosmos#896

---------

Co-authored-by: Ganesha Upadhyaya <[email protected]>
  • Loading branch information
Manav-Aggarwal and Ganesha Upadhyaya authored May 11, 2023
1 parent 0c866b5 commit 451c950
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 132 deletions.
1 change: 0 additions & 1 deletion proto/rollkit/rollkit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ message SignedHeader {
message Data {
repeated bytes txs = 1;
repeated bytes intermediate_state_roots = 2;
repeated tendermint.abci.Evidence evidence = 3;
}

message Block {
Expand Down
3 changes: 2 additions & 1 deletion state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func (e *BlockExecutor) CreateBlock(height uint64, lastCommit *types.Commit, las
Data: types.Data{
Txs: toRollkitTxs(mempoolTxs),
IntermediateStateRoots: types.IntermediateStateRoots{RawRootsList: nil},
Evidence: types.EvidenceData{Evidence: nil},
// Note: Temporarily remove Evidence #896
// Evidence: types.EvidenceData{Evidence: nil},
},
}
block.SignedHeader.Header.LastCommitHash = e.getLastCommitHash(lastCommit, &block.SignedHeader.Header)
Expand Down
3 changes: 2 additions & 1 deletion types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var _ encoding.BinaryUnmarshaler = &Block{}
type Data struct {
Txs Txs
IntermediateStateRoots IntermediateStateRoots
Evidence EvidenceData
// Note: Temporarily remove Evidence #896
// Evidence EvidenceData
}

// EvidenceData defines how evidence is stored in block.
Expand Down
152 changes: 44 additions & 108 deletions types/pb/rollkit/rollkit.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 22 additions & 20 deletions types/serialization.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
abci "github.com/tendermint/tendermint/abci/types"

"github.com/tendermint/tendermint/types"

pb "github.com/rollkit/rollkit/types/pb/rollkit"
Expand Down Expand Up @@ -183,7 +181,8 @@ func (d *Data) ToProto() *pb.Data {
return &pb.Data{
Txs: txsToByteSlices(d.Txs),
IntermediateStateRoots: d.IntermediateStateRoots.RawRootsList,
Evidence: evidenceToProto(d.Evidence),
// Note: Temporarily remove Evidence #896
// Evidence: evidenceToProto(d.Evidence),
}
}

Expand All @@ -195,7 +194,8 @@ func (b *Block) FromProto(other *pb.Block) error {
}
b.Data.Txs = byteSlicesToTxs(other.Data.Txs)
b.Data.IntermediateStateRoots.RawRootsList = other.Data.IntermediateStateRoots
b.Data.Evidence = evidenceFromProto(other.Data.Evidence)
// Note: Temporarily remove Evidence #896
// b.Data.Evidence = evidenceFromProto(other.Data.Evidence)

return nil
}
Expand Down Expand Up @@ -302,22 +302,24 @@ func byteSlicesToTxs(bytes [][]byte) Txs {
return txs
}

func evidenceToProto(evidence EvidenceData) []*abci.Evidence {
var ret []*abci.Evidence
for _, e := range evidence.Evidence {
for i := range e.ABCI() {
ae := e.ABCI()[i]
ret = append(ret, &ae)
}
}
return ret
}

func evidenceFromProto(evidence []*abci.Evidence) EvidenceData {
var ret EvidenceData
// TODO(tzdybal): right now Evidence is just an interface without implementations
return ret
}
// Note: Temporarily remove Evidence #896

// func evidenceToProto(evidence EvidenceData) []*abci.Evidence {
// var ret []*abci.Evidence
// for _, e := range evidence.Evidence {
// for i := range e.ABCI() {
// ae := e.ABCI()[i]
// ret = append(ret, &ae)
// }
// }
// return ret
// }

// func evidenceFromProto(evidence []*abci.Evidence) EvidenceData {
// var ret EvidenceData
// // TODO(tzdybal): right now Evidence is just an interface without implementations
// return ret
// }

func signaturesToByteSlices(sigs []Signature) [][]byte {
if sigs == nil {
Expand Down
3 changes: 2 additions & 1 deletion types/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func TestBlockSerializationRoundTrip(t *testing.T) {
Txs: nil,
IntermediateStateRoots: IntermediateStateRoots{RawRootsList: [][]byte{{0x1}}},
// TODO(tzdybal): update when we have actual evidence types
Evidence: EvidenceData{Evidence: nil},
// Note: Temporarily remove Evidence #896
// Evidence: EvidenceData{Evidence: nil},
},
}},
}
Expand Down

0 comments on commit 451c950

Please sign in to comment.