Skip to content

Commit

Permalink
Algod: rename some API operations for clarity (#4376)
Browse files Browse the repository at this point in the history
* Rename GetProof to GetTransactionProof to avoid ambiguity
* Rename GetProofForLightBlockHeader to GetLightBlockHeaderProof
  • Loading branch information
Aharonee authored Aug 9, 2022
1 parent 2d51070 commit 42f449f
Show file tree
Hide file tree
Showing 11 changed files with 612 additions and 504 deletions.
53 changes: 43 additions & 10 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@
"schemes": [
"http"
],
"summary": "Get a Merkle proof for a transaction in a block.",
"operationId": "GetProof",
"summary": "Get a proof for a transaction in a block.",
"operationId": "GetTransactionProof",
"parameters": [
{
"type": "integer",
Expand Down Expand Up @@ -566,7 +566,7 @@
],
"responses": {
"200": {
"$ref": "#/responses/ProofResponse"
"$ref": "#/responses/TransactionProofResponse"
},
"400": {
"description": "Malformed round number or transaction ID",
Expand All @@ -587,7 +587,7 @@
}
},
"500": {
"description": "Internal error, including protocol not supporting Merkle proofs.",
"description": "Internal error, including protocol not supporting proofs.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
Expand Down Expand Up @@ -1317,7 +1317,7 @@
"http"
],
"summary": "Gets a proof for a given light block header inside a state proof commitment",
"operationId": "GetProofForLightBlockHeader",
"operationId": "GetLightBlockHeaderProof",
"parameters": [
{
"type": "integer",
Expand Down Expand Up @@ -2683,9 +2683,42 @@
],
"properties": {
"Message": {
"description": "The encoded message.",
"type": "string",
"format": "byte"
"description": "Represents the message that the state proofs are attesting to.",
"type": "object",
"required": [
"BlockHeadersCommitment",
"VotersCommitment",
"LnProvenWeight",
"FirstAttestedRound",
"LastAttestedRound"
],
"properties": {
"BlockHeadersCommitment": {
"description": "The vector commitment root on all light block headers within a state proof interval.",
"type": "string",
"format": "byte"
},
"VotersCommitment": {
"description": "The vector commitment root of the top N accounts to sign the next StateProof.",
"type": "string",
"format": "byte"
},
"LnProvenWeight": {
"description": "An integer value representing the natural log of the proven weight with 16 bits of precision. This value would be used to verify the next state proof.",
"type": "integer",
"x-algorand-format": "uint64"
},
"FirstAttestedRound": {
"description": "The first round the message attests to.",
"type": "integer",
"x-algorand-format": "uint64"
},
"LastAttestedRound": {
"description": "The last round the message attests to.",
"type": "integer",
"x-algorand-format": "uint64"
}
}
},
"StateProof": {
"description": "The encoded StateProof for the message.",
Expand Down Expand Up @@ -2976,7 +3009,7 @@
}
}
},
"ProofResponse": {
"TransactionProofResponse": {
"description": "Proof of transaction in a block.",
"schema": {
"type": "object",
Expand All @@ -2989,7 +3022,7 @@
],
"properties": {
"proof": {
"description": "Merkle proof of transaction membership.",
"description": "Proof of transaction membership.",
"type": "string",
"format": "byte"
},
Expand Down
146 changes: 90 additions & 56 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,53 +630,6 @@
},
"description": "Transaction ID of the submission."
},
"ProofResponse": {
"content": {
"application/json": {
"schema": {
"properties": {
"hashtype": {
"description": "The type of hash function used to create the proof, must be one of: \n* sha512_256 \n* sha256",
"enum": [
"sha512_256",
"sha256"
],
"type": "string"
},
"idx": {
"description": "Index of the transaction in the block's payset.",
"type": "integer"
},
"proof": {
"description": "Merkle proof of transaction membership.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"stibhash": {
"description": "Hash of SignedTxnInBlock for verifying proof.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"treedepth": {
"description": "Represents the depth of the tree that is being proven, i.e. the number of edges from a leaf to the root.",
"type": "integer"
}
},
"required": [
"hashtype",
"idx",
"proof",
"stibhash",
"treedepth"
],
"type": "object"
}
}
},
"description": "Proof of transaction in a block."
},
"StateProofResponse": {
"content": {
"application/json": {
Expand Down Expand Up @@ -765,6 +718,53 @@
},
"description": "TransactionParams contains the parameters that help a client construct a new transaction."
},
"TransactionProofResponse": {
"content": {
"application/json": {
"schema": {
"properties": {
"hashtype": {
"description": "The type of hash function used to create the proof, must be one of: \n* sha512_256 \n* sha256",
"enum": [
"sha512_256",
"sha256"
],
"type": "string"
},
"idx": {
"description": "Index of the transaction in the block's payset.",
"type": "integer"
},
"proof": {
"description": "Proof of transaction membership.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"stibhash": {
"description": "Hash of SignedTxnInBlock for verifying proof.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"treedepth": {
"description": "Represents the depth of the tree that is being proven, i.e. the number of edges from a leaf to the root.",
"type": "integer"
}
},
"required": [
"hashtype",
"idx",
"proof",
"stibhash",
"treedepth"
],
"type": "object"
}
}
},
"description": "Proof of transaction in a block."
},
"VersionsResponse": {
"content": {
"application/json": {
Expand Down Expand Up @@ -1623,10 +1623,44 @@
"description": "Represents a state proof and its corresponding message",
"properties": {
"Message": {
"description": "The encoded message.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
"description": "Represents the message that the state proofs are attesting to.",
"properties": {
"BlockHeadersCommitment": {
"description": "The vector commitment root on all light block headers within a state proof interval.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"FirstAttestedRound": {
"description": "The first round the message attests to.",
"type": "integer",
"x-algorand-format": "uint64"
},
"LastAttestedRound": {
"description": "The last round the message attests to.",
"type": "integer",
"x-algorand-format": "uint64"
},
"LnProvenWeight": {
"description": "An integer value representing the natural log of the proven weight with 16 bits of precision. This value would be used to verify the next state proof.",
"type": "integer",
"x-algorand-format": "uint64"
},
"VotersCommitment": {
"description": "The vector commitment root of the top N accounts to sign the next StateProof.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
}
},
"required": [
"BlockHeadersCommitment",
"FirstAttestedRound",
"LastAttestedRound",
"LnProvenWeight",
"VotersCommitment"
],
"type": "object"
},
"StateProof": {
"description": "The encoded StateProof for the message.",
Expand Down Expand Up @@ -2666,7 +2700,7 @@
},
"/v2/blocks/{round}/lightheader/proof": {
"get": {
"operationId": "GetProofForLightBlockHeader",
"operationId": "GetLightBlockHeaderProof",
"parameters": [
{
"description": "The round to which the light block header belongs.",
Expand Down Expand Up @@ -2740,7 +2774,7 @@
},
"/v2/blocks/{round}/transactions/{txid}/proof": {
"get": {
"operationId": "GetProof",
"operationId": "GetTransactionProof",
"parameters": [
{
"description": "The round in which the transaction appears.",
Expand Down Expand Up @@ -2805,7 +2839,7 @@
"type": "integer"
},
"proof": {
"description": "Merkle proof of transaction membership.",
"description": "Proof of transaction membership.",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
Expand Down Expand Up @@ -2872,14 +2906,14 @@
}
}
},
"description": "Internal error, including protocol not supporting Merkle proofs."
"description": "Internal error, including protocol not supporting proofs."
},
"default": {
"content": {},
"description": "Unknown error"
}
},
"summary": "Get a Merkle proof for a transaction in a block."
"summary": "Get a proof for a transaction in a block."
}
},
"/v2/catchup/{catchpoint}": {
Expand Down
2 changes: 1 addition & 1 deletion daemon/algod/api/client/restClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (client RestClient) LightBlockHeaderProof(round uint64) (response generated
}

// TransactionProof gets a Merkle proof for a transaction in a block.
func (client RestClient) TransactionProof(txid string, round uint64, hashType crypto.HashType) (response generatedV2.ProofResponse, err error) {
func (client RestClient) TransactionProof(txid string, round uint64, hashType crypto.HashType) (response generatedV2.TransactionProofResponse, err error) {
txid = stripTransaction(txid)
err = client.get(&response, fmt.Sprintf("/v2/blocks/%d/transactions/%s/proof", round, txid), proofParams{HashType: hashType.String()})
return
Expand Down
Loading

0 comments on commit 42f449f

Please sign in to comment.