Skip to content

Commit

Permalink
2599 oxford supports attestation (#2666)
Browse files Browse the repository at this point in the history
* refactor: updated rpc types to accomdate both attestation and endorement

* fix: support both attestation and endrosement except localForger work with only attesation

BREAKING CHANGE: localforger only forge and parse atteation now

* refactor: added missing staker properties in OperationMetadataBalanceUpdates
  • Loading branch information
hui-an-yang authored Sep 26, 2023
1 parent d631b4e commit dda9fe0
Show file tree
Hide file tree
Showing 26 changed files with 687 additions and 216 deletions.
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Bjorsell",
"Boissonneault",
"camelcase",
"cooldown",
"crios",
"dailynet",
"delphinet",
Expand Down Expand Up @@ -53,7 +54,9 @@
"octez",
"oxfordnet",
"oxheadalpha",
"preattestation",
"precommit",
"preendorsement",
"println",
"Protofire",
"Proxford",
Expand Down
2 changes: 1 addition & 1 deletion docs/consensus_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Consensus Keys
author: Davis Sawali & Hui-An Yang
---

The "consensus key" feature allows bakers to use a different key, called the consensus key. It will allow for baking and signing consensus operations (i.e. pre-endorsements and endorsements). For more detailed information on consensus keys, refer to [this documentation](https://tezos.gitlab.io/protocols/015_lima.html?highlight=update%20consensus%20key#consensus-key)
The "consensus key" feature allows bakers to use a different key, called the consensus key. It will allow for baking and signing consensus operations (i.e. pre-endorsements/pre-attestation and endorsements/attestation). For more detailed information on consensus keys, refer to [this documentation](https://tezos.gitlab.io/protocols/015_lima.html?highlight=update%20consensus%20key#consensus-key)

Starting from Lima protocol, these 2 new operations will be available:

Expand Down
154 changes: 93 additions & 61 deletions docs/rpc_nodes_integration_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,109 @@ author: Roxane Letourneau

## Steps to run the tests

1. The RPC nodes' integration tests are disabled by default.
1. The RPC nodes' integration tests are disabled by default.
Remove `./rpc-nodes.spec.ts` from `"testPathIgnorePatterns"` in the package.json.

**nairobinet**: `npm run test:nairobinet rpc-nodes.spec.ts`
**nairobinet**: `npm run test:oxfordnet rpc-nodes.spec.ts`

**When all endpoints are accessible for a node, you will obtain:**

```
Test calling all methods from RPC node: https://a-node
✓ Get the head block hash (1376 ms)
✓ List the ancestors of the head block (1010 ms)
✓ Access the balance of an address (1024 ms)
✓ Access the data of a contract (1022 ms)
✓ Access the code and data of a contract (1096 ms)
✓ Access the complete status of a contract (1057 ms)
✓ Access the manager key of a contract (1023 ms)
✓ Access the delegate of a contract (1023 ms)
✓ Access the value associated with a key in a big map (3927 ms)
✓ Fetches information about a delegate from RPC (1590 ms)
✓ Get all constants from RPC (938 ms)
✓ Get all the information about a block (1021 ms)
✓ Get the whole block header (1125 ms)
✓ Get all the metadata associated to the block (918 ms)
✓ Retrieves the list of delegates allowed to bake a block (912 ms)
✓ Retrieves the list of delegates allowed to endorse a block (971 ms)
✓ Get ballots casted so far during a voting period (1059 ms)
✓ Get sum of ballots casted so far during a voting period (904 ms)
✓ Get current period kind (907 ms)
✓ Get current proposal under evaluation (986 ms)
✓ Get current expected quorum (920 ms)
✓ List of delegates with their voting weight, in number of rolls (923 ms)
✓ List of proposals with number of supporters (1023 ms)
✓ Forge an operation returning the unsigned bytes (1026 ms)
✓ Inject an operation in node and broadcast it (1127 ms)
✓ Simulate the validation of an operation (1022 ms)
✓ Get the list of entrypoints of the contract (1023 ms)
✓ Get chain ID (896 ms)
✓ Run an operation without signature checks (948 ms)
✓ Verify that rpcClient.getBlockHash returns the head block hash (64 ms)
✓ Verify that rpcClient.getLiveBlocks returns the ancestors of the head block (85 ms)
✓ Verify that rpcClient.getBalance returns the spendable balance of knownBaker, excluding frozen bonds (74 ms)
✓ Verify that rpcClient.getStorage returns the storage data of knowContract (67 ms)
✓ Verify that rpcClient.getScript returns the script data of knownContract (88 ms)
✓ Verify that rpcClient.getNormalizedScript returns the script of the knownContract and normalize it using the requested unparsing mode (56 ms)
✓ Verify that rpcClient.getContract returns the complete status of knownContract (66 ms)
✓ Verify that rpcClient.getManagerKey returns the manager key of the knownBaker (76 ms)
✓ Verify that rpcClient.getDelegate returns the delegate of the knownBaker (54 ms)
✓ Verify that rpcClient.getBigMapExpr(deprecated) returns the value associated with encoded expression in a big map (330 ms)
✓ Verify that rpcClient.getDelegates returns everything about a delegate (71 ms)
✓ verify that rpcClient.getVotingInfo returns the knownBaker voting power found in the listings of the current voting period (57 ms)
✓ Verify that rpcClient.getConstants returns all constants from RPC (65 ms)
✓ Verify that rpcClient.getBlock returns all the information about a block (82 ms)
✓ Verify that rpcClient.getBlockHeader returns the whole block header (68 ms)
✓ Verify that rpcClient.getBlockMetadata returns all metadata associated to the block (71 ms)
✓ Verify that rpcClient.getBakingRights retrieves the list of delegates allowed to bake a block (53 ms)
✓ Verify that rpcClient.getAttestationRights(deprecated) retrieves the list of delegates allowed to attest a block (70 ms)
✓ Verify that rpcClient.getEndorsingRights(deprecated) retrieves the list of delegates allowed to endorse a block (68 ms)
✓ Verify that rpcClient.getBallotList returns ballots casted so far during a voting period (51 ms)
✓ Verify that rpcClient.getBallots returns sum of ballots casted so far during a voting period (66 ms)
✓ Verify that rpcClient.getCurrentPeriod returns current period kind (61 ms)
✓ Verify that rpcClient.getCurrentProposal returns current proposal under evaluation (71 ms)
✓ Verify that rpcClient.getCurrentQuorum returns current expected quorum (57 ms)
✓ Verify that rpcClient.getVotesListings returns list of delegates with their voting weight, in number of rolls (58 ms)
✓ Verify that rpcClient.getProposals returns list of proposals with number of supporters (65 ms)
✓ Verify that rpcClient.forgeOperations forges an operation and returns the unsigned bytes (84 ms)
✓ Verify that rpcClient.injectOperation injects an operation in node and broadcast it (50 ms)
✓ Verify that rpcClient.preapplyOperations simulates the validation of an operation (260 ms)
✓ Verify that rpcClient.getEntrypoints for known contract returns list of entrypoints of the contract (57 ms)
✓ Verify that rpcClient.getChainId returns chain ID (55 ms)
✓ Verify that rpcClient.runOperation runs an operation without signature checks (60 ms)
✓ Verify that rpcClient.simulateOperation simulates an operation without signature checks (62 ms)
✓ Verify that rpcClient.runView executes tzip4 views (108 ms)
✓ Verify that rpcClient.runScriptView executes michelson view (118 ms)
✓ Verify that rpcClient.getSuccessorPeriod will get the voting period of next block (53 ms)
✓ Verify that rpcClient.getSaplingDiffById will access the value associated with a sapling state ID (109 ms)
✓ Verify that rpcClient.getSaplingDiffByContract will access the value associated with a sapling state (57 ms)
✓ Verify that rpcClient.getProtocols will list past and present Tezos protocols (58 ms)
✓ Verify that rpcClient.getStorageUsedSpace will retrieve the used space of a contract storage (55 ms)
✓ Verify that rpcClient.getStoragePaidSpace will retrieve the paid space of a contract storage (63 ms)
✓ Verify that rpcClient.ticketBalance will retrieve the specified ticket owned by the given contract (55 ms)
✓ Verify that rpcClient.allTicketBalances will retrieve all tickets owned by the given contract (55 ms)
✓ Verify that rpcClient.getPendingOperations version1 will retrieve the pending operations in mempool with property applied (1221 ms)
✓ Verify that rpcClient.getPendingOperations version2 will retrieve the pending operations in mempool with property validated (892 ms)
```

**Otherwise, you will see which endpoints do not work for a specific node:**
**Otherwise, you will see which endpoints do not work for a specific node:**

```
Test calling all methods from RPC node: https://another-node
✓ Get the head block hash (888 ms)
✓ List the ancestors of the head block (782 ms)
✓ Access the balance of an address (779 ms)
✓ Access the data of a contract (636 ms)
✓ Access the code and data of a contract (801 ms)
✓ Access the complete status of a contract (638 ms)
✓ Access the manager key of a contract (771 ms)
✓ Access the delegate of a contract (682 ms)
✓ Access the value associated with a key in a big map (4200 ms)
✓ Fetches information about a delegate from RPC (739 ms)
✓ Get all constants from RPC (633 ms)
✓ Get all the information about a block (673 ms)
✓ Get the whole block header (648 ms)
✓ Get all the metadata associated to the block (646 ms)
✓ Retrieves the list of delegates allowed to bake a block (814 ms)
✓ Retrieves the list of delegates allowed to endorse a block (649 ms)
✕ Get ballots casted so far during a voting period (634 ms)
✕ Get sum of ballots casted so far during a voting period (707 ms)
✕ Get current period kind (766 ms)
✕ Get current proposal under evaluation (654 ms)
✕ Get current expected quorum (639 ms)
✕ List of delegates with their voting weight, in number of rolls (630 ms)
✕ List of proposals with number of supporters (699 ms)
✓ Forge an operation returning the unsigned bytes (641 ms)
✓ Inject an operation in node and broadcast it (655 ms)
✓ Simulate the validation of an operation (653 ms)
✓ Get the list of entrypoints of the contract (625 ms)
✓ Get chain ID (636 ms)
✓ Run an operation without signature checks (626 ms)
✓ Verify that rpcClient.getBlockHash returns the head block hash (64 ms)
✓ Verify that rpcClient.getLiveBlocks returns the ancestors of the head block (85 ms)
✓ Verify that rpcClient.getBalance returns the spendable balance of knownBaker, excluding frozen bonds (74 ms)
✓ Verify that rpcClient.getStorage returns the storage data of knowContract (67 ms)
✓ Verify that rpcClient.getScript returns the script data of knownContract (88 ms)
✓ Verify that rpcClient.getNormalizedScript returns the script of the knownContract and normalize it using the requested unparsing mode (56 ms)
✓ Verify that rpcClient.getContract returns the complete status of knownContract (66 ms)
✓ Verify that rpcClient.getManagerKey returns the manager key of the knownBaker (76 ms)
✓ Verify that rpcClient.getDelegate returns the delegate of the knownBaker (54 ms)
✓ Verify that rpcClient.getBigMapExpr(deprecated) returns the value associated with encoded expression in a big map (330 ms)
✓ Verify that rpcClient.getDelegates returns everything about a delegate (71 ms)
✓ verify that rpcClient.getVotingInfo returns the knownBaker voting power found in the listings of the current voting period (57 ms)
✓ Verify that rpcClient.getConstants returns all constants from RPC (65 ms)
✓ Verify that rpcClient.getBlock returns all the information about a block (82 ms)
✓ Verify that rpcClient.getBlockHeader returns the whole block header (68 ms)
✓ Verify that rpcClient.getBlockMetadata returns all metadata associated to the block (71 ms)
✓ Verify that rpcClient.getBakingRights retrieves the list of delegates allowed to bake a block (53 ms)
✓ Verify that rpcClient.getAttestationRights(deprecated) retrieves the list of delegates allowed to attest a block (70 ms)
✓ Verify that rpcClient.getEndorsingRights(deprecated) retrieves the list of delegates allowed to endorse a block (68 ms)
✓ Verify that rpcClient.getBallotList returns ballots casted so far during a voting period (51 ms)
✓ Verify that rpcClient.getBallots returns sum of ballots casted so far during a voting period (66 ms)
✓ Verify that rpcClient.getCurrentPeriod returns current period kind (61 ms)
✓ Verify that rpcClient.getCurrentProposal returns current proposal under evaluation (71 ms)
✓ Verify that rpcClient.getCurrentQuorum returns current expected quorum (57 ms)
✓ Verify that rpcClient.getVotesListings returns list of delegates with their voting weight, in number of rolls (58 ms)
✓ Verify that rpcClient.getProposals returns list of proposals with number of supporters (65 ms)
✓ Verify that rpcClient.forgeOperations forges an operation and returns the unsigned bytes (84 ms)
✓ Verify that rpcClient.injectOperation injects an operation in node and broadcast it (50 ms)
✓ Verify that rpcClient.preapplyOperations simulates the validation of an operation (260 ms)
✓ Verify that rpcClient.getEntrypoints for known contract returns list of entrypoints of the contract (57 ms)
✓ Verify that rpcClient.getChainId returns chain ID (55 ms)
✓ Verify that rpcClient.runOperation runs an operation without signature checks (60 ms)
✓ Verify that rpcClient.simulateOperation simulates an operation without signature checks (62 ms)
✓ Verify that rpcClient.runView executes tzip4 views (108 ms)
✓ Verify that rpcClient.runScriptView executes michelson view (118 ms)
✓ Verify that rpcClient.getSuccessorPeriod will get the voting period of next block (53 ms)
✓ Verify that rpcClient.getSaplingDiffById will access the value associated with a sapling state ID (109 ms)
✓ Verify that rpcClient.getSaplingDiffByContract will access the value associated with a sapling state (57 ms)
✓ Verify that rpcClient.getProtocols will list past and present Tezos protocols (58 ms)
✓ Verify that rpcClient.getStorageUsedSpace will retrieve the used space of a contract storage (55 ms)
✓ Verify that rpcClient.getStoragePaidSpace will retrieve the paid space of a contract storage (63 ms)
✓ Verify that rpcClient.ticketBalance will retrieve the specified ticket owned by the given contract (55 ms)
✓ Verify that rpcClient.allTicketBalances will retrieve all tickets owned by the given contract (55 ms)
✓ Verify that rpcClient.getPendingOperations version1 will retrieve the pending operations in mempool with property applied (1221 ms)
✓ Verify that rpcClient.getPendingOperations version2 will retrieve the pending operations in mempool with property validated (892 ms)
```
6 changes: 5 additions & 1 deletion example/example-streamer-custom-retry-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ async function example() {
) as any
}));

