From d3ae08f3d567cacc81c1d54d15268d82a2ca71fd Mon Sep 17 00:00:00 2001 From: huianyang Date: Thu, 12 Dec 2024 14:41:51 -0800 Subject: [PATCH] fix: fix prepareProvier ballot and proposal bug and add sandbox test back --- .github/workflows/main.yml | 29 +++- cspell.json | 2 + .../flextesa/sandbox-ballot-operation.spec.ts | 83 ------------ .../sandbox-drain-delegate-operation.spec.ts | 63 --------- .../sandbox-drain-delegate-operation.spec.ts | 85 ++++++++++++ ...dbox-proposal-and-ballot-operation.spec.ts | 104 ++++++++++++++ integration-tests/package.json | 1 + .../sandbox-override-parameters.hjson | 128 ++++++++++++++++++ package-lock.json | 34 +---- packages/taquito/src/operations/types.ts | 2 + .../taquito/src/prepare/prepare-provider.ts | 8 +- .../test/prepare/prepare-provider.spec.ts | 2 + 12 files changed, 359 insertions(+), 182 deletions(-) delete mode 100644 integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts delete mode 100644 integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts create mode 100644 integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts create mode 100644 integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts create mode 100644 integration-tests/sandbox-override-parameters.hjson diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1b8ddde52..77e8bfe54e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: matrix: node: - 'lts/iron' - - '22' + - lts/hydrogen steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: lts/iron + node-version: lts/hydrogen - run: npm ci - run: npm run build - if: ${{ !github.event.pull_request.head.repo.fork }} @@ -62,3 +62,28 @@ jobs: env: # Ternary operator workaround TEZOS_RPC_${{ matrix.testnet_uppercase }}: ${{ github.event.pull_request.head.repo.fork && format('https://{0}.ecadinfra.com', matrix.testnet) || null }} + + integration-tests-tezbox: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + include: + - testnet: parisnet + testnet_uppercase: PARISNET + flextesa_docker_image: + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/hydrogen + - name: Provision Tezbox ${{ matrix.testnet }} container + run: npm -w integration-tests run sandbox:${{ matrix.testnet }} + - run: npm ci + - run: npm run build + - run: npm -w integration-tests run test __tests__/tezbox/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts + env: + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 + - run: npm -w integration-tests run test __tests__/tezbox/sandbox-drain-delegate-operation.spec + env: + TEZOS_RPC_${{ matrix.testnet_uppercase }}: http://localhost:8732 diff --git a/cspell.json b/cspell.json index 4d32d01c48..96d9172df5 100644 --- a/cspell.json +++ b/cspell.json @@ -105,6 +105,8 @@ "tcli", "testbox", "testchain", + "tezbox", + "tezboxnet", "tezbridge", "tezos", "Thanos", diff --git a/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts b/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts deleted file mode 100644 index 30e469917b..0000000000 --- a/integration-tests/__tests__/flextesa/sandbox-ballot-operation.spec.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This test is not being run by any runner, - * will keep for future reference if an alternative sandbox is available - */ - -import { VotingPeriodBlockResult } from '@taquito/rpc'; -import { InMemorySigner } from '@taquito/signer'; -import { TezosToolkit } from '@taquito/taquito'; -import { CONFIGS, isSandbox, sleep } from '../../config'; - -CONFIGS().forEach(async ({ lib, rpc, protocol, setup }) => { - const flextesanet = isSandbox({ rpc }) ? test : test.skip; - let blocksPerVotingPeriod: number; - let blockTime: number; - let currentPeriod: VotingPeriodBlockResult; - - // Our ci flextesa script have 3 bakers Alice, Bob and Charlie (.github/workflows/main.yml) - const Alice = lib; // Alice's secret key is passed through the command to run test is configured by integration-tests/config.ts - const Bob = new TezosToolkit(rpc); - Bob.setSignerProvider(new InMemorySigner('edsk3RFfvaFaxbHx8BMtEW1rKQcPtDML3LXjNqMNLCzC3wLC1bWbAt')); - const Charlie = new TezosToolkit(rpc); - Charlie.setSignerProvider(new InMemorySigner('edsk3RgWvbKKA1atEUcaGwivge7QtckHkTL9nQJUXQKY5r8WKp4pF4')); - - describe(`Test Proposal and Ballot operation in ${protocol.substring(0, 8)} with flextesa`, () => { - beforeAll(async () => { - await setup(); - let constants = await Alice.rpc.getConstants(); - blocksPerVotingPeriod = constants.blocks_per_cycle * constants.cycles_per_voting_period!; - blockTime = constants.minimal_block_delay!.toNumber(); - }); - - flextesanet('Should be able to inject proposal operation in proposal period', async () => { - - // double check if it's proposal period so that we can inject proposal operation - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'proposal') { - const proposalsOp = await Alice.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await proposalsOp.confirmation(); - - expect(proposalsOp.operationResults).toBeDefined(); - expect(proposalsOp.operationResults?.kind).toEqual('proposals'); - expect(proposalsOp.operationResults?.proposals).toEqual(['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK']); - expect(proposalsOp.includedInBlock).toBeDefined(); - expect(proposalsOp.hash).toBeDefined(); - - // injecting 2 more proposals from baker Bob and Charlie to reach above quorum - const BobOp = await Bob.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await BobOp.confirmation(); - const CharlieOp = await Charlie.contract.proposals({ - proposals: ['ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'] - }); - await CharlieOp.confirmation(); - } - }); - - flextesanet('Should be able to inject ballot operation in exploration period', async () => { - // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'proposal') { - await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) - }; - currentPeriod = await Alice.rpc.getCurrentPeriod(); - if (currentPeriod.voting_period.kind === 'exploration') { - const explorationBallotOp = await Alice.contract.ballot({ - proposal: 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK', - ballot: 'yay' - }); - await explorationBallotOp.confirmation(); - - expect(explorationBallotOp.operationResults).toBeDefined(); - expect(explorationBallotOp.operationResults?.kind).toEqual('ballot'); - expect(explorationBallotOp.operationResults?.proposal).toEqual('ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'); - expect(explorationBallotOp.operationResults?.ballot).toEqual('yay'); - expect(explorationBallotOp.includedInBlock).toBeDefined(); - expect(explorationBallotOp.hash).toBeDefined(); - } - }); - }); -}); diff --git a/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts b/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts deleted file mode 100644 index ae46c94696..0000000000 --- a/integration-tests/__tests__/flextesa/sandbox-drain-delegate-operation.spec.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This test is not being run by any runner, - * will keep for future reference if an alternative sandbox is available - */ - -import { TezosToolkit } from "@taquito/taquito"; -import { CONFIGS, sleep, isSandbox } from "../../config"; - -CONFIGS().forEach(({ lib, rpc, protocol, setup, createAddress }) => { - const Tezos = lib; - const flextesanet = isSandbox({ rpc }) ? test : test.skip; - - describe(`Test Drain Delegate in ${protocol}`, () => { - let Delegate: TezosToolkit; - let delegatePkh: string; - let Destination: TezosToolkit; - let destinationPkh: string; - beforeAll(async () => { - await setup(); - - try { - Delegate = await createAddress(); - delegatePkh = await Delegate.signer.publicKeyHash();; - Destination = await createAddress(); - destinationPkh = await Destination.signer.publicKeyHash(); - - // fund the delegate - const transferOp = await Tezos.contract.transfer({ to: delegatePkh, amount: 5 }); - await transferOp.confirmation(); - - // register as delegate - const registerOp = await Delegate.contract.registerDelegate({}); - await registerOp.confirmation(); - - // update consensus key to destination - const updateOp = await Delegate.contract.updateConsensusKey({ pk: await Destination.signer.publicKey() }); - await updateOp.confirmation(); - - // wait for more than preserved_cycles + 1 for consensus_key to be active - const constants = await Delegate.rpc.getConstants(); - await sleep(((constants.preserved_cycles + 2) * constants.blocks_per_cycle * (constants.minimal_block_delay!.toNumber())) * 1000); - - } catch (e) { - console.log(JSON.stringify(e)); - } - }) - flextesanet('Should be able to inject drain_delegate operation', async () => { - expect((await Delegate.rpc.getBalance(delegatePkh)).toNumber()).toBeGreaterThan(0); - let destinationBalanceBefore = (await Destination.rpc.getBalance(destinationPkh)).toNumber(); - - const drainOp = await Destination.contract.drainDelegate({ - consensus_key: destinationPkh, - delegate: delegatePkh, - destination: destinationPkh, - }); - await drainOp.confirmation(); - - expect(drainOp.includedInBlock).toBeDefined() - expect((await Delegate.rpc.getBalance(delegatePkh)).toNumber()).toEqual(0); - expect((await Destination.rpc.getBalance(destinationPkh)).toNumber()).toBeGreaterThan(destinationBalanceBefore); - }); - }); -}) diff --git a/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts new file mode 100644 index 0000000000..0d4523928e --- /dev/null +++ b/integration-tests/__tests__/tezbox/sandbox-drain-delegate-operation.spec.ts @@ -0,0 +1,85 @@ +import { CONFIGS, sleep, isSandbox } from "../../config"; +import { TezosToolkit } from "@taquito/taquito"; +import { InMemorySigner } from '@taquito/signer'; +import { OperationContentsAndResultDrainDelegate } from '@taquito/rpc'; + +CONFIGS().forEach(({ rpc, protocol, createAddress }) => { + const tezboxnet = isSandbox({ rpc }) ? test : test.skip; + const alice = new TezosToolkit(rpc); + let alicePkh: string; + let delegate: TezosToolkit; + let delegatePkh: string; + let destination: TezosToolkit; + let destinationPkh: string; + + describe(`Test Drain Delegate in ${protocol.substring(0, 8)}`, () => { + beforeAll(async () => { + // tezbox provision Alice account with balance, ref https://github.com/tez-capital/tezbox/blob/main/configuration/accounts.hjson + alice.setSignerProvider(new InMemorySigner('edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq')); + alicePkh = await alice.signer.publicKeyHash(); + delegate = await createAddress(); + delegatePkh = await delegate.signer.publicKeyHash();; + destination = await createAddress(); + destinationPkh = await destination.signer.publicKeyHash(); + // fund the delegate + const transferOp = await alice.contract.transfer({ to: delegatePkh, amount: 5 }); + await transferOp.confirmation(); + // register as delegate + const registerOp = await delegate.contract.registerDelegate({}); + await registerOp.confirmation(); + // update consensus key to destination + const updateOp = await delegate.contract.updateConsensusKey({ pk: await destination.signer.publicKey() }); + await updateOp.confirmation(); + }) + + tezboxnet('Should be able to prepare drainDelegate operations accepted by preapply endpoint', async () => { + // wait for more than preserved_cycles + 1 for consensus_key to be active to perform drainDelegate operation + const constants = await alice.rpc.getConstants(); + await sleep(((constants.consensus_rights_delay + 2) * (constants.blocks_per_cycle) * (constants.minimal_block_delay!.toNumber())) * 1000); + + const drainPrepared = await destination.prepare.drainDelegate({ + consensus_key: destinationPkh, + delegate: delegatePkh, + destination: destinationPkh, + }) + const drainPreapplied = await destination.rpc.preapplyOperations(await destination.prepare.toPreapply(drainPrepared)); + + expect(drainPreapplied).toBeInstanceOf(Array) + expect(drainPreapplied[0].contents).toBeInstanceOf(Array) + expect(drainPreapplied[0].contents[0].kind).toEqual('drain_delegate') + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).consensus_key).toEqual(destinationPkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).delegate).toEqual(delegatePkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).destination).toEqual(destinationPkh) + expect((drainPreapplied[0].contents[0] as OperationContentsAndResultDrainDelegate).metadata).toBeDefined() + }); + tezboxnet('Should be able to inject drain_delegate operation', async () => { + // get the delegate and destination balance before drainDelegate operation + let delegateBeforeBalance = (await delegate.rpc.getBalance(delegatePkh)).toNumber() + let destinationBeforeBalance = (await destination.rpc.getBalance(destinationPkh)).toNumber(); + + const drainOp = await destination.contract.drainDelegate({ + consensus_key: destinationPkh, + delegate: delegatePkh, + destination: destinationPkh, + }); + await drainOp.confirmation(); + + // get the delegate and destination balance after drainDelegate operation + let delegateAfterBalance = (await destination.rpc.getBalance(delegatePkh)).toNumber() + let destinationAfterBalance = (await destination.rpc.getBalance(destinationPkh)).toNumber() + + expect(drainOp.includedInBlock).toBeDefined() + expect(drainOp.status).toBeDefined() + expect(drainOp.hash).toBeDefined() + expect(drainOp.operationResults).toBeDefined() + expect(drainOp.consensusKey).toEqual(destinationPkh) + expect(drainOp.delegate).toEqual(delegatePkh) + expect(drainOp.destination).toEqual(destinationPkh) + + expect(delegateBeforeBalance).toBeGreaterThan(0); + expect(delegateAfterBalance).toBe(0); + expect(destinationBeforeBalance).toBe(0); + expect(destinationAfterBalance).toBeGreaterThan(0); + }); + }); +}) diff --git a/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts new file mode 100644 index 0000000000..f1376734ac --- /dev/null +++ b/integration-tests/__tests__/tezbox/sandbox-proposal-and-ballot-operation.spec.ts @@ -0,0 +1,104 @@ +import { CONFIGS, isSandbox, sleep } from '../../config'; +import { TezosToolkit } from '@taquito/taquito'; +import { InMemorySigner } from '@taquito/signer'; +import { OperationContentsAndResultBallot, OperationContentsAndResultProposals, VotingPeriodBlockResult, OperationContentsProposals } from '@taquito/rpc'; + +CONFIGS().forEach(async ({ rpc, protocol }) => { + const tezboxnet = isSandbox({ rpc }) ? test : test.skip; + const baker1 = new TezosToolkit(rpc); + const baker2 = new TezosToolkit(rpc); + const baker3 = new TezosToolkit(rpc); + const proposal = 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK'; + const ballot = 'yay'; + let blockTime: number + let currentPeriod: VotingPeriodBlockResult; + + describe(`Test Proposal and Ballot operation in ${protocol.substring(0, 8)} with tezbox`, () => { + beforeAll(async () => { + // tezbox provision of 3 bakers, ref https://github.com/tez-capital/tezbox/blob/main/configuration/bakers.hjson + baker1.setSignerProvider(new InMemorySigner('edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ')); + baker2.setSignerProvider(new InMemorySigner('edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo')); + baker3.setSignerProvider(new InMemorySigner('edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3')); + + // get block time from protocol constants + const constants = await baker1.rpc.getConstants(); + blockTime = constants.minimal_block_delay!.toNumber(); + }); + + tezboxnet('Should be able to prepare proposal accepted by preapply endpoint', async () => { + // check if it's in proposal period to start proposal test + currentPeriod = await baker1.rpc.getCurrentPeriod(); + while (currentPeriod.voting_period.kind !== 'proposal') { + await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) + currentPeriod = await baker1.rpc.getCurrentPeriod() + } + + const proposalPrepared = await baker1.prepare.proposals({ proposals: [proposal] }); + const proposalPreapplied = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(proposalPrepared)); + + expect(proposalPreapplied).toBeInstanceOf(Array); + expect(proposalPreapplied[0].contents).toBeInstanceOf(Array); + expect(proposalPreapplied[0].contents[0].kind).toBe('proposals'); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).source).toBe(await baker1.signer.publicKeyHash()); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).period).toBe((proposalPrepared.opOb.contents[0] as OperationContentsProposals).period); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals).toBeInstanceOf(Array); + expect((proposalPreapplied[0].contents[0] as OperationContentsAndResultProposals).proposals[0]).toEqual(proposal); + }); + + tezboxnet('Should be able to inject proposal operation in proposal period', async () => { + const proposalsOp = await baker1.contract.proposals({ + proposals: [proposal] + }); + await proposalsOp.confirmation(); + + expect(proposalsOp.includedInBlock).toBeDefined(); + expect(proposalsOp.status).toBeDefined(); + expect(proposalsOp.hash).toBeDefined(); + expect(proposalsOp.operationResults).toBeDefined(); + expect(proposalsOp.proposals).toEqual([proposal]); + expect(proposalsOp.period).toBeDefined(); + + // injecting 2 more proposals from baker baker2 and baker3 to reach above quorum + const baker2Op = await baker2.contract.proposals({ proposals: [proposal] }); + await baker2Op.confirmation(); + expect(baker2Op.includedInBlock).toBeDefined(); + const baker3Op = await baker3.contract.proposals({ proposals: [proposal] }); + await baker3Op.confirmation(); + expect(baker3Op.includedInBlock).toBeDefined(); + }); + + tezboxnet('Should be able to prepare ballot operations accepted by preapply endpoint', async () => { + // if it's still proposal period make the test sleep to get into exploration period to inject ballot operation + while (currentPeriod.voting_period.kind !== 'exploration') { + await sleep(((currentPeriod.remaining + 1) * blockTime) * 1000) + currentPeriod = await baker1.rpc.getCurrentPeriod() + } + + const ballotPrepared = await baker1.prepare.ballot({ proposal, ballot }); + const preappliedBallot = await baker1.rpc.preapplyOperations(await baker1.prepare.toPreapply(ballotPrepared)); + + expect(preappliedBallot).toBeInstanceOf(Array); + expect(preappliedBallot[0].contents).toBeInstanceOf(Array); + expect(preappliedBallot[0].contents[0].kind).toEqual('ballot'); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).source).toEqual(await baker1.signer.publicKeyHash()); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).proposal).toEqual(proposal); + expect((preappliedBallot[0].contents[0] as OperationContentsAndResultBallot).ballot).toEqual(ballot); + }); + + tezboxnet('Should be able to inject ballot operation in exploration period', async () => { + const explorationBallotOp = await baker1.contract.ballot({ + proposal, + ballot + }); + await explorationBallotOp.confirmation(); + + expect(explorationBallotOp.includedInBlock).toBeDefined(); + expect(explorationBallotOp.status).toBeDefined(); + expect(explorationBallotOp.hash).toBeDefined(); + expect(explorationBallotOp.operationResults).toBeDefined(); + expect(explorationBallotOp.proposal).toBe(proposal); + expect(explorationBallotOp.period).toBeDefined(); + expect(explorationBallotOp.ballot).toBe(ballot); + }); + }); +}); diff --git a/integration-tests/package.json b/integration-tests/package.json index 54beb40b45..a1e7cc7d57 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -10,6 +10,7 @@ "test:weeklynet-secret-key": "RUN_WEEKLYNET_WITH_SECRET_KEY=true jest --runInBand", "test:ghostnet": "GHOSTNET=true jest", "test:ghostnet-secret-key": "RUN_GHOSTNET_WITH_SECRET_KEY=true jest --runInBand", + "sandbox:parisnet": "docker run -d -p 0.0.0.0:8732:8732 -v $(pwd)/sandbox-override-parameters.hjson:/tezbox/configuration/protocols/PsParisC/sandbox-parameters.hjson --name sandbox ghcr.io/tez-capital/tezbox:tezos-v21.0 parisbox", "originate-known-contracts": "node -r ts-node/register originate-known-contracts.ts", "originate-known-contracts-and-run-test": "node -r ts-node/register originate-known-contracts.ts && jest" }, diff --git a/integration-tests/sandbox-override-parameters.hjson b/integration-tests/sandbox-override-parameters.hjson new file mode 100644 index 0000000000..8f4dbf9354 --- /dev/null +++ b/integration-tests/sandbox-override-parameters.hjson @@ -0,0 +1,128 @@ +{ + "consensus_rights_delay": 1, + "blocks_preservation_cycles": 1, + "delegate_parameters_activation_delay": 3, + "blocks_per_cycle": 10, + "blocks_per_commitment": 15, + "nonce_revelation_threshold": 5, + "cycles_per_voting_period": 1, + "hard_gas_limit_per_operation": "1040000", + "hard_gas_limit_per_block": "1733333", + "proof_of_work_threshold": "281474976710655", + "minimal_stake": "6000000000", + "minimal_frozen_stake": "600000000", + "vdf_difficulty": "10000000000", + "origination_size": 257, + "issuance_weights": { + "base_total_issued_per_minute": "80007812", + "baking_reward_fixed_portion_weight": 5120, + "baking_reward_bonus_weight": 5120, + "attesting_reward_weight": 10240, + "seed_nonce_revelation_tip_weight": 1, + "vdf_revelation_tip_weight": 1 + }, + "cost_per_byte": "250", + "hard_storage_limit_per_operation": "60000", + "quorum_min": 2000, + "quorum_max": 7000, + "min_proposal_quorum": 500, + "liquidity_baking_subsidy": "5000000", + "liquidity_baking_toggle_ema_threshold": 1000000000, + "max_operations_time_to_live": 360, + "minimal_block_delay": "1", + "delay_increment_per_round": "2", + "consensus_committee_size": 7000, + "consensus_threshold": 4667, + "minimal_participation_ratio": { + "numerator": 2, + "denominator": 3 + }, + "limit_of_delegation_over_baking": 9, + "percentage_of_frozen_deposits_slashed_per_double_baking": 500, + "percentage_of_frozen_deposits_slashed_per_double_attestation": 5000, + "max_slashing_per_block": 10000, + "max_slashing_threshold": 2334, + "testnet_dictator": "tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8", + "cache_script_size": 100000000, + "cache_stake_distribution_cycles": 8, + "cache_sampler_state_cycles": 8, + "dal_parametric": { + "feature_enable": true, + "incentives_enable": false, + "number_of_slots": 32, + "attestation_lag": 8, + "attestation_threshold": 66, + "redundancy_factor": 8, + "page_size": 3967, + "slot_size": 126944, + "number_of_shards": 512 + }, + "smart_rollup_arith_pvm_enable": false, + "smart_rollup_origination_size": 6314, + "smart_rollup_challenge_window_in_blocks": 241920, + "smart_rollup_stake_amount": "10000000000", + "smart_rollup_commitment_period_in_blocks": 180, + "smart_rollup_max_lookahead_in_blocks": 518400, + "smart_rollup_max_active_outbox_levels": 241920, + "smart_rollup_max_outbox_messages_per_level": 100, + "smart_rollup_number_of_sections_in_dissection": 32, + "smart_rollup_timeout_period_in_blocks": 120960, + "smart_rollup_max_number_of_cemented_commitments": 5, + "smart_rollup_max_number_of_parallel_games": 32, + "smart_rollup_reveal_activation_level": { + "raw_data": { + "Blake2B": 0 + }, + "metadata": 0, + "dal_page": 6422529, + "dal_parameters": 6422529, + "dal_attested_slots_validity_lag": 241920 + }, + "smart_rollup_private_enable": true, + "smart_rollup_riscv_pvm_enable": false, + "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": 0, + "adaptive_rewards_params": { + "issuance_ratio_final_min": { + "numerator": "1", + "denominator": "400" + }, + "issuance_ratio_final_max": { + "numerator": "1", + "denominator": "10" + }, + "issuance_ratio_initial_min": { + "numerator": "9", + "denominator": "200" + }, + "issuance_ratio_initial_max": { + "numerator": "11", + "denominator": "200" + }, + "initial_period": 10, + "transition_period": 50, + "max_bonus": "50000000000000", + "growth_rate": { + "numerator": "1", + "denominator": "100" + }, + "center_dz": { + "numerator": "1", + "denominator": "2" + }, + "radius_dz": { + "numerator": "1", + "denominator": "50" + } + }, + "adaptive_issuance_activation_vote_enable": true, + "autostaking_enable": true, + "adaptive_issuance_force_activation": false, + "ns_enable": true, + "direct_ticket_spending_enable": false +} diff --git a/package-lock.json b/package-lock.json index c1936b4ffd..244a6a1df4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "taquito", "workspaces": [ "packages/*", "packages/taquito-michel-codec/pack-test-tool", @@ -3612,27 +3613,6 @@ "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", "license": "MIT" }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic": { - "version": "6.6.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", - "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", - "license": "MIT", - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "license": "MIT" - }, "node_modules/@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -12098,9 +12078,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -21018,9 +20998,9 @@ "license": "ISC" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { diff --git a/packages/taquito/src/operations/types.ts b/packages/taquito/src/operations/types.ts index e6f860ad4f..eea7f06573 100644 --- a/packages/taquito/src/operations/types.ts +++ b/packages/taquito/src/operations/types.ts @@ -67,6 +67,8 @@ export type RPCOpWithFee = | RPCSmartRollupOutboxMessageOperation; export type RPCOpWithSource = + | RPCBallotOperation + | RPCProposalsOperation | RPCTransferOperation | RPCOriginationOperation | RPCDelegateOperation diff --git a/packages/taquito/src/prepare/prepare-provider.ts b/packages/taquito/src/prepare/prepare-provider.ts index 1989137e74..ffa59b6de5 100644 --- a/packages/taquito/src/prepare/prepare-provider.ts +++ b/packages/taquito/src/prepare/prepare-provider.ts @@ -269,19 +269,13 @@ export class PrepareProvider extends Provider implements PreparationProvider { ...this.getFee(op, pkh, headCounter), }; case OpKind.BALLOT: - if (currentVotingPeriod === undefined) { - throw new RPCResponseError(`Failed to get the current voting period index`); - } - return { - ...op, - period: currentVotingPeriod?.voting_period.index, - }; case OpKind.PROPOSALS: if (currentVotingPeriod === undefined) { throw new RPCResponseError(`Failed to get the current voting period index`); } return { ...op, + ...this.getSource(op, pkh, source), period: currentVotingPeriod?.voting_period.index, }; default: diff --git a/packages/taquito/test/prepare/prepare-provider.spec.ts b/packages/taquito/test/prepare/prepare-provider.spec.ts index 89b4d309cf..a01842f23f 100644 --- a/packages/taquito/test/prepare/prepare-provider.spec.ts +++ b/packages/taquito/test/prepare/prepare-provider.spec.ts @@ -970,6 +970,7 @@ describe('PrepareProvider test', () => { kind: 'ballot', period: 103, proposal: 'PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg', + source: 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', }, ], protocol: 'test_protocol', @@ -1018,6 +1019,7 @@ describe('PrepareProvider test', () => { kind: 'proposals', period: 103, proposals: ['PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg'], + source: 'tz1gvF4cD2dDtqitL3ZTraggSR1Mju2BKFEM', }, ], protocol: 'test_protocol',