From dda9fe0d57f0669b786a3e7dbc99a1f1b747dfcf Mon Sep 17 00:00:00 2001 From: hui-an-yang <106410553+hui-an-yang@users.noreply.github.com> Date: Tue, 26 Sep 2023 06:24:34 -0700 Subject: [PATCH] 2599 oxford supports attestation (#2666) * 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 --- cspell.json | 3 + docs/consensus_key.md | 2 +- docs/rpc_nodes_integration_test.md | 154 ++++++----- .../example-streamer-custom-retry-logic.ts | 6 +- example/example-streamer.ts | 6 +- integration-tests/data/allTestsCases.ts | 4 +- integration-tests/rpc-nodes.spec.ts | 41 ++- .../src/rpc-wrapper.ts | 8 + .../taquito-local-forging/src/constants.ts | 3 +- packages/taquito-local-forging/src/decoder.ts | 3 + packages/taquito-local-forging/src/encoder.ts | 2 + .../src/schema/operation.ts | 7 + .../taquito-local-forging/src/validator.ts | 3 + packages/taquito-rpc/src/opkind.ts | 5 + .../taquito-rpc/src/rpc-client-interface.ts | 7 + .../src/rpc-client-modules/rpc-cache.ts | 34 ++- packages/taquito-rpc/src/taquito-rpc.ts | 24 ++ packages/taquito-rpc/src/types.ts | 255 +++++++++++++----- .../taquito-rpc/test/data/rpc-responses.ts | 167 +++++++++--- packages/taquito-rpc/test/rpc-cache.spec.ts | 13 + .../taquito-utils/src/verify-signature.ts | 2 +- packages/taquito/README.md | 20 +- packages/taquito/src/signer/interface.ts | 2 +- packages/taquito/src/subscribe/filters.ts | 2 + packages/taquito/test/read-provider/data.ts | 124 +++++++-- .../read-provider/rpc-read-adapter.spec.ts | 6 +- 26 files changed, 687 insertions(+), 216 deletions(-) diff --git a/cspell.json b/cspell.json index 08c719d950..fae5d9bc3d 100644 --- a/cspell.json +++ b/cspell.json @@ -12,6 +12,7 @@ "Bjorsell", "Boissonneault", "camelcase", + "cooldown", "crios", "dailynet", "delphinet", @@ -53,7 +54,9 @@ "octez", "oxfordnet", "oxheadalpha", + "preattestation", "precommit", + "preendorsement", "println", "Protofire", "Proxford", diff --git a/docs/consensus_key.md b/docs/consensus_key.md index 7b9b84b478..49d4314ea2 100644 --- a/docs/consensus_key.md +++ b/docs/consensus_key.md @@ -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: diff --git a/docs/rpc_nodes_integration_test.md b/docs/rpc_nodes_integration_test.md index edc77b8312..8defc0aafc 100644 --- a/docs/rpc_nodes_integration_test.md +++ b/docs/rpc_nodes_integration_test.md @@ -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) ``` \ No newline at end of file diff --git a/example/example-streamer-custom-retry-logic.ts b/example/example-streamer-custom-retry-logic.ts index 7009bcd7a5..4dd6b0a41e 100644 --- a/example/example-streamer-custom-retry-logic.ts +++ b/example/example-streamer-custom-retry-logic.ts @@ -20,6 +20,10 @@ async function example() { ) as any })); + const bakeAttestationFilter = { + and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'attestation' }] + } + const bakerEndorsementFilter = { and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'endorsement' }] } @@ -29,7 +33,7 @@ async function example() { } tezos.stream.subscribeOperation({ - or: [bakerEndorsementFilter, bakerDelegation] + or: [bakeAttestationFilter, bakerEndorsementFilter, bakerDelegation] }) } diff --git a/example/example-streamer.ts b/example/example-streamer.ts index 9653adad81..91d61bee55 100644 --- a/example/example-streamer.ts +++ b/example/example-streamer.ts @@ -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' }] } @@ -15,7 +19,7 @@ async function example() { } const sub = tezos.stream.subscribeOperation({ - or: [bakerEndorsementFilter, bakerDelegation] + or: [bakerAttestationFilter, bakerEndorsementFilter, bakerDelegation] }) sub.on('data', console.log) diff --git a/integration-tests/data/allTestsCases.ts b/integration-tests/data/allTestsCases.ts index 482be9d14d..0979aa95f2 100644 --- a/integration-tests/data/allTestsCases.ts +++ b/integration-tests/data/allTestsCases.ts @@ -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, diff --git a/integration-tests/rpc-nodes.spec.ts b/integration-tests/rpc-nodes.spec.ts index 758ecc1b9b..00162b9388 100644 --- a/integration-tests/rpc-nodes.spec.ts +++ b/integration-tests/rpc-nodes.spec.ts @@ -53,61 +53,61 @@ CONFIGS().forEach( const rpcClient = new RpcClientCache(new RpcClient(rpc)); describe(`Test calling all methods from RPC node: ${rpc}`, () => { - it('Verify rpcClient.getBlockHash returns the head block hash', async (done) => { + it('Verify that rpcClient.getBlockHash returns the head block hash', async (done) => { const blockHash = await rpcClient.getBlockHash(); expect(blockHash).toBeDefined(); done(); }); - it('Verify rpcClient.getLiveBlocks returns the ancestors of the head block', async (done) => { + it('Verify that rpcClient.getLiveBlocks returns the ancestors of the head block', async (done) => { const liveBlocks = await rpcClient.getLiveBlocks(); expect(liveBlocks).toBeDefined(); done(); }); - it(`Verify rpcClient.getBalance for known baker returns the balance of the address`, async (done) => { + it(`Verify that rpcClient.getBalance returns the spendable balance of knownBaker, excluding frozen bonds`, async (done) => { const balance = await rpcClient.getBalance(knownBaker); expect(balance).toBeDefined(); done(); }); - it(`Verify that rpcClient.getStorage for know contract returns the data of a contract`, async (done) => { + it(`Verify that rpcClient.getStorage returns the storage data of knowContract`, async (done) => { const storage = await rpcClient.getStorage(knownContract); expect(storage).toBeDefined(); done(); }); - it(`Verify that rpcClient.getScript for know contract returns the code and data of a contract`, async (done) => { + it(`Verify that rpcClient.getScript returns the script data of knownContract`, async (done) => { const script = await rpcClient.getScript(knownContract); expect(script).toBeDefined(); done(); }); - it(`Verify that rpcClient.getNormalizedScript for known contract returns the script of the contract and normalize it using the requested unparsing mode`, async (done) => { + it(`Verify that rpcClient.getNormalizedScript returns the script of the knownContract and normalize it using the requested unparsing mode`, async (done) => { const script = await rpcClient.getNormalizedScript(knownContract); expect(script).toBeDefined(); done(); }); - it(`Verify that rpcClient.getContract returns the complete status of a contract`, async (done) => { + it(`Verify that rpcClient.getContract returns the complete status of knownContract`, async (done) => { const contract = await rpcClient.getContract(knownContract); expect(contract).toBeDefined(); done(); }); - it(`Verify that rpcClient.getManagerKey for known baker returns the manager key of the contract`, async (done) => { + it(`Verify that rpcClient.getManagerKey returns the manager key of the knownBaker`, async (done) => { const managerKey = await rpcClient.getManagerKey(knownBaker); expect(managerKey).toBeDefined(); done(); }); - it(`Verify that rpcClient.getDelegate for known baker returns the delegate of the contract`, async (done) => { + it(`Verify that rpcClient.getDelegate returns the delegate of the knownBaker`, async (done) => { const delegate = await rpcClient.getDelegate(knownBaker); expect(delegate).toBeDefined(); done(); }); - it(`Verify that rpcClient.getBigMapExpr for encoded expression returns the value associated with a key in a big map`, async (done) => { + it(`Verify that rpcClient.getBigMapExpr(deprecated) returns the value associated with encoded expression in a big map`, async (done) => { const schema = new Schema({ prim: 'big_map', args: [ @@ -137,13 +137,13 @@ CONFIGS().forEach( done(); }); - it(`Verify that rpcClient.getDelegates for known baker returns information about a delegate from RPC`, async (done) => { + it(`Verify that rpcClient.getDelegates returns everything about a delegate`, async (done) => { const delegates = await rpcClient.getDelegates(knownBaker); expect(delegates).toBeDefined(); done(); }); - it(`Fetches voting information about a delegate from RPC`, async (done) => { + it(`verify that rpcClient.getVotingInfo returns the knownBaker voting power found in the listings of the current voting period`, async (done) => { const votinInfo = await rpcClient.getVotingInfo(knownBaker); expect(votinInfo).toBeDefined(); done(); @@ -161,7 +161,7 @@ CONFIGS().forEach( done(); }); - it('Verify that rpcClient.getBlockHeader returns whole block header', async (done) => { + it('Verify that rpcClient.getBlockHeader returns the whole block header', async (done) => { const blockHeader = await rpcClient.getBlockHeader(); expect(blockHeader).toBeDefined(); done(); @@ -183,7 +183,20 @@ CONFIGS().forEach( done(); }); - unrestrictedRPCNode('Verify that rpcClient.getEndorsingRights retrieves the list of delegates allowed to endorse a block', async (done) => { + unrestrictedRPCNode('Verify that rpcClient.getAttestationRights(deprecated) retrieves the list of delegates allowed to attest a block', async (done) => { + const attestRights = await rpcClient.getAttestationRights(); + expect(attestRights).toBeDefined(); + expect(attestRights[0].delegates).toBeDefined(); + expect(attestRights[0].delegates![0].delegate).toBeDefined(); + expect(typeof attestRights[0].delegates![0].delegate).toEqual('string'); + expect(attestRights[0].delegates![0].attestation_power).toBeDefined(); + expect(typeof attestRights[0].delegates![0].attestation_power).toEqual('number'); + expect(attestRights[0].delegates![0].first_slot).toBeDefined(); + expect(typeof attestRights[0].delegates![0].first_slot).toEqual('number'); + done(); + }); + + unrestrictedRPCNode('Verify that rpcClient.getEndorsingRights(deprecated) retrieves the list of delegates allowed to endorse a block', async (done) => { const endorsingRights = await rpcClient.getEndorsingRights(); expect(endorsingRights).toBeDefined(); expect(endorsingRights[0].delegates).toBeDefined(); diff --git a/packages/taquito-contracts-library/src/rpc-wrapper.ts b/packages/taquito-contracts-library/src/rpc-wrapper.ts index f0fb87a0ed..51f600e770 100644 --- a/packages/taquito-contracts-library/src/rpc-wrapper.ts +++ b/packages/taquito-contracts-library/src/rpc-wrapper.ts @@ -17,7 +17,9 @@ import { DelegateResponse, DelegatesResponse, VotingInfoResponse, + AttestationRightsQueryArguments, EndorsingRightsQueryArguments, + AttestationRightsResponse, EndorsingRightsResponse, EntrypointsResponse, ForgeOperationsParams, @@ -169,6 +171,12 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface { ): Promise { return this.rpc.getBakingRights(args, { block }); } + async getAttestationRights( + args: AttestationRightsQueryArguments, + { block }: RPCOptions = defaultRPCOptions + ): Promise { + return this.rpc.getAttestationRights(args, { block }); + } async getEndorsingRights( args: EndorsingRightsQueryArguments, { block }: RPCOptions = defaultRPCOptions diff --git a/packages/taquito-local-forging/src/constants.ts b/packages/taquito-local-forging/src/constants.ts index afaaf0a93d..d69d75dcc4 100644 --- a/packages/taquito-local-forging/src/constants.ts +++ b/packages/taquito-local-forging/src/constants.ts @@ -41,6 +41,7 @@ export enum CODEC { OP_ORIGINATION = 'origination', OP_BALLOT = 'ballot', OP_FAILING_NOOP = 'failing_noop', + OP_ATTESTATION = 'attestation', OP_ENDORSEMENT = 'endorsement', OP_SEED_NONCE_REVELATION = 'seed_nonce_revelation', OP_REVEAL = 'reveal', @@ -241,7 +242,7 @@ export const kindMapping: { [key: number]: string } = { 0x6c: 'transaction', 0x6d: 'origination', 0x06: 'ballot', - 0x15: 'endorsement', + 0x15: 'attestation', 0x01: 'seed_nonce_revelation', 0x05: 'proposals', 0x6f: 'register_global_constant', diff --git a/packages/taquito-local-forging/src/decoder.ts b/packages/taquito-local-forging/src/decoder.ts index 8959d0b129..752b9fa129 100644 --- a/packages/taquito-local-forging/src/decoder.ts +++ b/packages/taquito-local-forging/src/decoder.ts @@ -33,6 +33,7 @@ import { ActivationSchema, BallotSchema, DelegationSchema, + AttestationSchema, EndorsementSchema, IncreasePaidStorageSchema, UpdateConsensusKeySchema, @@ -105,6 +106,8 @@ decoders[CODEC.OP_TRANSACTION] = (val: Uint8ArrayConsumer) => decoders[CODEC.OP_ORIGINATION] = (val: Uint8ArrayConsumer) => schemaDecoder(decoders)(OriginationSchema)(val); decoders[CODEC.OP_BALLOT] = (val: Uint8ArrayConsumer) => schemaDecoder(decoders)(BallotSchema)(val); +decoders[CODEC.OP_ATTESTATION] = (val: Uint8ArrayConsumer) => + schemaDecoder(decoders)(AttestationSchema)(val); decoders[CODEC.OP_ENDORSEMENT] = (val: Uint8ArrayConsumer) => schemaDecoder(decoders)(EndorsementSchema)(val); decoders[CODEC.OP_SEED_NONCE_REVELATION] = (val: Uint8ArrayConsumer) => diff --git a/packages/taquito-local-forging/src/encoder.ts b/packages/taquito-local-forging/src/encoder.ts index 917f2ee26b..6749c09da6 100644 --- a/packages/taquito-local-forging/src/encoder.ts +++ b/packages/taquito-local-forging/src/encoder.ts @@ -32,6 +32,7 @@ import { ActivationSchema, BallotSchema, DelegationSchema, + AttestationSchema, EndorsementSchema, IncreasePaidStorageSchema, UpdateConsensusKeySchema, @@ -94,6 +95,7 @@ encoders[CODEC.OP_DELEGATION] = (val: any) => schemaEncoder(encoders)(Delegation encoders[CODEC.OP_TRANSACTION] = (val: any) => schemaEncoder(encoders)(TransactionSchema)(val); encoders[CODEC.OP_ORIGINATION] = (val: any) => schemaEncoder(encoders)(OriginationSchema)(val); encoders[CODEC.OP_BALLOT] = (val: any) => schemaEncoder(encoders)(BallotSchema)(val); +encoders[CODEC.OP_ATTESTATION] = (val: any) => schemaEncoder(encoders)(AttestationSchema)(val); encoders[CODEC.OP_ENDORSEMENT] = (val: any) => schemaEncoder(encoders)(EndorsementSchema)(val); encoders[CODEC.OP_SEED_NONCE_REVELATION] = (val: any) => schemaEncoder(encoders)(SeedNonceRevelationSchema)(val); diff --git a/packages/taquito-local-forging/src/schema/operation.ts b/packages/taquito-local-forging/src/schema/operation.ts index 90aaae1c19..536e5573ea 100644 --- a/packages/taquito-local-forging/src/schema/operation.ts +++ b/packages/taquito-local-forging/src/schema/operation.ts @@ -65,6 +65,13 @@ export const BallotSchema = { ballot: CODEC.BALLOT_STATEMENT, }; +export const AttestationSchema = { + slot: CODEC.INT16, + level: CODEC.INT32, + round: CODEC.INT32, + block_payload_hash: CODEC.BLOCK_PAYLOAD_HASH, +}; + export const EndorsementSchema = { slot: CODEC.INT16, level: CODEC.INT32, diff --git a/packages/taquito-local-forging/src/validator.ts b/packages/taquito-local-forging/src/validator.ts index e94fa741b0..6aafd0ce96 100644 --- a/packages/taquito-local-forging/src/validator.ts +++ b/packages/taquito-local-forging/src/validator.ts @@ -10,6 +10,7 @@ import { ProposalsSchema, RevealSchema, RegisterGlobalConstantSchema, + AttestationSchema, EndorsementSchema, TransferTicketSchema, TxRollupOriginationSchema, @@ -31,6 +32,7 @@ type OperationKind = | OpKind.TRANSACTION | OpKind.ORIGINATION | OpKind.BALLOT + | OpKind.ATTESTATION | OpKind.ENDORSEMENT | OpKind.SEED_NONCE_REVELATION | OpKind.PROPOSALS @@ -53,6 +55,7 @@ const OperationKindMapping = { transaction: TransactionSchema, origination: OriginationSchema, ballot: BallotSchema, + attestation: AttestationSchema, endorsement: EndorsementSchema, seed_nonce_revelation: SeedNonceRevelationSchema, proposals: ProposalsSchema, diff --git a/packages/taquito-rpc/src/opkind.ts b/packages/taquito-rpc/src/opkind.ts index b7e163d4b7..1b1b66fdef 100644 --- a/packages/taquito-rpc/src/opkind.ts +++ b/packages/taquito-rpc/src/opkind.ts @@ -4,12 +4,17 @@ export enum OpKind { REVEAL = 'reveal', TRANSACTION = 'transaction', ACTIVATION = 'activate_account', + ATTESTATION = 'attestation', ENDORSEMENT = 'endorsement', + PREATTESTATION = 'preattestation', PREENDORSEMENT = 'preendorsement', SET_DEPOSITS_LIMIT = 'set_deposits_limit', + DOUBLE_PREATTESTATION_EVIDENCE = 'double_preattestation_evidence', DOUBLE_PREENDORSEMENT_EVIDENCE = 'double_preendorsement_evidence', + ATTESTATION_WITH_SLOT = 'attestation_with_slot', ENDORSEMENT_WITH_SLOT = 'endorsement_with_slot', SEED_NONCE_REVELATION = 'seed_nonce_revelation', + DOUBLE_ATTESTATION_EVIDENCE = 'double_attestation_evidence', DOUBLE_ENDORSEMENT_EVIDENCE = 'double_endorsement_evidence', DOUBLE_BAKING_EVIDENCE = 'double_baking_evidence', PROPOSALS = 'proposals', diff --git a/packages/taquito-rpc/src/rpc-client-interface.ts b/packages/taquito-rpc/src/rpc-client-interface.ts index 6081a1e0e2..61e8af9f7a 100644 --- a/packages/taquito-rpc/src/rpc-client-interface.ts +++ b/packages/taquito-rpc/src/rpc-client-interface.ts @@ -17,7 +17,9 @@ import { CurrentQuorumResponse, DelegateResponse, DelegatesResponse, + AttestationRightsQueryArguments, EndorsingRightsQueryArguments, + AttestationRightsResponse, EndorsingRightsResponse, EntrypointsResponse, ForgeOperationsParams, @@ -84,6 +86,10 @@ export interface RpcClientInterface { args: BakingRightsQueryArguments, options?: RPCOptions ): Promise; + getAttestationRights( + args: AttestationRightsQueryArguments, + options?: RPCOptions + ): Promise; getEndorsingRights( args: EndorsingRightsQueryArguments, options?: RPCOptions @@ -150,6 +156,7 @@ export enum RPCMethodName { GET_DELEGATE = 'getDelegate', GET_DELEGATES = 'getDelegates', GET_VOTING_INFO = 'getVotingInfo', + GET_ATTESTATION_RIGHTS = 'getAttestationRights', GET_ENDORSING_RIGHTS = 'getEndorsingRights', GET_ENTRYPOINTS = 'getEntrypoints', GET_LIVE_BLOCKS = 'getLiveBlocks', diff --git a/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts b/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts index 191ca7448c..b8114cfcc8 100644 --- a/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts +++ b/packages/taquito-rpc/src/rpc-client-modules/rpc-cache.ts @@ -20,7 +20,9 @@ import { DelegateResponse, DelegatesResponse, VotingInfoResponse, + AttestationRightsQueryArguments, EndorsingRightsQueryArguments, + AttestationRightsResponse, EndorsingRightsResponse, EntrypointsResponse, ForgeOperationsParams, @@ -72,7 +74,8 @@ type RpcMethodParam = | BigMapKey | BakingRightsQueryArguments | PendingOperationsQueryArguments - | EndorsingRightsQueryArguments; + | AttestationRightsQueryArguments + | EndorsingRightsQueryArguments const defaultTtl = 1000; @@ -88,7 +91,7 @@ export class RpcClientCache implements RpcClientInterface { * * @example new RpcClientCache(new RpcClient('https://mainnet.ecadinfra.com/')) */ - constructor(private rpcClient: RpcClientInterface, private ttl = defaultTtl) {} + constructor(private rpcClient: RpcClientInterface, private ttl = defaultTtl) { } getAllCachedData() { return this._cache; @@ -617,6 +620,33 @@ export class RpcClientCache implements RpcClientInterface { } } + /** + * + * @param args contains optional query arguments + * @param options contains generic configuration for rpc calls + * + * @description Retrieves the list of delegates allowed to bake a block. + * + * @see https://tezos.gitlab.io/api/rpc.html#get-block-id-helpers-attestation-rights + */ + async getAttestationRights( + args: AttestationRightsQueryArguments = {}, + { block }: RPCOptions = defaultRPCOptions + ): Promise { + const key = this.formatCacheKey( + this.rpcClient.getRpcUrl(), + RPCMethodName.GET_ATTESTATION_RIGHTS, + [block, args] + ); + if (this.has(key)) { + return this.get(key); + } else { + const response = this.rpcClient.getAttestationRights(args, { block }); + this.put(key, response); + return response; + } + } + /** * * @param args contains optional query arguments diff --git a/packages/taquito-rpc/src/taquito-rpc.ts b/packages/taquito-rpc/src/taquito-rpc.ts index f18856e281..86092ebdde 100644 --- a/packages/taquito-rpc/src/taquito-rpc.ts +++ b/packages/taquito-rpc/src/taquito-rpc.ts @@ -29,7 +29,9 @@ import { DelegateResponse, DelegatesResponse, VotingInfoResponse, + AttestationRightsQueryArguments, EndorsingRightsQueryArguments, + AttestationRightsResponse, EndorsingRightsResponse, EntrypointsResponse, ForgeOperationsParams, @@ -586,6 +588,28 @@ export class RpcClient implements RpcClientInterface { return response; } + /** + * + * @param args contains optional query arguments + * @param options contains generic configuration for rpc calls to specify block + * + * @description Retrieves the delegates allowed to attest a block. + * + * @see https://tezos.gitlab.io/api/rpc.html#get-block-id-helpers-attestation-rights + */ + async getAttestationRights( + args: AttestationRightsQueryArguments = {}, + { block }: RPCOptions = defaultRPCOptions + ): Promise { + const response = await this.httpBackend.createRequest({ + url: this.createURL(`/chains/${this.chain}/blocks/${block}/helpers/attestation_rights`), + method: 'GET', + query: args, + }); + + return response; + } + /** * * @param args contains optional query arguments diff --git a/packages/taquito-rpc/src/types.ts b/packages/taquito-rpc/src/types.ts index 6a9ab8dcf1..ec7fd016b2 100644 --- a/packages/taquito-rpc/src/types.ts +++ b/packages/taquito-rpc/src/types.ts @@ -19,27 +19,27 @@ interface INodeExtender { type OtherEltsInner = | { - value: any; - } + value: any; + } | { - inode_extender: INodeExtender; - }; + inode_extender: INodeExtender; + }; export type OtherElts = | { - node: [string, { value: string } | { node: string }][]; - } + node: [string, { value: string } | { node: string }][]; + } | { - other_elts: OtherEltsInner; - }; + other_elts: OtherEltsInner; + }; type State = | { - inode: Inode; - } + inode: Inode; + } | { - other_elts: OtherElts; - }; + other_elts: OtherElts; + }; export interface Inode { length: string; @@ -48,11 +48,11 @@ export interface Inode { type TxRollupProofContextHash = | { - value: string; - } + value: string; + } | { - node: string; - }; + node: string; + }; export interface TxRollupProof { version: number; @@ -159,14 +159,32 @@ export interface BlockFullHeader { signature: string; } +export type InlinedAttestationKindEnum = OpKind.ATTESTATION; + export type InlinedEndorsementKindEnum = OpKind.ENDORSEMENT; +export interface InlinedAttestationContents { + kind: InlinedAttestationKindEnum; + slot: number; + level: number; + round: number; + block_payload_hash: string; +} + export interface InlinedEndorsementContents { kind: InlinedEndorsementKindEnum; - slot?: number; - round?: number; - block_payload_hash?: string; + slot: number; level: number; + round: number; + block_payload_hash: string; +} + +export interface InlinedPreattestationContents { + kind: OpKind.PREATTESTATION; + slot: number; + level: number; + round: number; + block_payload_hash: string; } export interface InlinedPreEndorsementContents { @@ -177,12 +195,24 @@ export interface InlinedPreEndorsementContents { block_payload_hash: string; } +export interface InlinedAttestation { + branch: string; + operations: InlinedAttestationContents; + signature?: string; +} + export interface InlinedEndorsement { branch: string; operations: InlinedEndorsementContents; signature?: string; } +export interface InlinedPreattestation { + branch: string; + operations: InlinedPreattestationContents; + signature?: string; +} + export interface InlinedPreEndorsement { branch: string; operations: InlinedPreEndorsementContents; @@ -191,6 +221,14 @@ export interface InlinedPreEndorsement { export type BallotVote = 'nay' | 'yay' | 'pass'; +export interface OperationContentsAttestation { + kind: OpKind.ATTESTATION; + slot: number; + level: number; + round: number; + block_payload_hash?: string; +} + export interface OperationContentsEndorsement { kind: OpKind.ENDORSEMENT; level: number; @@ -199,6 +237,14 @@ export interface OperationContentsEndorsement { block_payload_hash?: string; } +export interface OperationContentsPreattestation { + kind: OpKind.PREATTESTATION; + slot: number; + level: number; + round: number; + block_payload_hash: string; +} + export interface OperationContentsPreEndorsement { kind: OpKind.PREENDORSEMENT; slot: number; @@ -207,6 +253,12 @@ export interface OperationContentsPreEndorsement { block_payload_hash: string; } +export interface OperationContentsDoublePreattestation { + kind: OpKind.DOUBLE_PREATTESTATION_EVIDENCE; + op1: InlinedPreattestation; + op2: InlinedPreattestation; +} + export interface OperationContentsDoublePreEndorsement { kind: OpKind.DOUBLE_PREENDORSEMENT_EVIDENCE; op1: InlinedPreEndorsement; @@ -223,12 +275,6 @@ export interface OperationContentsSetDepositsLimit { limit?: string; } -export interface OperationContentsEndorsementWithSlot { - kind: OpKind.ENDORSEMENT_WITH_SLOT; - endorsement: InlinedEndorsement; - slot: number; -} - export interface OperationContentsRevelation { kind: OpKind.SEED_NONCE_REVELATION; level: number; @@ -240,11 +286,16 @@ export interface OperationContentsVdfRevelation { solution: string[]; } +export interface OperationContentsDoubleAttestation { + kind: OpKind.DOUBLE_ATTESTATION_EVIDENCE; + op1: InlinedAttestation; + op2: InlinedAttestation; +} + export interface OperationContentsDoubleEndorsement { kind: OpKind.DOUBLE_ENDORSEMENT_EVIDENCE; op1: InlinedEndorsement; op2: InlinedEndorsement; - slot?: number; } export interface OperationContentsDoubleBaking { @@ -563,11 +614,15 @@ export interface OperationContentsSmartRollupTimeout { } export type OperationContents = + | OperationContentsAttestation | OperationContentsEndorsement + | OperationContentsPreattestation | OperationContentsPreEndorsement + | OperationContentsDoublePreattestation | OperationContentsDoublePreEndorsement | OperationContentsRevelation | OperationContentsVdfRevelation + | OperationContentsDoubleAttestation | OperationContentsDoubleEndorsement | OperationContentsDoubleBaking | OperationContentsActivateAccount @@ -577,7 +632,6 @@ export type OperationContents = | OperationContentsTransaction | OperationContentsOrigination | OperationContentsDelegation - | OperationContentsEndorsementWithSlot | OperationContentsFailingNoop | OperationContentsRegisterGlobalConstant | OperationContentsSetDepositsLimit @@ -601,7 +655,14 @@ export type OperationContents = | OperationContentsSmartRollupRecoverBond | OperationContentsSmartRollupTimeout; -export interface OperationContentsAndResultMetadataExtended { +export interface OperationContentsAndResultMetadataExtended1 { + balance_updates?: OperationMetadataBalanceUpdates[]; + delegate: string; + consensus_power: number; + consensus_key: string; +} + +export interface OperationContentsAndResultMetadataExtended0 { balance_updates?: OperationMetadataBalanceUpdates[]; delegate: string; slots?: number[]; @@ -609,11 +670,18 @@ export interface OperationContentsAndResultMetadataExtended { consensus_key?: string; } +export interface OperationContentsAndResultMetadataPreattestation { + balance_updates?: OperationMetadataBalanceUpdates[]; + delegate: string; + consensus_power: number; + consensus_key: string; +} + export interface OperationContentsAndResultMetadataPreEndorsement { balance_updates?: OperationMetadataBalanceUpdates[]; delegate: string; preendorsement_power: number; - consensus_key?: string; + consensus_key: string; } export interface OperationContentsAndResultMetadataReveal { @@ -769,13 +837,31 @@ export interface OperationContentsAndResultMetadataSmartRollupTimeout { internal_operation_results?: InternalOperationResult[]; } +export interface OperationContentsAndResultAttestation { + kind: OpKind.ATTESTATION; + slot: number; + level: number; + round: number; + block_payload_hash: string; + metadata: OperationContentsAndResultMetadataExtended1; +} + export interface OperationContentsAndResultEndorsement { kind: OpKind.ENDORSEMENT; - block_payload_hash?: string; + slot: number; level: number; - round?: number; - slot?: number; - metadata: OperationContentsAndResultMetadataExtended; + round: number; + block_payload_hash: string; + metadata: OperationContentsAndResultMetadataExtended0; +} + +export interface OperationContentsAndResultPreattestation { + kind: OpKind.PREATTESTATION; + slot: number; + level: number; + round: number; + block_payload_hash: string; + metadata: OperationContentsAndResultMetadataPreattestation; } export interface OperationContentsAndResultPreEndorsement { @@ -787,17 +873,24 @@ export interface OperationContentsAndResultPreEndorsement { metadata: OperationContentsAndResultMetadataPreEndorsement; } +export interface OperationContentsAndResultDoublePreattestation { + kind: OpKind.DOUBLE_PREATTESTATION_EVIDENCE; + op1: InlinedPreattestation; + op2: InlinedPreattestation; + metadata: OperationContentsAndResultMetadata; +} export interface OperationContentsAndResultDoublePreEndorsement { kind: OpKind.DOUBLE_PREENDORSEMENT_EVIDENCE; op1: InlinedPreEndorsement; op2: InlinedPreEndorsement; metadata: OperationContentsAndResultMetadata; } + export interface OperationContentsAndResultEndorsementWithSlot { kind: OpKind.ENDORSEMENT_WITH_SLOT; endorsement: InlinedEndorsement; slot: number; - metadata: OperationContentsAndResultMetadataExtended; + metadata: OperationContentsAndResultMetadataExtended0; } export interface OperationContentsAndResultRevelation { @@ -807,11 +900,17 @@ export interface OperationContentsAndResultRevelation { metadata: OperationContentsAndResultMetadata; } +export interface OperationContentsAndResultDoubleAttestation { + kind: OpKind.DOUBLE_ATTESTATION_EVIDENCE; + op1: InlinedAttestation; + op2: InlinedAttestation; + metadata: OperationContentsAndResultMetadata; +} + export interface OperationContentsAndResultDoubleEndorsement { kind: OpKind.DOUBLE_ENDORSEMENT_EVIDENCE; op1: InlinedEndorsement; op2: InlinedEndorsement; - slot?: number; metadata: OperationContentsAndResultMetadata; } @@ -1157,10 +1256,14 @@ export interface OperationContentsAndResultSmartRollupTimeout { } export type OperationContentsAndResult = + | OperationContentsAndResultAttestation | OperationContentsAndResultEndorsement + | OperationContentsAndResultPreattestation | OperationContentsAndResultPreEndorsement + | OperationContentsAndResultDoublePreattestation | OperationContentsAndResultDoublePreEndorsement | OperationContentsAndResultRevelation + | OperationContentsAndResultDoubleAttestation | OperationContentsAndResultDoubleEndorsement | OperationContentsAndResultDoubleBaking | OperationContentsAndResultActivateAccount @@ -1257,10 +1360,20 @@ export interface BakingRightsResponseItem { export type BakingRightsResponse = BakingRightsResponseItem[]; +export type AttestationRightsArgumentsDelegate = string | string[]; +export type AttestationRightsArgumentsCycle = number | number[]; +export type AttestationRightsArgumentsLevel = number | number[]; export type EndorsingRightsArgumentsDelegate = string | string[]; export type EndorsingRightsArgumentsCycle = number | number[]; export type EndorsingRightsArgumentsLevel = number | number[]; +export interface AttestationRightsQueryArguments { + level?: AttestationRightsArgumentsLevel; + cycle?: AttestationRightsArgumentsCycle; + delegate?: AttestationRightsArgumentsDelegate; + consensus_key?: string; +} + export interface EndorsingRightsQueryArguments { level?: EndorsingRightsArgumentsLevel; cycle?: EndorsingRightsArgumentsCycle; @@ -1268,20 +1381,36 @@ export interface EndorsingRightsQueryArguments { consensus_key?: string; } +export interface AttestationRightsResponseItemDelegates { + delegate: string; + first_slot: number; + attestation_power: number; + consensus_key: string; +} + export interface EndorsingRightsResponseItemDelegates { delegate: string; first_slot: number; endorsing_power: number; - consensus_key?: string; + consensus_key: string; } + +export interface AttestationRightsResponseItem { + level: number; + delegates: AttestationRightsResponseItemDelegates[]; + estimated_time?: Date; +} + export interface EndorsingRightsResponseItem { level: number; + delegates: EndorsingRightsResponseItemDelegates[]; + estimated_time?: Date; delegate?: string; - delegates?: EndorsingRightsResponseItemDelegates[]; slots?: number[]; - estimated_time?: Date; } +export type AttestationRightsResponse = AttestationRightsResponseItem[]; + export type EndorsingRightsResponse = EndorsingRightsResponseItem[]; export type BallotListResponseEnum = 'nay' | 'yay' | 'pass'; @@ -1419,13 +1548,13 @@ export interface ScriptedContracts { export type BondId = | { - smart_rollup?: never; - tx_rollup: string; - } + smart_rollup?: never; + tx_rollup: string; + } | { - smart_rollup: string; - tx_rollup?: never; - }; + smart_rollup: string; + tx_rollup?: never; + }; export interface OperationBalanceUpdatesItem { kind: BalanceUpdateKindEnum; @@ -1786,24 +1915,18 @@ export interface SuccessfulManagerOperationResult { export type MetadataBalanceUpdatesKindEnum = | 'contract' - | 'freezer' | 'accumulator' + | 'freezer' + | 'minted' | 'burned' - | 'commitment' - | 'minted'; + | 'commitment'; export enum METADATA_BALANCE_UPDATES_CATEGORY { - BAKING_REWARDS = 'baking rewards', - REWARDS = 'rewards', - FEES = 'fees', - DEPOSITS = 'deposits', - LEGACY_REWARDS = 'legacy_rewards', - LEGACY_FEES = 'legacy_fees', - LEGACY_DEPOSITS = 'legacy_deposits', BLOCK_FEES = 'block fees', + DEPOSITS = 'deposits', NONCE_REVELATION_REWARDS = 'nonce revelation rewards', - DOUBLE_SIGNING_EVIDENCE_REWARDS = 'double signing evidence rewards', ENDORSING_REWARDS = 'endorsing rewards', + BAKING_REWARDS = 'baking rewards', BAKING_BONUSES = 'baking bonuses', STORAGE_FEES = 'storage fees', PUNISHMENTS = 'punishments', @@ -1814,9 +1937,18 @@ export enum METADATA_BALANCE_UPDATES_CATEGORY { BOOTSTRAP = 'bootstrap', INVOICE = 'invoice', MINTED = 'minted', + BONDS = 'bonds', + SMART_ROLLUP_REFUTATION_PUNISHMENTS = 'smart_rollup_refutation_punishments', + SMART_ROLLUP_REFUTATION_REWARDS = 'smart_rollup_refutation_rewards', + UNSTAKED_DEPOSITS = 'unstaked_deposits', + REWARDS = 'rewards', + FEES = 'fees', + LEGACY_REWARDS = 'legacy_rewards', + LEGACY_FEES = 'legacy_fees', + LEGACY_DEPOSITS = 'legacy_deposits', + DOUBLE_SIGNING_EVIDENCE_REWARDS = 'double signing evidence rewards', TX_ROLLUP_REJECTION_REWARDS = 'tx_rollup_rejection_rewards', TX_ROLLUP_REJECTION_PUNISHMENTS = 'tx_rollup_rejection_punishments', - BONDS = 'bonds', } export type MetadataBalanceUpdatesCategoryEnum = METADATA_BALANCE_UPDATES_CATEGORY; @@ -1824,15 +1956,16 @@ export type MetadataBalanceUpdatesOriginEnum = 'block' | 'migration' | 'subsidy' export interface OperationMetadataBalanceUpdates { kind: MetadataBalanceUpdatesKindEnum; - category?: MetadataBalanceUpdatesCategoryEnum; contract?: string; + change: string; + origin: MetadataBalanceUpdatesOriginEnum; + category?: MetadataBalanceUpdatesCategoryEnum; + staker?: { contract?: string, delegate: string }; delegate?: string; participation?: boolean; revelation?: boolean; committer?: string; cycle?: number; - change: string; - origin?: MetadataBalanceUpdatesOriginEnum; } export type OperationResultStatusEnum = 'applied' | 'failed' | 'skipped' | 'backtracked'; @@ -2189,10 +2322,10 @@ export interface ConstantsResponseProto010 extends ConstantsResponseProto009 { } // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface ConstantsResponseProto009 extends ConstantsResponseProto008 { } +export interface ConstantsResponseProto009 extends ConstantsResponseProto008 {} // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface ConstantsResponseProto008 extends ConstantsResponseProto007 { } +export interface ConstantsResponseProto008 extends ConstantsResponseProto007 {} export interface ConstantsResponseProto007 extends Omit { diff --git a/packages/taquito-rpc/test/data/rpc-responses.ts b/packages/taquito-rpc/test/data/rpc-responses.ts index 3dcd71d4bb..d5ce9c91fa 100644 --- a/packages/taquito-rpc/test/data/rpc-responses.ts +++ b/packages/taquito-rpc/test/data/rpc-responses.ts @@ -2323,53 +2323,138 @@ export const constants = { max_anon_ops_per_block: 132, max_operation_data_length: 32768, max_proposals_per_delegate: 20, + max_micheline_node_count: 50000, + max_micheline_bytes_limit: 50000, + max_allowed_global_constants_depth: 10000, + cache_layout_size: 3, + michelson_maximum_type_size: 2001, + smart_rollup_max_wrapped_proof_binary_size: 30000, + smart_rollup_message_size_limit: 4096, + smart_rollup_max_number_of_messages_per_level: '1000000', preserved_cycles: 3, - blocks_per_cycle: 4096, - blocks_per_commitment: 32, - blocks_per_roll_snapshot: 256, - blocks_per_voting_period: 20480, - time_between_blocks: [new BigNumber(30), new BigNumber(20)], - endorsers_per_block: 256, + blocks_per_cycle: 8192, + blocks_per_commitment: 64, + nonce_revelation_threshold: 512, + blocks_per_stake_snapshot: 512, + cycles_per_voting_period: 1, hard_gas_limit_per_operation: new BigNumber(1040000), - hard_gas_limit_per_block: new BigNumber(5200000), - proof_of_work_threshold: new BigNumber(70368744177663), - minimal_stake: new BigNumber(8000000000), - michelson_maximum_type_size: 1000, - seed_nonce_revelation_tip: new BigNumber(125000), + hard_gas_limit_per_block: new BigNumber(2600000), + proof_of_work_threshold: new BigNumber(-1), + minimal_stake: new BigNumber(6000000000), + minimal_frozen_stake: '600000000', + vdf_difficulty: new BigNumber(10000000000), origination_size: 257, - block_security_deposit: new BigNumber(640000000), - endorsement_security_deposit: new BigNumber(2500000), - baking_reward_per_endorsement: [new BigNumber(78125), new BigNumber(11719)], - endorsement_reward: [new BigNumber(78125), new BigNumber(52083)], + issuance_weights: { + base_total_issued_per_minute: '85007812', + baking_reward_fixed_portion_weight: 5120, + baking_reward_bonus_weight: 5120, + attesting_reward_weight: 10240, + liquidity_baking_subsidy_weight: 1280, + seed_nonce_revelation_tip_weight: 1, + vdf_revelation_tip_weight: 1, + }, cost_per_byte: new BigNumber(250), hard_storage_limit_per_operation: new BigNumber(60000), quorum_min: 2000, quorum_max: 7000, min_proposal_quorum: 500, - initial_endorsers: 192, - delay_per_missing_endorsement: new BigNumber(4), - minimal_block_delay: new BigNumber(15), - liquidity_baking_subsidy: new BigNumber(2500000), - liquidity_baking_sunset_level: 2032928, - liquidity_baking_escape_ema_threshold: 1000000, + liquidity_baking_toggle_ema_threshold: 1000000000, + max_operations_time_to_live: 240, + minimal_block_delay: new BigNumber(8), + delay_increment_per_round: new BigNumber(3), + consensus_committee_size: 7000, + consensus_threshold: 4667, + minimal_participation_ratio: { + numerator: 2, + denominator: 3, + }, + max_slashing_period: 2, + limit_of_delegation_over_baking: 9, + percentage_of_frozen_deposits_slashed_per_double_baking: 10, + percentage_of_frozen_deposits_slashed_per_double_attestation: 50, + testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8', + cache_script_size: 100000000, + cache_stake_distribution_cycles: 8, + cache_sampler_state_cycles: 8, + dal_parametric: { + feature_enable: false, + number_of_slots: 256, + attestation_lag: 4, + attestation_threshold: 50, + blocks_per_epoch: 8, + redundancy_factor: 16, + page_size: 4096, + slot_size: 1048576, + number_of_shards: 2048, + }, + smart_rollup_enable: true, + smart_rollup_arith_pvm_enable: false, + smart_rollup_origination_size: 6314, + smart_rollup_challenge_window_in_blocks: 40, + smart_rollup_stake_amount: '10000000000', + smart_rollup_commitment_period_in_blocks: 20, + smart_rollup_max_lookahead_in_blocks: 30000, + smart_rollup_max_active_outbox_levels: 20160, + smart_rollup_max_outbox_messages_per_level: 100, + smart_rollup_number_of_sections_in_dissection: 32, + smart_rollup_timeout_period_in_blocks: 500, + smart_rollup_max_number_of_cemented_commitments: 5, + smart_rollup_max_number_of_parallel_games: 32, + smart_rollup_reveal_activation_level: { + dal_page: 2147483646, + metadata: 0, + raw_data: { + Blake2B: 0, + }, + }, + zk_rollup_enable: false, + zk_rollup_origination_size: 4000, + zk_rollup_min_pending_to_process: 10, + zk_rollup_max_ticket_payload_size: 2048, + global_limit_of_staking_over_baking: 5, + edge_of_staking_over_delegation: 2, + adaptive_issuance_launch_ema_threshold: 100000000, + adaptive_rewards_params: { + issuance_ratio_min: { + numerator: '1', + denominator: '2000', + }, + issuance_ratio_max: { + numerator: '1', + denominator: '20', + }, + max_bonus: '50000000000000', + growth_rate: '115740740', + center_dz: { + numerator: '1', + denominator: '2', + }, + radius_dz: { + numerator: '1', + denominator: '50', + }, + }, }; + export const blockHeader = { - protocol: 'PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV', - chain_id: 'NetXz969SFaFn8k', - hash: 'BMZXDPn8kKMCSXX1ZfpkCHBuSeXkwqbEp3MJtEwNB21TNVC3Gsp', - level: 516500, + protocol: 'ProxfordSW2S7fvchT1Zgj2avb5UES194neRyYVXoaDGvF9egt8', + chain_id: 'NetXH6zDyMzRsUy', + hash: 'BLgooF9wJXXMhAYMYF7d5A78AJyT4mLDoyQx4qt5JHevQfdnq5R', + level: 326182, proto: 2, - predecessor: 'BM4FhgGT16ikghoVoz1WoG5z2pmo24GC9sTrfMk5UB4KEnzjNTu', - timestamp: '2021-09-27T20:41:55Z', + predecessor: 'BMGK9uiSyg9j6imoh1bBCmNizKgVHoQL2HaJELJJNVGG2fsBj4M', + timestamp: '2023-09-21T20:26:58Z', validation_pass: 4, - operations_hash: 'LLoZRW4irfmyGwY5ufakDd52aA1P6bVhn3zpjBbQxdjPvwjeEaDkK', - fitness: ['01', '000000000007e193'], - context: 'CoWX5BdtfTGKmmwpwhF9cpU6SqBmP5MqostAPP6b3oZp94PG9V2S', - priority: 0, - proof_of_work_nonce: '36055190bec80200', - liquidity_baking_escape_vote: false, + operations_hash: 'LLobF9ZUVRpBqhTFAnE4jmDwMufEEP35v2EuEgWyfqc1HJo32JjZs', + fitness: ['02', '0004fa26', '00000000', 'ffffffff', '00000001'], + context: 'CoV2VS8Kfq3p2JhmKAfZZWNEHDpr7thYMsEkHjwjHQzKYbqLjgmt', + payload_hash: 'vh2w1osGnghEun7bR46KFEkBxNmAYmZ3rN1GdYYEwT6i2vn8159e', + payload_round: 0, + proof_of_work_nonce: 'f59e1b0e00000000', + liquidity_baking_toggle_vote: 'pass', + adaptive_issuance_vote: 'on', signature: - 'sigXwcYckn43nA9uqFKKTqFbkiyhBdKfRd8mbCWHnk4kFqis7unT4VJozBrT7f1pVZNUnTPwHYBqarCdVTRajj5bhWg4qGSF', + 'sigecgpR9FnpDBFSWkMenKCoim1FSS7wXYEsNPGBrEYvCfoqmYnsMsKcpKH8xqLgY7TwK5yhfACE9v3r1LsHivXZtYTbFnRm', }; export const bakingRights = [ @@ -2446,6 +2531,20 @@ export const blockMetadata = { }, ], }; +export const attestationRights = [ + { + level: 326268, + delegates: [ + { + delegate: 'tz1Z8Uy81ATY4Hb95zckc4J6uHdhFnbKSGuv', + first_slot: 4870, + attestation_power: 1, + consensus_key: 'tz1Z8Uy81ATY4Hb95zckc4J6uHdhFnbKSGuv', + }, + ], + }, +]; + export const endorsingRights = [ { level: 516500, diff --git a/packages/taquito-rpc/test/rpc-cache.spec.ts b/packages/taquito-rpc/test/rpc-cache.spec.ts index 0bc823316a..c4aba2c1f4 100644 --- a/packages/taquito-rpc/test/rpc-cache.spec.ts +++ b/packages/taquito-rpc/test/rpc-cache.spec.ts @@ -15,6 +15,7 @@ import { blockHeader, blockMetadata, bakingRights, + attestationRights, endorsingRights, ballotList, ballots, @@ -71,6 +72,7 @@ describe('RpcClientCache test', () => { getBlockHeader: jest.fn(), getBlockMetadata: jest.fn(), getBakingRights: jest.fn(), + getAttestationRights: jest.fn(), getEndorsingRights: jest.fn(), getBallotList: jest.fn(), getBallots: jest.fn(), @@ -110,6 +112,7 @@ describe('RpcClientCache test', () => { mockRpcClient.getBlockHeader.mockReturnValue(blockHeader); mockRpcClient.getBlockMetadata.mockReturnValue(blockMetadata); mockRpcClient.getBakingRights.mockReturnValue(bakingRights); + mockRpcClient.getAttestationRights.mockReturnValue(attestationRights); mockRpcClient.getEndorsingRights.mockReturnValue(endorsingRights); mockRpcClient.getBallotList.mockReturnValue(ballotList); mockRpcClient.getBallots.mockReturnValue(ballots); @@ -154,6 +157,7 @@ describe('RpcClientCache test', () => { await rpcCache.getBlockHeader(); await rpcCache.getBlockMetadata(); await rpcCache.getBakingRights(); + await rpcCache.getAttestationRights(); await rpcCache.getEndorsingRights(); await rpcCache.getBallotList(); await rpcCache.getBallots(); @@ -228,6 +232,9 @@ describe('RpcClientCache test', () => { expect(rpcCache.getAllCachedData()['rpcTest/getBakingRights/head/{}/'].response).toEqual( bakingRights ); + expect(rpcCache.getAllCachedData()['rpcTest/getAttestationRights/head/{}/'].response).toEqual( + attestationRights + ); expect(rpcCache.getAllCachedData()['rpcTest/getEndorsingRights/head/{}/'].response).toEqual( endorsingRights ); @@ -299,6 +306,7 @@ describe('RpcClientCache test', () => { await rpcCache.getBlockHeader(block); await rpcCache.getBlockMetadata(block); await rpcCache.getBakingRights({ level: 1111 }, block); + await rpcCache.getAttestationRights({ level: 1111 }, block); await rpcCache.getEndorsingRights({ level: 1111 }, block); await rpcCache.getBallotList(block); await rpcCache.getBallots(block); @@ -387,6 +395,10 @@ describe('RpcClientCache test', () => { expect( rpcCache.getAllCachedData()[`rpcTest/getBakingRights/${block.block}/{"level":1111}/`].response ).toEqual(bakingRights); + expect( + rpcCache.getAllCachedData()[`rpcTest/getAttestationRights/${block.block}/{"level":1111}/`] + .response + ).toEqual(attestationRights); expect( rpcCache.getAllCachedData()[`rpcTest/getEndorsingRights/${block.block}/{"level":1111}/`] .response @@ -459,6 +471,7 @@ describe('RpcClientCache test', () => { await rpcCache.getBlockHeader(); await rpcCache.getBlockMetadata(); await rpcCache.getBakingRights(); + await rpcCache.getAttestationRights(); await rpcCache.getEndorsingRights(); await rpcCache.getBallotList(); await rpcCache.getBallots(); diff --git a/packages/taquito-utils/src/verify-signature.ts b/packages/taquito-utils/src/verify-signature.ts index 658a0cb867..29c214fbba 100644 --- a/packages/taquito-utils/src/verify-signature.ts +++ b/packages/taquito-utils/src/verify-signature.ts @@ -23,7 +23,7 @@ type SigPrefix = Prefix.EDSIG | Prefix.SPSIG | Prefix.P2SIG | Prefix.SIG; * @description Verify signature of a payload * * @param messageBytes The forged message including the magic byte (11 for block, - * 12 for preendorsement, 13 for endorsement, 3 for generic, 5 for the PACK format of michelson) + * 12 for preendorsement/preattestation, 13 for endorsement/attestation, 3 for generic, 5 for the PACK format of michelson) * @param publicKey The public key to verify the signature against * @param signature The signature to verify * @returns A boolean indicating if the signature matches diff --git a/packages/taquito/README.md b/packages/taquito/README.md index f1f7a47a82..57f610d2e8 100644 --- a/packages/taquito/README.md +++ b/packages/taquito/README.md @@ -1,4 +1,4 @@ -# Taquito high-level functions +# Taquito high-level functions *TypeDoc style documentation is available on-line [here](https://tezostaquito.io/typedoc/modules/_taquito_taquito.html)* @@ -13,9 +13,9 @@ crossorigin="anonymous" integrity="sha384-BSwSPkCs3OtHNJYV10JxwTLgzumF43f8OrYIio ## General Information -The `TezosToolkit` is a facade class that surfaces all of the library's capability and allows its configuration through different providers. +The `TezosToolkit` is a facade class that surfaces all of the library's capability and allows its configuration through different providers. -## Install +## Install ``` npm i --save @taquito/taquito @@ -25,7 +25,7 @@ npm i --save @taquito/taquito ## Minimal configuration ### TezosToolkit instantiation -The `TezosToolkit` constructor takes at least an RPC URL as a parameter. When instantiating the toolkit with a URL, a default instance of `RpcClient` is created. The `RpcClient` class is used to interact with the Tezos network. +The `TezosToolkit` constructor takes at least an RPC URL as a parameter. When instantiating the toolkit with a URL, a default instance of `RpcClient` is created. The `RpcClient` class is used to interact with the Tezos network. ```ts import { TezosToolkit } from '@taquito/taquito'; @@ -114,7 +114,7 @@ Tezos.setProvider( ## Estimation -Use the `estimate` member to estimate fees, gas and storage of operations. +Use the `estimate` member to estimate fees, gas and storage of operations. ```ts const estimate = await Tezos.estimate.transfer(transferParams); @@ -125,12 +125,12 @@ const estimate = await Tezos.estimate.transfer(transferParams); Use the `stream` member to subscribe to specific operations: ```ts -Tezos.setProvider({ - config: { shouldObservableSubscriptionRetry: true, streamerPollingIntervalMilliseconds: 15000 } +Tezos.setProvider({ + config: { shouldObservableSubscriptionRetry: true, streamerPollingIntervalMilliseconds: 15000 } }); -const bakerEndorsementFilter = { - and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'endorsement' }] +const bakerAttestationFilter = { + and: [{ source: 'tz2TSvNTh2epDMhZHrw73nV9piBX7kLZ9K9m' }, { kind: 'attestation' }] } const bakerDelegation = { @@ -138,7 +138,7 @@ const bakerDelegation = { } const sub = tezos.stream.subscribeOperation({ - or: [bakerEndorsementFilter, bakerDelegation] + or: [bakerAttestationFilter, bakerDelegation] }) sub.on('data', console.log) diff --git a/packages/taquito/src/signer/interface.ts b/packages/taquito/src/signer/interface.ts index 980de2eddd..c722d9fc11 100644 --- a/packages/taquito/src/signer/interface.ts +++ b/packages/taquito/src/signer/interface.ts @@ -5,7 +5,7 @@ export interface Signer { /** * * @param op Operation to sign - * @param magicByte Magic bytes 11 for block, 12 for preendorsement, 13 for endorsements, 3 for generic, 5 for the PACK format of michelson + * @param magicByte Magic bytes 11 for block, 12 for preendorsement/preattestation, 13 for endorsements/attestation, 3 for generic, 5 for the PACK format of michelson */ sign( op: string, diff --git a/packages/taquito/src/subscribe/filters.ts b/packages/taquito/src/subscribe/filters.ts index eafc9db514..b2c95baa60 100644 --- a/packages/taquito/src/subscribe/filters.ts +++ b/packages/taquito/src/subscribe/filters.ts @@ -17,6 +17,8 @@ const opHashFilter = (op: OperationContent, filter: OpHashFilter) => op.hash === const sourceFilter = (x: OperationContent, filter: SourceFilter) => { switch (x.kind) { + case 'attestation': + return 'metadata' in x && x.metadata.delegate === filter.source; case 'endorsement': return 'metadata' in x && x.metadata.delegate === filter.source; case 'activate_account': diff --git a/packages/taquito/test/read-provider/data.ts b/packages/taquito/test/read-provider/data.ts index b2b6b4465c..c1704bfe40 100644 --- a/packages/taquito/test/read-provider/data.ts +++ b/packages/taquito/test/read-provider/data.ts @@ -11,36 +11,114 @@ export const constantsRpc = { max_micheline_node_count: 50000, max_micheline_bytes_limit: 50000, max_allowed_global_constants_depth: 10000, - cache_layout: [new BigNumber('100000000')], + cache_layout_size: 3, michelson_maximum_type_size: 2001, - preserved_cycles: 5, + smart_rollup_max_wrapped_proof_binary_size: 30000, + smart_rollup_message_size_limit: 4096, + smart_rollup_max_number_of_messages_per_level: '1000000', + preserved_cycles: 3, blocks_per_cycle: 8192, blocks_per_commitment: 64, - blocks_per_roll_snapshot: 512, - blocks_per_voting_period: 40960, - time_between_blocks: [new BigNumber('60'), new BigNumber('40')], - endorsers_per_block: 256, - hard_gas_limit_per_operation: new BigNumber('1040000'), - hard_gas_limit_per_block: new BigNumber('5200000'), - proof_of_work_threshold: new BigNumber('70368744177663'), - minimal_stake: new BigNumber('8000000000'), - seed_nonce_revelation_tip: new BigNumber('125000'), + nonce_revelation_threshold: 512, + blocks_per_stake_snapshot: 512, + cycles_per_voting_period: 1, + hard_gas_limit_per_operation: new BigNumber(1040000), + hard_gas_limit_per_block: new BigNumber(2600000), + proof_of_work_threshold: new BigNumber(-1), + minimal_stake: new BigNumber(6000000000), + minimal_frozen_stake: '600000000', + vdf_difficulty: new BigNumber(10000000000), origination_size: 257, - block_security_deposit: new BigNumber('640000000'), - endorsement_security_deposit: new BigNumber('2500000'), - baking_reward_per_endorsement: [new BigNumber('78125'), new BigNumber('11719')], - endorsement_reward: [new BigNumber('78125'), new BigNumber('52083')], - cost_per_byte: new BigNumber('250'), - hard_storage_limit_per_operation: new BigNumber('60000'), + issuance_weights: { + base_total_issued_per_minute: '85007812', + baking_reward_fixed_portion_weight: 5120, + baking_reward_bonus_weight: 5120, + attesting_reward_weight: 10240, + liquidity_baking_subsidy_weight: 1280, + seed_nonce_revelation_tip_weight: 1, + vdf_revelation_tip_weight: 1, + }, + cost_per_byte: new BigNumber(250), + hard_storage_limit_per_operation: new BigNumber(60000), quorum_min: 2000, quorum_max: 7000, min_proposal_quorum: 500, - initial_endorsers: 192, - delay_per_missing_endorsement: new BigNumber('4'), - minimal_block_delay: new BigNumber('30'), - liquidity_baking_subsidy: new BigNumber('2500000'), - liquidity_baking_sunset_level: 2244609, - liquidity_baking_escape_ema_threshold: 1000000, + liquidity_baking_toggle_ema_threshold: 1000000000, + max_operations_time_to_live: 240, + minimal_block_delay: new BigNumber(8), + delay_increment_per_round: new BigNumber(3), + consensus_committee_size: 7000, + consensus_threshold: 4667, + minimal_participation_ratio: { + numerator: 2, + denominator: 3, + }, + max_slashing_period: 2, + limit_of_delegation_over_baking: 9, + percentage_of_frozen_deposits_slashed_per_double_baking: 10, + percentage_of_frozen_deposits_slashed_per_double_attestation: 50, + testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8', + cache_script_size: 100000000, + cache_stake_distribution_cycles: 8, + cache_sampler_state_cycles: 8, + dal_parametric: { + feature_enable: false, + number_of_slots: 256, + attestation_lag: 4, + attestation_threshold: 50, + blocks_per_epoch: 8, + redundancy_factor: 16, + page_size: 4096, + slot_size: 1048576, + number_of_shards: 2048, + }, + smart_rollup_enable: true, + smart_rollup_arith_pvm_enable: false, + smart_rollup_origination_size: 6314, + smart_rollup_challenge_window_in_blocks: 40, + smart_rollup_stake_amount: '10000000000', + smart_rollup_commitment_period_in_blocks: 20, + smart_rollup_max_lookahead_in_blocks: 30000, + smart_rollup_max_active_outbox_levels: 20160, + smart_rollup_max_outbox_messages_per_level: 100, + smart_rollup_number_of_sections_in_dissection: 32, + smart_rollup_timeout_period_in_blocks: 500, + smart_rollup_max_number_of_cemented_commitments: 5, + smart_rollup_max_number_of_parallel_games: 32, + smart_rollup_reveal_activation_level: { + dal_page: 2147483646, + metadata: 0, + raw_data: { + Blake2B: 0, + }, + }, + zk_rollup_enable: false, + zk_rollup_origination_size: 4000, + zk_rollup_min_pending_to_process: 10, + zk_rollup_max_ticket_payload_size: 2048, + global_limit_of_staking_over_baking: 5, + edge_of_staking_over_delegation: 2, + adaptive_issuance_launch_ema_threshold: 100000000, + adaptive_rewards_params: { + issuance_ratio_min: { + numerator: '1', + denominator: '2000', + }, + issuance_ratio_max: { + numerator: '1', + denominator: '20', + }, + max_bonus: '50000000000000', + growth_rate: '115740740', + center_dz: { + numerator: '1', + denominator: '2', + }, + radius_dz: { + numerator: '1', + denominator: '50', + }, + }, }; export const contractCodeSample = [ diff --git a/packages/taquito/test/read-provider/rpc-read-adapter.spec.ts b/packages/taquito/test/read-provider/rpc-read-adapter.spec.ts index d28c5bfceb..2bf2ab1281 100644 --- a/packages/taquito/test/read-provider/rpc-read-adapter.spec.ts +++ b/packages/taquito/test/read-provider/rpc-read-adapter.spec.ts @@ -115,11 +115,11 @@ describe('RpcReadAdapter test', () => { const result = await readProvider.getProtocolConstants(block); expect(result).toEqual({ hard_gas_limit_per_operation: new BigNumber('1040000'), - hard_gas_limit_per_block: new BigNumber('5200000'), + hard_gas_limit_per_block: new BigNumber('2600000'), cost_per_byte: new BigNumber('250'), hard_storage_limit_per_operation: new BigNumber('60000'), - minimal_block_delay: new BigNumber('30'), - time_between_blocks: [new BigNumber('60'), new BigNumber('40')], + minimal_block_delay: new BigNumber('8'), + smart_rollup_origination_size: 6314, }); expect(mockRpcClient.getConstants.mock.calls[0][0]).toEqual({ block: `${block}` });