Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2599 oxford2 supports attestation #2775

Merged
merged 8 commits into from
Jan 5, 2024
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
"oxfordnet",
"oxheadalpha",
"Pkhfrom",
"preattestation",
"precommit",
"preendorsement",
"preendorsements",
"prevalidated",
"prevalidation",
"println",
Expand Down
2 changes: 1 addition & 1 deletion docs/consensus_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Consensus Keys
author: Davis Sawali & Hui-An Yang
---

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

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

Expand Down
6 changes: 5 additions & 1 deletion example/example-streamer-custom-retry-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ async function example() {
) as any
}));

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

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

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

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

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

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

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

sub.on('data', console.log)
Expand Down
81 changes: 41 additions & 40 deletions integration-tests/data/allTestsCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,18 @@ interface TestCase {
expected?: object;
}

export const nairobiCases: TestCase[] = [
export const oxfordCases: TestCase[] = [
{
name: 'Set deposits limit 1000000',
name: 'Attestation',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Unset deposits limit',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10'
kind: OpKind.ATTESTATION,
slot: 0,
level: 66299,
round: 5,
block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n',
},
],
},
Expand Down Expand Up @@ -134,6 +116,40 @@ export const commonCases: TestCase[] = [
],
},
},

{
name: 'Set deposits limit 1000000',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10',
limit: '1000000',
},
],
},
},
{
name: 'Unset deposits limit',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.SET_DEPOSITS_LIMIT,
counter: '1',
source: 'tz1QZ6KY7d3BuZDT1d19dUxoQrtFPN2QJ3hn',
fee: '10000',
gas_limit: '10',
storage_limit: '10'
},
],
},
},
{
name: 'Seed nonce revelation',
operation: {
Expand Down Expand Up @@ -1171,21 +1187,6 @@ export const commonCases: TestCase[] = [
],
},
},
{
name: 'Endorsement',
operation: {
branch: 'BLzyjjHKEKMULtvkpSHxuZxx6ei6fpntH2BTkYZiLgs8zLVstvX',
contents: [
{
kind: OpKind.ENDORSEMENT,
slot: 0,
level: 66299,
round: 5,
block_payload_hash: 'vh3FEkypvxUYLwjGYd2Sme7aWyfX8npDsqxcL6imVpBWnAZeNn2n',
},
],
},
},
{
name: `Origination of a contract that contains the instructions SUB_MUTEZ`,
operation: {
Expand Down
9 changes: 5 additions & 4 deletions integration-tests/local-forging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { CONFIGS } from "./config";
import { commonCases, nairobiCases } from './data/allTestsCases';
import { commonCases, oxfordCases } from './data/allTestsCases';
import { LocalForger, ProtocolsHash } from '@taquito/local-forging'
import { Protocols, TezosToolkit } from "@taquito/taquito";
import { ProtoGreaterOrEqual } from '@taquito/michel-codec'

CONFIGS().forEach(({ rpc, protocol }) => {
const Tezos = new TezosToolkit(rpc);
const nairobinet = protocol === Protocols.PtNairobi ? it : it.skip;
const oxfordAndAlpha = ProtoGreaterOrEqual(protocol, Protocols.ProxfordY) ? test : test.skip

describe(`Test local forger: ${rpc}`, () => {
// all protocols
nairobiCases.forEach(({ name, operation, expected }) => {
nairobinet(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => {
oxfordCases.forEach(({ name, operation, expected }) => {
oxfordAndAlpha(`Verify that .forge for local forge will return same result as for network forge for rpc: ${name} (${rpc})`, async () => {
const localForger = new LocalForger(protocol as unknown as ProtocolsHash);
const result = await localForger.forge(operation);
const rpcResult = await Tezos.rpc.forgeOperations(operation);
Expand Down
19 changes: 16 additions & 3 deletions integration-tests/rpc-nodes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CONFIGS().forEach(
}) => {
const Tezos = lib;
const unrestrictedRPCNode = rpc.endsWith("ecadinfra.com") ? test.skip : test;
const oxfordAndAlpha = ProtoGreaterOrEqual(protocol, Protocols.ProxfordY) ? test : test.skip
const unrestrictedOxfordAndAlpha = ProtoGreaterOrEqual(protocol, Protocols.ProxfordY) ? test : test.skip;
Copy link
Contributor

Choose a reason for hiding this comment

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

could you remind me what unrestricted is for again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

line24 should rename to oxfordAndAlpha, will update in next commit
answering unrestricted is for bakingRights, endorsingRights, attestationRights that usually are not accessible through public rpc node, but we have made it able to test with rpc url rpc.endsWith("ecadinfra.com")


let ticketContract: DefaultContractType;

Expand Down Expand Up @@ -166,6 +166,19 @@ CONFIGS().forEach(
expect(bakingRights[0].priority).toBeUndefined();
});

unrestrictedRPCNode('Verify that rpcClient.getAttestationRights retrieves the list of delegates allowed to attest a block', async () => {
const attestationRights = await rpcClient.getAttestationRights();
expect(attestationRights).toBeDefined();
expect(attestationRights[0].delegates).toBeDefined();
expect(attestationRights[0].delegates![0].delegate).toBeDefined();
expect(typeof attestationRights[0].delegates![0].delegate).toEqual('string');
expect(attestationRights[0].delegates![0].attestation_power).toBeDefined();
expect(typeof attestationRights[0].delegates![0].attestation_power).toEqual('number');
expect(attestationRights[0].delegates![0].first_slot).toBeDefined();
expect(typeof attestationRights[0].delegates![0].first_slot).toEqual('number');
expect(attestationRights[0].delegate).toBeUndefined();
});

unrestrictedRPCNode('Verify that rpcClient.getEndorsingRights retrieves the list of delegates allowed to endorse a block', async () => {
const endorsingRights = await rpcClient.getEndorsingRights();
expect(endorsingRights).toBeDefined();
Expand Down Expand Up @@ -448,7 +461,7 @@ CONFIGS().forEach(
});

it('Verify that rpcClient.getPendingOperations v1 will retrieve the pending operations in mempool with property applied', async () => {
const pendingOperations = await rpcClient.getPendingOperations({ version: '1'}) as PendingOperationsV1;
const pendingOperations = await rpcClient.getPendingOperations({ version: '1' }) as PendingOperationsV1;
expect(pendingOperations).toBeDefined();
expect(pendingOperations.applied).toBeInstanceOf(Array);
expect(pendingOperations.refused).toBeInstanceOf(Array);
Expand All @@ -457,7 +470,7 @@ CONFIGS().forEach(
expect(pendingOperations.branch_refused).toBeInstanceOf(Array);
});

oxfordAndAlpha('Verify that rpcClient.getPendingOperations v2 will retrieve the pending operations in mempool with property validated', async () => {
unrestrictedOxfordAndAlpha('Verify that rpcClient.getPendingOperations v2 will retrieve the pending operations in mempool with property validated', async () => {
const pendingOperations = await rpcClient.getPendingOperations({ version: '2' }) as PendingOperationsV2;
expect(pendingOperations).toBeDefined();
expect(pendingOperations.validated).toBeInstanceOf(Array);
Expand Down
8 changes: 8 additions & 0 deletions packages/taquito-contracts-library/src/rpc-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
DelegateResponse,
DelegatesResponse,
VotingInfoResponse,
AttestationRightsQueryArguments,
AttestationRightsResponse,
EndorsingRightsQueryArguments,
EndorsingRightsResponse,
EntrypointsResponse,
Expand Down Expand Up @@ -172,6 +174,12 @@ export class RpcWrapperContractsLibrary implements RpcClientInterface {
): Promise<BakingRightsResponse> {
return this.rpc.getBakingRights(args, { block });
}
async getAttestationRights(
args: AttestationRightsQueryArguments,
{ block }: RPCOptions = defaultRPCOptions
): Promise<AttestationRightsResponse> {
return this.rpc.getAttestationRights(args, { block });
}
async getEndorsingRights(
args: EndorsingRightsQueryArguments,
{ block }: RPCOptions = defaultRPCOptions
Expand Down
3 changes: 2 additions & 1 deletion packages/taquito-local-forging/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -236,7 +237,7 @@ export const kindMapping: { [key: number]: string } = {
0x6c: 'transaction',
0x6d: 'origination',
0x06: 'ballot',
0x15: 'endorsement',
0x15: 'attestation',
hui-an-yang marked this conversation as resolved.
Show resolved Hide resolved
0x01: 'seed_nonce_revelation',
0x05: 'proposals',
0x6f: 'register_global_constant',
Expand Down
3 changes: 3 additions & 0 deletions packages/taquito-local-forging/src/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
ActivationSchema,
BallotSchema,
DelegationSchema,
AttestationSchema,
EndorsementSchema,
IncreasePaidStorageSchema,
UpdateConsensusKeySchema,
Expand Down Expand Up @@ -97,6 +98,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) =>
Expand Down
2 changes: 2 additions & 0 deletions packages/taquito-local-forging/src/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
ActivationSchema,
BallotSchema,
DelegationSchema,
AttestationSchema,
EndorsementSchema,
IncreasePaidStorageSchema,
UpdateConsensusKeySchema,
Expand Down Expand Up @@ -89,6 +90,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);
Expand Down
7 changes: 7 additions & 0 deletions packages/taquito-local-forging/src/schema/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions packages/taquito-local-forging/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ProposalsSchema,
RevealSchema,
RegisterGlobalConstantSchema,
AttestationSchema,
EndorsementSchema,
TransferTicketSchema,
IncreasePaidStorageSchema,
Expand All @@ -29,6 +30,7 @@ type OperationKind =
| OpKind.TRANSACTION
| OpKind.ORIGINATION
| OpKind.BALLOT
| OpKind.ATTESTATION
| OpKind.ENDORSEMENT
| OpKind.SEED_NONCE_REVELATION
| OpKind.PROPOSALS
Expand All @@ -49,6 +51,7 @@ const OperationKindMapping = {
transaction: TransactionSchema,
origination: OriginationSchema,
ballot: BallotSchema,
attestation: AttestationSchema,
endorsement: EndorsementSchema,
seed_nonce_revelation: SeedNonceRevelationSchema,
proposals: ProposalsSchema,
Expand Down
5 changes: 5 additions & 0 deletions packages/taquito-rpc/src/opkind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 7 additions & 0 deletions packages/taquito-rpc/src/rpc-client-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
CurrentQuorumResponse,
DelegateResponse,
DelegatesResponse,
AttestationRightsQueryArguments,
AttestationRightsResponse,
EndorsingRightsQueryArguments,
EndorsingRightsResponse,
EntrypointsResponse,
Expand Down Expand Up @@ -84,6 +86,10 @@ export interface RpcClientInterface {
args: BakingRightsQueryArguments,
options?: RPCOptions
): Promise<BakingRightsResponse>;
getAttestationRights(
args: AttestationRightsQueryArguments,
options?: RPCOptions
): Promise<AttestationRightsResponse>;
getEndorsingRights(
args: EndorsingRightsQueryArguments,
options?: RPCOptions
Expand Down Expand Up @@ -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',
Expand Down
Loading
Loading