Skip to content

Commit 3c3384d

Browse files
committed
Enhanced event and claim processing due to pokt-network/poktroll#1673 pr.
- Refactored claim attribute handling for streamlined processing and improved data extraction. - Added improved support for managing new schema fields such as `sessionEndBlockHeight`, `serviceId`, `proofValidationStatus`, and more. - Optimized `EventClaimSettled` and `EventSupplierSlashed` mapping logic by introducing better handling for missing or optional attributes. - Updated protobuf definitions to align with new requirements and added missing fields to several event messages.
1 parent caabe5b commit 3c3384d

File tree

12 files changed

+1698
-309
lines changed

12 files changed

+1698
-309
lines changed

proto/pocket/proof/event.proto

Lines changed: 135 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,193 @@ package pocket.proof;
44
option go_package = "github.com/pokt-network/poktroll/x/proof/types";
55
option (gogoproto.stable_marshaler_all) = true;
66

7+
import "cosmos_proto/cosmos.proto";
78
import "gogoproto/gogo.proto";
89
import "pocket/proof/types.proto";
910

1011
message EventClaimCreated {
11-
// Next index: 8
12-
reserved 6; // cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
12+
// Next index: 13
13+
14+
// pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
15+
// cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
16+
reserved 1, 6;
1317

14-
pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
1518
uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"];
1619
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
1720
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
1821
string claimed_upokt = 7 [(gogoproto.jsontag) = "claimed_upokt"];
22+
23+
// The Service ID to which the claim corresponds.
24+
string service_id = 8;
25+
26+
// The address of the application which participated in the claimed session.
27+
string application_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
28+
29+
// The end block height of the session to which the claim corresponds.
30+
int64 session_end_block_height = 10;
31+
32+
// The validation status of the claim.
33+
// DEV_NOTE: This field uses the integer representation of the ClaimProofStatus
34+
// enum to minimize onchain disk utilization. This is necessary because event
35+
// data is not always protobuf-encoded in the various places and formats that it
36+
// appears in onchain leveldb databases.
37+
// Enum values:
38+
// PENDING_VALIDATION = 0;
39+
// VALIDATED = 1;
40+
// INVALID = 2;
41+
int32 claim_proof_status_int = 11;
42+
43+
// The operator address of the supplier which submitted the claim.
44+
string supplier_operator_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
1945
}
2046

2147
// TODO_TEST: Add coverage for claim updates.
2248
message EventClaimUpdated {
23-
// Next index: 8
49+
// Next index: 13
2450

51+
// pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
2552
// cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
26-
reserved 6;
53+
reserved 1, 6;
2754

28-
pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
2955
uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"];
3056
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
3157
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
3258
string claimed_upokt = 7 [(gogoproto.jsontag) = "claimed_upokt"];
59+
60+
// The Service ID to which the claim corresponds.
61+
string service_id = 8;
62+
63+
// The address of the application which participated in the claimed session.
64+
string application_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
65+
66+
// The end block height of the session to which the claim corresponds.
67+
int64 session_end_block_height = 10;
68+
69+
// The validation status of the claim.
70+
// DEV_NOTE: This field uses the integer representation of the ClaimProofStatus
71+
// enum to minimize onchain disk utilization. This is necessary because event
72+
// data is not always protobuf-encoded in the various places and formats that it
73+
// appears in onchain leveldb databases.
74+
// Enum values:
75+
// PENDING_VALIDATION = 0;
76+
// VALIDATED = 1;
77+
// INVALID = 2;
78+
int32 claim_proof_status_int = 11;
79+
80+
// The operator address of the supplier which updated the claim.
81+
string supplier_operator_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
3382
}
3483

3584
message EventProofSubmitted {
36-
// Next index: 8
85+
// Next index: 13
3786

87+
// pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
3888
// cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
39-
reserved 6;
89+
reserved 1, 6;
4090

41-
pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
4291
uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"];
4392
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
4493
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
4594
string claimed_upokt = 7 [(gogoproto.jsontag) = "claimed_upokt"];
95+
96+
// The Service ID to which the claim corresponds.
97+
string service_id = 8;
98+
99+
// The address of the application which participated in the claimed session.
100+
string application_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
101+
102+
// The end block height of the session to which the claim corresponds.
103+
int64 session_end_block_height = 10;
104+
105+
// The validation status of the claim.
106+
// DEV_NOTE: This field uses the integer representation of the ClaimProofStatus
107+
// enum to minimize onchain disk utilization. This is necessary because event
108+
// data is not always protobuf-encoded in the various places and formats that it
109+
// appears in onchain leveldb databases.
110+
// Enum values:
111+
// PENDING_VALIDATION = 0;
112+
// VALIDATED = 1;
113+
// INVALID = 2;
114+
int32 claim_proof_status_int = 11;
115+
116+
// The operator address of the supplier which submitted the proof.
117+
string supplier_operator_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
46118
}
47119

48120
// TODO_TEST: Add coverage for proof updates.
49121
message EventProofUpdated {
50-
// Next index: 8
122+
// Next index: 13
51123

124+
// pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
52125
// cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
53-
reserved 6;
126+
reserved 1, 6;
54127

55-
pocket.proof.Claim claim = 1 [(gogoproto.jsontag) = "claim"];
56128
uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"];
57129
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
58130
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
59131
string claimed_upokt = 7 [(gogoproto.jsontag) = "claimed_upokt"];
132+
133+
// The Service ID to which the claim corresponds.
134+
string service_id = 8;
135+
136+
// The address of the application which participated in the claimed session.
137+
string application_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
138+
139+
// The end block height of the session to which the claim corresponds.
140+
int64 session_end_block_height = 10;
141+
142+
// The validation status of the claim.
143+
// DEV_NOTE: This field uses the integer representation of the ClaimProofStatus
144+
// enum to minimize onchain disk utilization. This is necessary because event
145+
// data is not always protobuf-encoded in the various places and formats that it
146+
// appears in onchain leveldb databases.
147+
// Enum values:
148+
// PENDING_VALIDATION = 0;
149+
// VALIDATED = 1;
150+
// INVALID = 2;
151+
int32 claim_proof_status_int = 11;
152+
153+
// The operator address of the supplier which updated the proof.
154+
string supplier_operator_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
60155
}
61156

62157
// Event emitted after a proof has been checked for validity in the proof module's
63158
// EndBlocker.
64159
message EventProofValidityChecked {
65-
// Next index: 6
160+
// Next index: 12
66161

67162
// The following fields were removed to minimize block size.
68163
// See https://github.com/pokt-network/poktroll/issues/1497.
69-
reserved 1; // pocket.proof.Proof proof = 1 [(gogoproto.jsontag) = "proof"];
70-
reserved 3; // pocket.proof.ClaimProofStatus proof_status = 3 [(gogoproto.jsontag) = "proof_status"];
164+
// pocket.proof.Proof proof = 1 [(gogoproto.jsontag) = "proof"];
165+
// pocket.proof.ClaimProofStatus proof_status = 3 [(gogoproto.jsontag) = "proof_status"];
166+
// pocket.proof.Claim claim = 5 [(gogoproto.jsontag) = "claim"];
167+
reserved 1, 3, 5;
71168

72-
pocket.proof.Claim claim = 5 [(gogoproto.jsontag) = "claim"];
73169
uint64 block_height = 2 [(gogoproto.jsontag) = "block_height"];
74170
// reason is the string representation of the error that led to the proof being
75171
// marked as invalid (e.g. "invalid closest merkle proof", "invalid relay request signature")
76172
string failure_reason = 4 [(gogoproto.jsontag) = "failure_reason"];
173+
174+
// The Service ID to which the claim corresponds.
175+
string service_id = 8;
176+
177+
// The address of the application which participated in the claimed session.
178+
string application_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
179+
180+
// The end block height of the session to which the claim corresponds.
181+
int64 session_end_block_height = 10;
182+
183+
// The validation status of the claim.
184+
// DEV_NOTE: This field uses the integer representation of the ClaimProofStatus
185+
// enum to minimize onchain disk utilization. This is necessary because event
186+
// data is not always protobuf-encoded in the various places and formats that it
187+
// appears in onchain leveldb databases.
188+
// Enum values:
189+
// PENDING_VALIDATION = 0;
190+
// VALIDATED = 1;
191+
// INVALID = 2;
192+
int32 claim_proof_status_int = 11;
193+
194+
// The operator address of the supplier whose proof was checked.
195+
string supplier_operator_address = 12 [(cosmos_proto.scalar) = "cosmos.AddressString"];
77196
}

proto/pocket/supplier/event.proto

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ enum SupplierUnbondingReason {
1919

2020
// EventSupplierStaked is emitted when a supplier stake message is committed onchain.
2121
message EventSupplierStaked {
22-
pocket.shared.Supplier supplier = 1 [(gogoproto.jsontag) = "supplier"];
22+
// Next index: 4
23+
24+
// pocket.shared.Supplier supplier = 1 [(gogoproto.jsontag) = "supplier"];
25+
reserved 1;
26+
2327
// The session end height of the last session in which the supplier was staked.
2428
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
29+
30+
string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
2531
}
2632

2733
// EventSupplierUnbondingBegin is emitted when an application unstake message
@@ -61,10 +67,16 @@ message EventSupplierUnbondingCanceled {
6167
// EventSupplierServiceConfigActivated is emitted when a supplier service configuration
6268
// becomes effective at a specific block height.
6369
message EventSupplierServiceConfigActivated {
64-
// supplier contains the complete updated supplier information including the
65-
// active service configurations in supplier.Services.
66-
pocket.shared.Supplier supplier = 1 [(gogoproto.jsontag) = "supplier"];
70+
// Next index: 5
71+
72+
// pocket.shared.Supplier supplier = 1 [(gogoproto.jsontag) = "supplier"];
73+
reserved 1;
74+
6775
// activation_height indicates the block height at which the new service
6876
// configurations became active.
6977
int64 activation_height = 2 [(gogoproto.jsontag) = "activation_height"];
78+
79+
string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
80+
81+
string service_id = 4; // The Service ID for which the supplier is configured
7082
}

0 commit comments

Comments
 (0)