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

chore: return the oracle info struct in kormir-server #27

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

rorp
Copy link
Contributor

@rorp rorp commented Jan 11, 2025

Fixes #24

Sample output of /create-enum and /announcement

{
  "announcementSignature": "affab11446617018efddde0f4e6ab0cf0cb8ddd3dc19be723edcb57ec6e46926cec7c7c05ab9de5999ca0d484d42e314f1b1294d5025fa2ca07c20b5442e88bb",
  "oraclePublicKey": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
  "oracleEvent": {
    "oracleNonces": [
      "c2d0b9e9342693770d738cfcd069bc6339f030be21935e3c85d57ec3e08fc0d4"
    ],
    "eventMaturityEpoch": 1738884967,
    "eventDescriptor": {
      "enumEvent": {
        "outcomes": [
          "a",
          "b"
        ]
      }
    },
    "eventId": "enum"
  }
}

Sample output of /sign-enum and /attestation

{
  "eventId": "enum",
  "oraclePublicKey": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
  "signatures": [
    "c2d0b9e9342693770d738cfcd069bc6339f030be21935e3c85d57ec3e08fc0d413b01af856909cdc1231d1dc384c77a16438b8f970c696809ad0cc895c80941e"
  ],
  "outcomes": [
    "b"
  ]
}

Sample output of /create-numeric and /announcement

{
  "announcementSignature": "1459c2d6c0da571ba0a69265e5c4175bfca8221a05184c7ae63d65c54c3b77ced2dd603a66ad01aff14e074c68b7a147944ad7ec5ed847b1dac63f319c3749b2",
  "oraclePublicKey": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
  "oracleEvent": {
    "oracleNonces": [
      "a6a1f4ba811a2f8616fa32882d5903d56b076bf16afb7670ac958e287cfcf12b",
      "07e3f6c6f040b5cd304bed6603284295c0716de64e8442012ba3851c1665e7f6",
      "75e9e385e8151c5c81f6c14082a995dc9e24e1a75121a1ff3d06b31fb1dc824c",
      "71244aa64a6a542d6311dd4fe21dd44986d13c6c7b2e35818024ac3b369615ee",
      "123282ff00304ee83f6ad1510d54926e8976699a1f44f6ab80d81a5caf97c714",
      "21fa5029d9e8febb956e21a214494cde47584f71f23b2d131db598317550687d",
      "916ec8667200ec63edde56b0d761d005543848d287f0f346af2c59f6d3b8ae5a",
      "658ed1bdae800b8c257ce0d4aa0a4f87b8c643b55165235c917d3241b21040f6",
      "b6911c0b3eaf93b1f1a4c7d7a8bbb6d573b9d38b3e152084d1b1f69ff84eb3d7",
      "b4ee33f48cc2247f2b83747a177f72820e792d4ace8a0b6a30c029d6a0cd0c3e",
      "52cca6d6f8220747a643517e4d9a9fa5cf52251edd1c8ebb29aded230ce8e557",
      "ab1647c20e5977455eb76fc0cdba2493f29eebd9d0dea78997f6041f2cb9c619",
      "cd8d508a6a71c21d361f2ff02985bcbcef302df92b3b29f1a56d04817fc4f403",
      "fdd3fe05a982983a7798a1111f5179a6e9d0eec03153b448c4d39a4b86648187",
      "afbf40b41aac957511b4fa0a7fdad7c0a49dd7d4e06287f789b92a689d1337ef",
      "dbb1f9170028875599339a080a555b9de6fafdab5b2827daf58bd0e422d81473",
      "b0b895c684a59fb4482f6902052571bb33941ec132a2839ad45ca1077b9f5998",
      "cff164d7b78b7924aea33fc9fd74549ea4f18a40731210f5dd7b8f27081c45f7",
      "2b2cff0fd3f1186a592fd3e1a5f0a72927fd7d79e055efccc1edad7eb8cbccad"
    ],
    "eventMaturityEpoch": 1738880124,
    "eventDescriptor": {
      "digitDecompositionEvent": {
        "base": 2,
        "isSigned": true,
        "unit": "m/s",
        "precision": 0,
        "nbDigits": 18
      }
    },
    "eventId": "numeric"
  }
}

Sample output of /sign-numeric and /attestation

