diff --git a/api/poktroll/proof/event.pulsar.go b/api/poktroll/proof/event.pulsar.go index fa9a83ea1..9ec8937e5 100644 --- a/api/poktroll/proof/event.pulsar.go +++ b/api/poktroll/proof/event.pulsar.go @@ -2805,11 +2805,11 @@ func (x *fastReflection_EventProofUpdated) ProtoMethods() *protoiface.Methods { } var ( - md_EventProofValidityChecked protoreflect.MessageDescriptor - fd_EventProofValidityChecked_proof protoreflect.FieldDescriptor - fd_EventProofValidityChecked_block_height protoreflect.FieldDescriptor - fd_EventProofValidityChecked_proof_status protoreflect.FieldDescriptor - fd_EventProofValidityChecked_reason protoreflect.FieldDescriptor + md_EventProofValidityChecked protoreflect.MessageDescriptor + fd_EventProofValidityChecked_proof protoreflect.FieldDescriptor + fd_EventProofValidityChecked_block_height protoreflect.FieldDescriptor + fd_EventProofValidityChecked_proof_status protoreflect.FieldDescriptor + fd_EventProofValidityChecked_failure_reason protoreflect.FieldDescriptor ) func init() { @@ -2818,7 +2818,7 @@ func init() { fd_EventProofValidityChecked_proof = md_EventProofValidityChecked.Fields().ByName("proof") fd_EventProofValidityChecked_block_height = md_EventProofValidityChecked.Fields().ByName("block_height") fd_EventProofValidityChecked_proof_status = md_EventProofValidityChecked.Fields().ByName("proof_status") - fd_EventProofValidityChecked_reason = md_EventProofValidityChecked.Fields().ByName("reason") + fd_EventProofValidityChecked_failure_reason = md_EventProofValidityChecked.Fields().ByName("failure_reason") } var _ protoreflect.Message = (*fastReflection_EventProofValidityChecked)(nil) @@ -2904,9 +2904,9 @@ func (x *fastReflection_EventProofValidityChecked) Range(f func(protoreflect.Fie return } } - if x.Reason != "" { - value := protoreflect.ValueOfString(x.Reason) - if !f(fd_EventProofValidityChecked_reason, value) { + if x.FailureReason != "" { + value := protoreflect.ValueOfString(x.FailureReason) + if !f(fd_EventProofValidityChecked_failure_reason, value) { return } } @@ -2931,8 +2931,8 @@ func (x *fastReflection_EventProofValidityChecked) Has(fd protoreflect.FieldDesc return x.BlockHeight != uint64(0) case "poktroll.proof.EventProofValidityChecked.proof_status": return x.ProofStatus != 0 - case "poktroll.proof.EventProofValidityChecked.reason": - return x.Reason != "" + case "poktroll.proof.EventProofValidityChecked.failure_reason": + return x.FailureReason != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.proof.EventProofValidityChecked")) @@ -2955,8 +2955,8 @@ func (x *fastReflection_EventProofValidityChecked) Clear(fd protoreflect.FieldDe x.BlockHeight = uint64(0) case "poktroll.proof.EventProofValidityChecked.proof_status": x.ProofStatus = 0 - case "poktroll.proof.EventProofValidityChecked.reason": - x.Reason = "" + case "poktroll.proof.EventProofValidityChecked.failure_reason": + x.FailureReason = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.proof.EventProofValidityChecked")) @@ -2982,8 +2982,8 @@ func (x *fastReflection_EventProofValidityChecked) Get(descriptor protoreflect.F case "poktroll.proof.EventProofValidityChecked.proof_status": value := x.ProofStatus return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(value)) - case "poktroll.proof.EventProofValidityChecked.reason": - value := x.Reason + case "poktroll.proof.EventProofValidityChecked.failure_reason": + value := x.FailureReason return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { @@ -3011,8 +3011,8 @@ func (x *fastReflection_EventProofValidityChecked) Set(fd protoreflect.FieldDesc x.BlockHeight = value.Uint() case "poktroll.proof.EventProofValidityChecked.proof_status": x.ProofStatus = (ClaimProofStatus)(value.Enum()) - case "poktroll.proof.EventProofValidityChecked.reason": - x.Reason = value.Interface().(string) + case "poktroll.proof.EventProofValidityChecked.failure_reason": + x.FailureReason = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.proof.EventProofValidityChecked")) @@ -3042,8 +3042,8 @@ func (x *fastReflection_EventProofValidityChecked) Mutable(fd protoreflect.Field panic(fmt.Errorf("field block_height of message poktroll.proof.EventProofValidityChecked is not mutable")) case "poktroll.proof.EventProofValidityChecked.proof_status": panic(fmt.Errorf("field proof_status of message poktroll.proof.EventProofValidityChecked is not mutable")) - case "poktroll.proof.EventProofValidityChecked.reason": - panic(fmt.Errorf("field reason of message poktroll.proof.EventProofValidityChecked is not mutable")) + case "poktroll.proof.EventProofValidityChecked.failure_reason": + panic(fmt.Errorf("field failure_reason of message poktroll.proof.EventProofValidityChecked is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.proof.EventProofValidityChecked")) @@ -3064,7 +3064,7 @@ func (x *fastReflection_EventProofValidityChecked) NewField(fd protoreflect.Fiel return protoreflect.ValueOfUint64(uint64(0)) case "poktroll.proof.EventProofValidityChecked.proof_status": return protoreflect.ValueOfEnum(0) - case "poktroll.proof.EventProofValidityChecked.reason": + case "poktroll.proof.EventProofValidityChecked.failure_reason": return protoreflect.ValueOfString("") default: if fd.IsExtension() { @@ -3145,7 +3145,7 @@ func (x *fastReflection_EventProofValidityChecked) ProtoMethods() *protoiface.Me if x.ProofStatus != 0 { n += 1 + runtime.Sov(uint64(x.ProofStatus)) } - l = len(x.Reason) + l = len(x.FailureReason) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } @@ -3178,10 +3178,10 @@ func (x *fastReflection_EventProofValidityChecked) ProtoMethods() *protoiface.Me i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Reason) > 0 { - i -= len(x.Reason) - copy(dAtA[i:], x.Reason) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Reason))) + if len(x.FailureReason) > 0 { + i -= len(x.FailureReason) + copy(dAtA[i:], x.FailureReason) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FailureReason))) i-- dAtA[i] = 0x22 } @@ -3334,7 +3334,7 @@ func (x *fastReflection_EventProofValidityChecked) ProtoMethods() *protoiface.Me } case 4: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FailureReason", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3362,7 +3362,7 @@ func (x *fastReflection_EventProofValidityChecked) ProtoMethods() *protoiface.Me if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Reason = string(dAtA[iNdEx:postIndex]) + x.FailureReason = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3710,7 +3710,7 @@ type EventProofValidityChecked struct { ProofStatus ClaimProofStatus `protobuf:"varint,3,opt,name=proof_status,json=proofStatus,proto3,enum=poktroll.proof.ClaimProofStatus" json:"proof_status,omitempty"` // reason is the string representation of the error that led to the proof being // marked as invalid (e.g. "invalid closest merkle proof", "invalid relay request signature") - Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason,omitempty"` + FailureReason string `protobuf:"bytes,4,opt,name=failure_reason,json=failureReason,proto3" json:"failure_reason,omitempty"` } func (x *EventProofValidityChecked) Reset() { @@ -3754,9 +3754,9 @@ func (x *EventProofValidityChecked) GetProofStatus() ClaimProofStatus { return ClaimProofStatus_PENDING_VALIDATION } -func (x *EventProofValidityChecked) GetReason() string { +func (x *EventProofValidityChecked) GetFailureReason() string { if x != nil { - return x.Reason + return x.FailureReason } return "" } @@ -3877,7 +3877,7 @@ var file_poktroll_proof_event_proto_rawDesc = []byte{ 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x11, 0xea, 0xde, 0x1f, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x64, 0x5f, 0x75, 0x70, 0x6f, 0x6b, 0x74, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, - 0x6d, 0x65, 0x64, 0x55, 0x70, 0x6f, 0x6b, 0x74, 0x22, 0x83, 0x02, 0x0a, 0x19, 0x45, 0x76, 0x65, + 0x6d, 0x65, 0x64, 0x55, 0x70, 0x6f, 0x6b, 0x74, 0x22, 0x9a, 0x02, 0x0a, 0x19, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x64, 0x12, 0x36, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, @@ -3891,20 +3891,21 @@ var file_poktroll_proof_event_proto_rawDesc = []byte{ 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x10, 0xea, 0xde, 0x1f, 0x0c, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0b, 0x70, - 0x72, 0x6f, 0x6f, 0x66, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x06, 0x72, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xea, 0xde, 0x1f, 0x06, - 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x42, 0x9e, - 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0xa2, 0x02, 0x03, 0x50, 0x50, 0x58, 0xaa, 0x02, - 0x0e, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0xca, - 0x02, 0x0e, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x6f, 0x66, - 0xe2, 0x02, 0x1a, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x6f, - 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x6f, 0x66, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x39, 0x0a, 0x0e, 0x66, 0x61, + 0x69, 0x6c, 0x75, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x12, 0xea, 0xde, 0x1f, 0x0e, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x5f, + 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x0d, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x52, + 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x42, 0x9e, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x12, 0x63, 0x6f, + 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x6f, 0x66, + 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0xa2, + 0x02, 0x03, 0x50, 0x50, 0x58, 0xaa, 0x02, 0x0e, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0xca, 0x02, 0x0e, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0xe2, 0x02, 0x1a, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, + 0x3a, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/crypto/protocol/hasher.go b/pkg/crypto/protocol/hasher.go index 918c576bf..db95bc6f7 100644 --- a/pkg/crypto/protocol/hasher.go +++ b/pkg/crypto/protocol/hasher.go @@ -1,6 +1,10 @@ package protocol -import "crypto/sha256" +import ( + "crypto/sha256" + + "github.com/pokt-network/smt" +) const ( RelayHasherSize = sha256.Size @@ -15,3 +19,7 @@ var ( NewRelayHasher = sha256.New NewTrieHasher = sha256.New ) + +func SMTValueHasher() smt.TrieSpecOption { + return smt.WithValueHasher(nil) +} diff --git a/pkg/crypto/protocol/proof_path.go b/pkg/crypto/protocol/proof_path.go index 1a48b40ee..1a3dce465 100644 --- a/pkg/crypto/protocol/proof_path.go +++ b/pkg/crypto/protocol/proof_path.go @@ -1,18 +1,13 @@ package protocol import ( - "crypto/sha256" - "github.com/pokt-network/smt" ) -// newHasher is the hash function used by the SMT specification. -var newHasher = sha256.New - // GetPathForProof computes the path to be used for proof validation by hashing // the block hash and session id. func GetPathForProof(blockHash []byte, sessionId string) []byte { - hasher := newHasher() + hasher := NewTrieHasher() if _, err := hasher.Write(append(blockHash, []byte(sessionId)...)); err != nil { panic(err) } @@ -20,13 +15,13 @@ func GetPathForProof(blockHash []byte, sessionId string) []byte { return hasher.Sum(nil) } -// NewSMTSpec returns the SMT specification used for the proof verification. -// It uses a new hasher at every call to avoid concurrency issues that could be -// caused by a shared hasher. +// NewSMTSpec returns the SMT specification used for proof verification. +// A new hasher is created for each call to prevent concurrency issues +// from shared state. func NewSMTSpec() *smt.TrieSpec { trieSpec := smt.NewTrieSpec( - newHasher(), true, - smt.WithValueHasher(nil), + NewTrieHasher(), true, + SMTValueHasher(), ) return &trieSpec diff --git a/pkg/relayer/session/sessiontree.go b/pkg/relayer/session/sessiontree.go index 42269c973..a5a56137c 100644 --- a/pkg/relayer/session/sessiontree.go +++ b/pkg/relayer/session/sessiontree.go @@ -2,7 +2,6 @@ package session import ( "bytes" - "crypto/sha256" "fmt" "os" "path/filepath" @@ -94,7 +93,7 @@ func NewSessionTree( // Create the SMST from the KVStore and a nil value hasher so the proof would // contain a non-hashed Relay that could be used to validate the proof onchain. - trie := smt.NewSparseMerkleSumTrie(treeStore, protocol.NewTrieHasher(), smt.WithValueHasher(nil)) + trie := smt.NewSparseMerkleSumTrie(treeStore, protocol.NewTrieHasher(), protocol.SMTValueHasher()) logger = logger.With( "store_path", storePath, @@ -175,7 +174,7 @@ func (st *sessionTree) ProveClosest(path []byte) (compactProof *smt.SparseCompac return nil, err } - sessionSMT := smt.ImportSparseMerkleSumTrie(st.treeStore, sha256.New(), st.claimedRoot, smt.WithValueHasher(nil)) + sessionSMT := smt.ImportSparseMerkleSumTrie(st.treeStore, protocol.NewTrieHasher(), st.claimedRoot, protocol.SMTValueHasher()) // Generate the proof and cache it along with the path for which it was generated. // There is no ProveClosest variant that generates a compact proof directly. diff --git a/pkg/relayer/session/sessiontree_test.go b/pkg/relayer/session/sessiontree_test.go index 762ebcb1b..c42e6d568 100644 --- a/pkg/relayer/session/sessiontree_test.go +++ b/pkg/relayer/session/sessiontree_test.go @@ -39,7 +39,7 @@ func TestSessionTree_CompactProofsAreSmallerThanNonCompactProofs(t *testing.T) { kvStore, err := pebble.NewKVStore("") require.NoError(t, err) - trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), smt.WithValueHasher(nil)) + trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), protocol.SMTValueHasher()) // Insert numLeaf random leaves. for i := 0; i < numLeafs; i++ { diff --git a/proto/poktroll/proof/event.proto b/proto/poktroll/proof/event.proto index 271a6c355..f14fbd8b5 100644 --- a/proto/poktroll/proof/event.proto +++ b/proto/poktroll/proof/event.proto @@ -52,5 +52,5 @@ message EventProofValidityChecked { poktroll.proof.ClaimProofStatus proof_status = 3 [(gogoproto.jsontag) = "proof_status"]; // reason is the string representation of the error that led to the proof being // marked as invalid (e.g. "invalid closest merkle proof", "invalid relay request signature") - string reason = 4 [(gogoproto.jsontag) = "reason"]; + string failure_reason = 4 [(gogoproto.jsontag) = "failure_reason"]; } diff --git a/tests/integration/service/relay_mining_difficulty_test.go b/tests/integration/service/relay_mining_difficulty_test.go index 050b8328c..1a171e5c3 100644 --- a/tests/integration/service/relay_mining_difficulty_test.go +++ b/tests/integration/service/relay_mining_difficulty_test.go @@ -200,7 +200,7 @@ func prepareSMST( // TODO_TECHDEBT(#446): Centralize the configuration for the SMT spec. kvStore, err := pebble.NewKVStore("") require.NoError(t, err) - trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), smt.WithValueHasher(nil)) + trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), protocol.SMTValueHasher()) for i := uint64(0); i < numRelays; i++ { // DEV_NOTE: A signed mined relay is a MinedRelay type with the appropriate diff --git a/tests/integration/tokenomics/relay_mining_integration_test.go b/tests/integration/tokenomics/relay_mining_integration_test.go index 3a9231c4a..f0d1dfa17 100644 --- a/tests/integration/tokenomics/relay_mining_integration_test.go +++ b/tests/integration/tokenomics/relay_mining_integration_test.go @@ -214,7 +214,7 @@ func prepareRealClaim( require.NoError(t, err) // Prepare an SMST - trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), smt.WithValueHasher(nil)) + trie := smt.NewSparseMerkleSumTrie(kvStore, protocol.NewTrieHasher(), protocol.SMTValueHasher()) // Insert the mined relays into the SMST for i := uint64(0); i < numRelays; i++ { diff --git a/x/proof/keeper/validate_proofs.go b/x/proof/keeper/validate_proofs.go index 0e085aafe..b6627aeb3 100644 --- a/x/proof/keeper/validate_proofs.go +++ b/x/proof/keeper/validate_proofs.go @@ -151,14 +151,14 @@ func (k Keeper) validateProof( // Set the proof status to valid by default. proofStatus := types.ClaimProofStatus_VALIDATED // Set the invalidity reason to an empty string by default. - invalidProofCause := "" + invalidProofReason := "" if err := k.EnsureValidProofSignaturesAndClosestPath(ctx, &claim, &proof); err != nil { // Set the proof status to invalid. proofStatus = types.ClaimProofStatus_INVALID // Set the invalidity reason to the error message. - invalidProofCause = err.Error() + invalidProofReason = err.Error() logger.Info(fmt.Sprintf("invalid proof due to error: %v", err)) } @@ -166,10 +166,10 @@ func (k Keeper) validateProof( // Create and emit an event for the proof validation result. eventProofValidityChecked := types.EventProofValidityChecked{ - Proof: &proof, - BlockHeight: uint64(sdkCtx.BlockHeight()), - ProofStatus: proofStatus, - Reason: invalidProofCause, + Proof: &proof, + BlockHeight: uint64(sdkCtx.BlockHeight()), + ProofStatus: proofStatus, + FailureReason: invalidProofReason, } if err := sdkCtx.EventManager().EmitTypedEvent(&eventProofValidityChecked); err != nil { diff --git a/x/proof/types/event.pb.go b/x/proof/types/event.pb.go index 45873d3b6..3d0e25004 100644 --- a/x/proof/types/event.pb.go +++ b/x/proof/types/event.pb.go @@ -338,7 +338,7 @@ type EventProofValidityChecked struct { ProofStatus ClaimProofStatus `protobuf:"varint,3,opt,name=proof_status,json=proofStatus,proto3,enum=poktroll.proof.ClaimProofStatus" json:"proof_status"` // reason is the string representation of the error that led to the proof being // marked as invalid (e.g. "invalid closest merkle proof", "invalid relay request signature") - Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason"` + FailureReason string `protobuf:"bytes,4,opt,name=failure_reason,json=failureReason,proto3" json:"failure_reason"` } func (m *EventProofValidityChecked) Reset() { *m = EventProofValidityChecked{} } @@ -391,9 +391,9 @@ func (m *EventProofValidityChecked) GetProofStatus() ClaimProofStatus { return ClaimProofStatus_PENDING_VALIDATION } -func (m *EventProofValidityChecked) GetReason() string { +func (m *EventProofValidityChecked) GetFailureReason() string { if m != nil { - return m.Reason + return m.FailureReason } return "" } @@ -409,42 +409,43 @@ func init() { func init() { proto.RegisterFile("poktroll/proof/event.proto", fileDescriptor_dd4c19e04487fbec) } var fileDescriptor_dd4c19e04487fbec = []byte{ - // 551 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0x4f, 0x6f, 0xda, 0x3e, - 0x18, 0xc7, 0x49, 0x29, 0x48, 0x18, 0x7e, 0xe8, 0xd7, 0xec, 0x8f, 0x80, 0x69, 0x09, 0xea, 0xa9, - 0x97, 0x26, 0x6a, 0x2b, 0xf5, 0x05, 0x10, 0x55, 0xda, 0x61, 0x87, 0x2d, 0x13, 0xd3, 0xb4, 0xc3, - 0x50, 0x12, 0x3c, 0xb0, 0x88, 0xed, 0x28, 0xb1, 0xbb, 0x71, 0xde, 0x61, 0xd7, 0xbd, 0xa3, 0x69, - 0xb7, 0x1d, 0x7b, 0xec, 0x29, 0x9a, 0xe0, 0x96, 0x57, 0x31, 0xf9, 0x71, 0x58, 0x01, 0x75, 0x93, - 0xaa, 0x4a, 0xdb, 0x85, 0x93, 0xfd, 0x3c, 0xdf, 0xe7, 0x6b, 0x9b, 0xe7, 0x43, 0x6c, 0xd4, 0x4b, - 0xf8, 0x4c, 0xa4, 0x3c, 0x8e, 0xdd, 0x24, 0xe5, 0xfc, 0xbd, 0x8b, 0x2f, 0x31, 0x13, 0x4e, 0x92, - 0x72, 0xc1, 0xcd, 0xf6, 0x4a, 0x73, 0x40, 0xeb, 0x59, 0x11, 0xcf, 0x28, 0xcf, 0xdc, 0x30, 0xc8, - 0xb0, 0x7b, 0x79, 0x12, 0x62, 0x11, 0x9c, 0xb8, 0x11, 0x27, 0x4c, 0xd7, 0xf7, 0x1e, 0x4e, 0xf8, - 0x84, 0xc3, 0xd4, 0x55, 0xb3, 0x32, 0xbb, 0xbd, 0x83, 0x98, 0x27, 0x38, 0xd3, 0xda, 0xe1, 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0x4f, 0x67, 0xee, 0xaf, 0x17, - 0xff, 0xe3, 0xfa, 0x9b, 0x1f, 0xd6, 0xe1, 0xd1, 0x3f, 0xfb, 0x19, 0x00, 0x00, 0xff, 0xff, 0x68, - 0x6f, 0xcf, 0x81, 0x74, 0x08, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x96, 0xb1, 0x6f, 0xd3, 0x4e, + 0x14, 0xc7, 0xe3, 0xa6, 0xa9, 0x94, 0x4b, 0x1a, 0xfd, 0xea, 0x1f, 0xa0, 0x24, 0x08, 0x3b, 0x62, + 0xea, 0x52, 0x5b, 0x6d, 0xa5, 0x4a, 0xac, 0xb1, 0x2a, 0x31, 0x30, 0xc0, 0xa1, 0x20, 0xc4, 0x80, + 0x65, 0x3b, 0xd7, 0xe4, 0x14, 0xfb, 0xce, 0xb2, 0xef, 0x0a, 0xf9, 0x0b, 0x58, 0x99, 0xf9, 0x67, + 0x10, 0x1b, 0x63, 0xc7, 0x4e, 0x16, 0x4a, 0x36, 0xff, 0x15, 0xe8, 0xde, 0x25, 0x34, 0x89, 0x0a, + 0x52, 0x55, 0x09, 0x96, 0x4c, 0xbe, 0xf7, 0xbe, 0xef, 0xfb, 0xee, 0xf2, 0x3e, 0xb1, 0x75, 0xa8, + 0x9b, 0xf2, 0x89, 0xc8, 0x78, 0x1c, 0xbb, 0x69, 0xc6, 0xf9, 0x85, 0x4b, 0x2e, 0x09, 0x13, 0x4e, + 0x9a, 0x71, 0xc1, 0xcd, 0xd6, 0x52, 0x73, 0x40, 0xeb, 0x5a, 0x11, 0xcf, 0x13, 0x9e, 0xbb, 0x61, + 0x90, 0x13, 0xf7, 0xf2, 0x38, 0x24, 0x22, 0x38, 0x76, 0x23, 0x4e, 0x99, 0xae, 0xef, 0x3e, 0x18, + 0xf1, 0x11, 0x87, 0xa5, 0xab, 0x56, 0x8b, 0xec, 0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55, 0xde, 0x39, 0x23, 0x2a, 0xc6, 0x32, 0x74, 0x22, 0x9e, 0xb8, 0xea, + 0x8c, 0x47, 0x8c, 0x88, 0x0f, 0x3c, 0x9b, 0xb8, 0xbf, 0x2e, 0x02, 0x1f, 0x57, 0xaf, 0x02, 0xe1, + 0x1e, 0xdc, 0x05, 0x4e, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xda, 0x61, 0x57, 0x8b, 0x08, + 0x00, 0x00, } func (m *EventClaimCreated) Marshal() (dAtA []byte, err error) { @@ -739,10 +740,10 @@ func (m *EventProofValidityChecked) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.Reason) > 0 { - i -= len(m.Reason) - copy(dAtA[i:], m.Reason) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Reason))) + if len(m.FailureReason) > 0 { + i -= len(m.FailureReason) + copy(dAtA[i:], m.FailureReason) + i = encodeVarintEvent(dAtA, i, uint64(len(m.FailureReason))) i-- dAtA[i] = 0x22 } @@ -910,7 +911,7 @@ func (m *EventProofValidityChecked) Size() (n int) { if m.ProofStatus != 0 { n += 1 + sovEvent(uint64(m.ProofStatus)) } - l = len(m.Reason) + l = len(m.FailureReason) if l > 0 { n += 1 + l + sovEvent(uint64(l)) } @@ -1816,7 +1817,7 @@ func (m *EventProofValidityChecked) Unmarshal(dAtA []byte) error { } case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reason", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FailureReason", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1844,7 +1845,7 @@ func (m *EventProofValidityChecked) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Reason = string(dAtA[iNdEx:postIndex]) + m.FailureReason = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex