Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DR and result fields #426

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions plugins/indexing/batching/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/hex"
"strconv"
"time"

// "cosmossdk.io/collections"
"cosmossdk.io/collections"
Expand Down Expand Up @@ -31,19 +32,24 @@ func ExtractUpdate(ctx *types.BlockContext, cdc codec.Codec, logger *log.Logger,
}

data := struct {
ID string `json:"result_id"`
DrID string `json:"dr_id"`
Version string `json:"version"`
BlockHeight string `json:"block_height"`
ExitCode uint32 `json:"exit_code"`
GasUsed string `json:"gas_used"`
Result []byte `json:"result"`
PaybackAddress string `json:"payback_address"`
SedaPayload string `json:"seda_payload"`
Consensus bool `json:"consensus"`
ID string `json:"result_id"`
DrID string `json:"dr_id"`
DrBlockHeight string `json:"dr_block_height"`
Version string `json:"version"`
BlockHeight string `json:"block_height"`
Timestamp time.Time `json:"timestamp"`
ExitCode uint32 `json:"exit_code"`
GasUsed string `json:"gas_used"`
Result []byte `json:"result"`
PaybackAddress string `json:"payback_address"`
SedaPayload string `json:"seda_payload"`
Consensus bool `json:"consensus"`
}{
ID: val.Id,
DrID: val.DrId,
ID: val.Id,
DrID: val.DrId,
DrBlockHeight: strconv.FormatUint(val.DrBlockHeight, 10),
//nolint:gosec // G115: When storing the timestamp we converted from int64 to uint64, so the reverse should be safe.
Timestamp: time.Unix(int64(val.BlockTimestamp), 0),
Version: val.Version,
BlockHeight: strconv.FormatUint(val.BlockHeight, 10),
ExitCode: val.ExitCode,
Expand Down
20 changes: 12 additions & 8 deletions proto/sedachain/batching/v1/batching.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,26 @@ message DataResult {
string id = 1 [ (gogoproto.jsontag) = "id" ];
// dr_id is the data request identifier.
string dr_id = 2 [ (gogoproto.jsontag) = "dr_id" ];
// dr_block_height is the height at which the data request was submitted.
uint64 dr_block_height = 3 [ (gogoproto.jsontag) = "dr_block_height" ];
// version is a semantic version string.
string version = 3 [ (gogoproto.jsontag) = "version" ];
string version = 4 [ (gogoproto.jsontag) = "version" ];
// block_height is the height at which the data request was tallied.
uint64 block_height = 4 [ (gogoproto.jsontag) = "block_height" ];
uint64 block_height = 5 [ (gogoproto.jsontag) = "block_height" ];
// block_timestamp is the unix timestamp in seconds of when the data request was tallied.
Thomasvdam marked this conversation as resolved.
Show resolved Hide resolved
uint64 block_timestamp = 6 [ (gogoproto.jsontag) = "block_timestamp" ];
// exit_code is the exit code of the tally wasm binary execution.
uint32 exit_code = 5 [ (gogoproto.jsontag) = "exit_code" ];
uint32 exit_code = 7 [ (gogoproto.jsontag) = "exit_code" ];
// gas_used is the gas used by the data request execution.
uint64 gas_used = 6 [ (gogoproto.jsontag) = "gas_used" ];
uint64 gas_used = 8 [ (gogoproto.jsontag) = "gas_used" ];
// result is the result of the tally wasm binary execution.
bytes result = 7 [ (gogoproto.jsontag) = "result" ];
bytes result = 9 [ (gogoproto.jsontag) = "result" ];
// payback_address is the payback address set by the relayer.
string payback_address = 8 [ (gogoproto.jsontag) = "payback_address" ];
string payback_address = 10 [ (gogoproto.jsontag) = "payback_address" ];
// seda_payload is the payload set by SEDA Protocol (e.g. OEV-enabled
// data requests)
string seda_payload = 9 [ (gogoproto.jsontag) = "seda_payload" ];
string seda_payload = 11 [ (gogoproto.jsontag) = "seda_payload" ];
// consensus indicates whether consensus was reached in the tally
// process.
bool consensus = 10 [ (gogoproto.jsontag) = "consensus" ];
bool consensus = 12 [ (gogoproto.jsontag) = "consensus" ];
}
52 changes: 31 additions & 21 deletions x/batching/keeper/endblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,128 +226,138 @@ type TestData struct {
const testDataJSON = `{
"results": [
{
"resultId": "0xbe65b686b9bd9a896762f4c6fef234290ec55e3ab609426c685c53d61287d336",
"resultId": "0xccf12276c43cc61e0f3c6ace3e66872eda5df5ec753525a7bddab6fa3407e927",
"version": "0.0.1",
"drId": "0x2e469f40cf0afb5b93641c75aaecb654f0c73fc2dd4fcc350150c4825d2fb36e",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0x99de4dde0fb83fa812b9b8c60b2cf9d47518e456b83bd42eb1c7d98bbb7ede58",
"resultId": "0xe5c2d374e25002439b4d332914c1b15f438fbb8edab3c37c0c0fff4ba6f661da",
"version": "0.0.1",
"drId": "0xa779f7061360e9fd128acb8686c393294db943848dc6c1e2248dd91fc79f3835",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0xcf9138035c2c57694000aa70218b2523eefe150257482b9af18d4633e7e8b97b",
"resultId": "0xbc769462ef60997285d262e404bf036b0d62ebd59df10470f3c0223d1deb18c0",
"version": "0.0.1",
"drId": "0xcedae320cef23e6b50baf01f722b53818fd1d738d796a57a785c71436237dd35",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0xc0b86bcf24a3e305b0319e45106b7851ee8e59f7e2d9793a886c16a8949ca898",
"resultId": "0xef5977dcf9789d3d51ec4741317187406636ae4f3fda398b561391d2a32ecbca",
"version": "0.0.1",
"drId": "0xd2e85a4f932ee01d3aec08c4fb0725425073914e11e32219a90d0fb190adcce3",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0x7d2731c2c215d7a90f8037e7ce7fb5dfb8699417fc3cda6a946fcc13761c8b77",
"resultId": "0xfb849492d85812dacb8c7a61555a642571674746253c6b36eec48c4937854198",
"version": "0.0.1",
"drId": "0xa11695dd090839580ee64a21412e8f0843255c149f5352311ab6960990e690be",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0xc6c8c01a175383783db75dd7199cbe74db15438880e5fe5e7e6dcbe9fbc96e4c",
"resultId": "0x7259f83b16565218632920cc2def23a9fa6411eb10ceca5a8c2231c30adf91c0",
"version": "0.0.1",
"drId": "0xa4a1baa9d463128792770c0aadfc7916362d9309e19d709729060a48eb3b4b13",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0x998c975ddc39a0185b02e544001f63eac401b01fe3737c4f9da4992bcb146bea",
"resultId": "0x49212d617b70d464f4c90b5ae16e89e5bc4ab57dba99a00246d4a230cdd80e4a",
"version": "0.0.1",
"drId": "0xe220988adad2c99912c5a4a7feb197e04a1a0396de7ca16b5e47dc1b6995b484",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0x57d66709949b25a61c29a914ca6b63680b95843f16c9e6f796ebb3ede2ca0f58",
"resultId": "0xfd9e8e35b1195457cb0fa4f0f451342821d51571eb2bd6a0edbce4f994e384f8",
"version": "0.0.1",
"drId": "0x2d9d50f861512a9f7041452eddfbff39f2553e1ebb5646d2eecf6733d7c8d2ce",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0xe3c54225c36fe4b1250fb806ef1cc5c13f291069941259a4c58664419c222528",
"resultId": "0x41ae733f44a6cd3c5446b9599b31c32a71fabe0d560f09929e4627b3d1ff8060",
"version": "0.0.1",
"drId": "0x3b8dfa0893f0a24ce3d600fad4ca16fd08ee257efea866145d000e65cf14f04a",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"resultId": "0xafb0ab28855671a35c30b99eab2fd1e2a71486bfc6fc625638fd31a2ac5f26ed",
"resultId": "0x6aef851aea422b9f23c9cc1eef4e3190f968c9dcf2515d0d203670c706007e9e",
"version": "0.0.1",
"drId": "0xf180cde27633a009ad05fe86b0ef69c7f2065c3fcf40b103710173829990ce87",
"consensus": true,
"exitCode": 0,
"result": "0x39bf027dd97f3bae0cf8cfb909695ec63313a9bd61ad52fc7f52cf565b141da8",
"blockHeight": 0,
"blockTimestamp": 0,
"gasUsed": 0,
"paybackAddress": "0x0000000000000000000000000000000000000000",
"sedaPayload": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"tree": {
"root": "0xf0fd6bcebfba525736179ce169ae7a219bf994857bc51546fb83661be3a61744",
"root": "0x561e1141ca38e99ad3b9d2d94744be7d6b307011b8dd35b8e08d97b4226ae32f",
"leaves": [
"0xae813aa6da400689d42228fb2f352734d0f66114bd1755446f1217456e22b4ad",
"0x32047ba1e49f5435144d16d581c11851989a357cdf2924f53cb4322c5c92f680",
Expand Down Expand Up @@ -426,16 +436,16 @@ const testDataJSON = `{
"validatorsTree": {
"root": "0x2c5073e9c4308e65eb22152f62611c6f604d6b427c6514bbd1effaf282d9614a",
"leaves": [
"0x38519bc19a6c21b2e4d5c07f5c317a04907d74428e84ce53d7e31660363697e3",
"0xefaaa7508118895a0d04b782da3824d32e8068bc149eb9cb64d5035bfdc23d75",
"0x08acd70e8df30e046db9b1f428e801b98426493443630c1a10ed41ca831b59dc",
"0xb83b5ecaf184b6525c995e98885c3c26105981d368fba6a32f118d963a8b2f0e",
"0x5ea122e40dd0c50ea173ed35af483f3391d910051d0b81b5764962bc7259c75a",
"0x1b36b415df57e691bc923f10a6dc481caf1b31a77f3514c443e78e07a9692e70",
"0x15c3bea022ed633d5aeabfeba41955d19f23ad533c95d50b121b1cb0c585c2f7",
"0xe2f6ad28acf622aad072b4af09ff3e4588c312461fd9f34f87a30398c4874c6f",
"0x66931389acd9b85bf84eb1b4b391e0100affed572a4b5695bcbb07c1655fbfe7",
"0x49f4e02c70dc0cff353603c5af12911e3fe408e8263005cbe2877e2677789469"
"0xfd9e8e35b1195457cb0fa4f0f451342821d51571eb2bd6a0edbce4f994e384f8",
"0xccf12276c43cc61e0f3c6ace3e66872eda5df5ec753525a7bddab6fa3407e927",
"0x41ae733f44a6cd3c5446b9599b31c32a71fabe0d560f09929e4627b3d1ff8060",
"0xfb849492d85812dacb8c7a61555a642571674746253c6b36eec48c4937854198",
"0x7259f83b16565218632920cc2def23a9fa6411eb10ceca5a8c2231c30adf91c0",
"0xe5c2d374e25002439b4d332914c1b15f438fbb8edab3c37c0c0fff4ba6f661da",
"0xbc769462ef60997285d262e404bf036b0d62ebd59df10470f3c0223d1deb18c0",
"0xef5977dcf9789d3d51ec4741317187406636ae4f3fda398b561391d2a32ecbca",
"0x49212d617b70d464f4c90b5ae16e89e5bc4ab57dba99a00246d4a230cdd80e4a",
"0x6aef851aea422b9f23c9cc1eef4e3190f968c9dcf2515d0d203670c706007e9e"
]
}
}`
Expand Down
Loading
Loading