{
  "eventId": "numeric",
  "oraclePublicKey": "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
  "signatures": [
    "a6a1f4ba811a2f8616fa32882d5903d56b076bf16afb7670ac958e287cfcf12b03301753f2efff1627566b6d56f504cc394cc852aef8501f7b011e910eba57f8",
    "07e3f6c6f040b5cd304bed6603284295c0716de64e8442012ba3851c1665e7f67ca7e3d7f4f29e559b6544617f6d856766633513806654956e4ad38591ab0c32",
    "75e9e385e8151c5c81f6c14082a995dc9e24e1a75121a1ff3d06b31fb1dc824c0d972980cb53a764daef0d1cd24efe7f807fdfeea47c08dd573728b98283e4ca",
    "71244aa64a6a542d6311dd4fe21dd44986d13c6c7b2e35818024ac3b369615ee7637d0e96c39b5831640a359c78d2daf2f600a5117ba46e02c979c1c5d712eca",
    "123282ff00304ee83f6ad1510d54926e8976699a1f44f6ab80d81a5caf97c714dd1bde553256cdac2616be2f1c7d916978d814356fc7779e40415571386b4e33",
    "21fa5029d9e8febb956e21a214494cde47584f71f23b2d131db598317550687dd17224d6ed64e3903a37a20de03c91d4a42b4173adf59052f67a079746150b22",
    "916ec8667200ec63edde56b0d761d005543848d287f0f346af2c59f6d3b8ae5afeb455c4bc3fe3e05690bb4080ab54ae9614990d046df890a10a5a6e53449e0b",
    "658ed1bdae800b8c257ce0d4aa0a4f87b8c643b55165235c917d3241b21040f6d89703f0c3b716cde6b965fb3ea1d0be542000866a76295afdd842e9dc2b96da",
    "b6911c0b3eaf93b1f1a4c7d7a8bbb6d573b9d38b3e152084d1b1f69ff84eb3d75541193cfedf474a312710c6a2dd485deb78e5bc23646b0609dba75c8d38a912",
    "b4ee33f48cc2247f2b83747a177f72820e792d4ace8a0b6a30c029d6a0cd0c3e1c0826260eea6dda25d53658e5694271bf7baa23807b30ed73761c165168ed10",
    "52cca6d6f8220747a643517e4d9a9fa5cf52251edd1c8ebb29aded230ce8e557e18ae8c0e3959513abfc528dfc234c904436771d7e09aeefce9c5b014c097a60",
    "ab1647c20e5977455eb76fc0cdba2493f29eebd9d0dea78997f6041f2cb9c6198888b9f0079b88fb665b9fe3e34ede6bfbbe2661c663a1827abaa1c4832ac821",
    "cd8d508a6a71c21d361f2ff02985bcbcef302df92b3b29f1a56d04817fc4f40317ef877f8a5d62ef6ebb527335738b283812aafa40947e976d0cfa1ebfedf177",
    "fdd3fe05a982983a7798a1111f5179a6e9d0eec03153b448c4d39a4b866481871ec28780922c0a95757299041973b252b430eb6e507d56a6994cbd849e8b23f8",
    "afbf40b41aac957511b4fa0a7fdad7c0a49dd7d4e06287f789b92a689d1337ef6fd40ba0c072768c27615b03b3ed73b3fb0dc1584a8e29383cd15d6cb87530f5",
    "dbb1f9170028875599339a080a555b9de6fafdab5b2827daf58bd0e422d81473d9d2faf72bb087ad69e1667446eb4c079796d93848a968f109efa7fa1c3446e5",
    "b0b895c684a59fb4482f6902052571bb33941ec132a2839ad45ca1077b9f5998093164abb7441210ee76fe2ebf25cc49056d3d3871b049ff2f0a7a2eb9600845",
    "cff164d7b78b7924aea33fc9fd74549ea4f18a40731210f5dd7b8f27081c45f76497ccb3dccbfdf152b143dfd0cd90200bf4a6d45e9f401a7e2ad1a4d86aaf76",
    "2b2cff0fd3f1186a592fd3e1a5f0a72927fd7d79e055efccc1edad7eb8cbccadaffd95ae1f98a8e2267d598a28e8105be9501b698a35d649d8f81ea5853923e9"
  ],
  "outcomes": [
    "-",
    "0",
    "1",
    "1",
    "0",
    "0",
    "0",
    "0",
    "1",
    "1",
    "0",
    "1",
    "0",
    "1",
    "0",
    "0",
    "0",
    "0",
    "0"
  ]
}

@rorp rorp force-pushed the chore/return_oracle_info branch 2 times, most recently from 83eed80 to a54cc26 Compare January 12, 2025 19:55
}

Ok(event.attestation().unwrap())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should bubble up the error here instead of unwrap()

serde_json::to_string(ann).unwrap()
}

pub fn att_as_json(ann: &OracleAttestation) -> String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Rename to att or attestation

}
}

pub fn ann_as_json(ann: &OracleAnnouncement) -> String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we want to have these functions that unwrap. Even though the ann & att are validated in kormir, I still don't like an unwrap especially when just used for logging.

Since they are just for logging, should we just print the event id & outcome for attestations?

Json(body): Json<crate::routes::CreateNumericEvent>,
) -> Result<Json<String>, (StatusCode, String)> {
Json(body): Json<CreateNumericEventRequest>,
) -> Result<Json<OracleAnnouncement>, (StatusCode, String)> {
if body.num_digits.is_some() && body.num_digits.unwrap() == 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be unwrap_or(0) so that the route does not panic?

@@ -34,30 +34,82 @@ pub async fn list_events(
"Failed to list events".to_string(),
)
})?;
match Format::from_query(&params) {
Err(_) => Err((StatusCode::BAD_REQUEST, "Invalid format".into())),
Ok(format) => match format {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: return an error here of Result<Value, Error> to properly handle panic in the format match

@rorp rorp force-pushed the chore/return_oracle_info branch from a54cc26 to f66fdeb Compare January 17, 2025 03:35
@rorp rorp requested a review from bennyhodl January 17, 2025 03:35
@rorp rorp force-pushed the chore/return_oracle_info branch from f66fdeb to bfd73c5 Compare January 17, 2025 03:54
@rorp rorp force-pushed the chore/return_oracle_info branch from bfd73c5 to 2849721 Compare January 17, 2025 04:01
Copy link
Owner

@bennyhodl bennyhodl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK, LGTM

I added a JSON pubkey response as well. Thank you!

@bennyhodl bennyhodl merged commit 971ca35 into bennyhodl:master Jan 17, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: Return the OracleInfo struct in kormir-server
2 participants