const bakeAttestationFilter = {
and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'attestation' }]
}

const bakerEndorsementFilter = {
and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'endorsement' }]
}
Expand All @@ -29,7 +33,7 @@ async function example() {
}

tezos.stream.subscribeOperation({
or: [bakerEndorsementFilter, bakerDelegation]
or: [bakeAttestationFilter, bakerEndorsementFilter, bakerDelegation]
})
}

Expand Down
6 changes: 5 additions & 1 deletion example/example-streamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ async function example() {
tezos.setStreamProvider(tezos.getFactory(PollingSubscribeProvider)({ shouldObservableSubscriptionRetry: true, pollingIntervalMilliseconds: 15000 }));
try {

const bakerAttestationFilter = {
and: [{ source: 'tz1bQMn5xYFbX6geRxqvuAiTywsCtNywawxH' }, { kind: 'attestation' }]
}

const bakerEndorsementFilter = {
and: [{ source: 'tz1bQMn5xYFbX6geRxqvuAiTywsCtNywawxH' }, { kind: 'endorsement' }]
}
Expand All @@ -15,7 +19,7 @@ async function example() {
}

const sub = tezos.stream.subscribeOperation({
or: [bakerEndorsementFilter, bakerDelegation]
or: [bakerAttestationFilter, bakerEndorsementFilter, bakerDelegation]
})

sub.on('data', console.log)
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/data/allTestsCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1172,12 +1172,12 @@ export const commonCases: TestCase[] = [
},
},
{
name: 'Endorsement',
name: 'Attestation',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.ENDORSEMENT,
kind: OpKind.ATTESTATION,
slot: 0,
level: 66299,
round: 5,
Expand Down
Loading

0 comments on commit dda9fe0

Please sign in to comment.