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

Rework Worker api and make it work against recent integritee-worker (aka tls directly into the enclave) #89

Merged
merged 41 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5c70bd2
[worker] test simple websocket connection
clangenb Mar 29, 2024
e7ba030
[jest] allow any kind of certificate
clangenb Mar 29, 2024
8d32315
[worker] update get balance to just get regular balance of incognito …
clangenb Mar 29, 2024
e49ed8a
[network] update localDockerNetwork to be correct
clangenb Mar 29, 2024
3768996
[worker.spec] successfully connect to the worker.
clangenb Apr 2, 2024
9b75854
Revert "[worker.spec] successfully connect to the worker."
clangenb Apr 2, 2024
641858a
[worker.spec] connect to worker with original implementation; protoco…
clangenb Apr 5, 2024
a5a2222
[worker] implement new trusted rpc protocol and successfully fetch th…
clangenb Apr 5, 2024
4125540
[worker.spec] remove primitive websocket test
clangenb Apr 5, 2024
f0409f1
[worker.spec] separate tests for encointer-specific protocol
clangenb Apr 5, 2024
32dba38
[worker] successfully get free balance of an account
clangenb Apr 6, 2024
3d4e352
[worker] implement getting shard vault
clangenb Apr 6, 2024
b7f3b26
[worker] fix return value parsing in generic cases
clangenb Apr 6, 2024
767b5d8
[worker] refactor request creation into its own file
clangenb Apr 6, 2024
de9c307
[worker] rename getter api to sendRequest
clangenb Apr 6, 2024
1461d73
[worker] update public getter
clangenb Apr 6, 2024
992cfea
[worker] rename callGetter to sendRequest
clangenb Apr 6, 2024
86a9af5
[worker] more explicit naming
clangenb Apr 6, 2024
1966fe9
[worker] implement draft of trusted call balance transfer, (getting n…
clangenb Apr 6, 2024
efb5ff8
[worker] fix getting nonce by using toHex instead of to u8a
clangenb Apr 6, 2024
b1b5c6e
[worker] fix signature type in trusted calls/getters
clangenb Apr 6, 2024
7773a51
[worker] fix interpreting the result of getters
clangenb Apr 6, 2024
187075e
[worker] fix signature of trusted call
clangenb Apr 6, 2024
e13865a
[worker] try to encrypt the trusted call upon sending
clangenb Apr 6, 2024
7efd96a
[worker] introduce trusted operation
clangenb Apr 8, 2024
f1e8790
[worker] fix encryption
clangenb Apr 8, 2024
90e2c4f
[worker] add comment for node-rsa setting
clangenb Apr 8, 2024
13066b5
[worker] successfully send a top to the worker.
clangenb Apr 8, 2024
823659d
[worker] better doc
clangenb Apr 8, 2024
46f550d
[worker] fix sending trusted calls with `author_submitExtrinsic`
clangenb Apr 8, 2024
e22849b
[jest] remove tls certificate config that didn't work
clangenb Apr 8, 2024
911ca61
[jest] remove tls certificate config that didn't work
clangenb Apr 8, 2024
29473cc
[worker] implement balance_unshield trusted call
clangenb Apr 8, 2024
a9fa8a0
[worker] use charlie in tests
clangenb Apr 10, 2024
c1068af
[worker] rename interface IEncointerWorker to IIntegriteeWorker
clangenb Apr 10, 2024
aa14787
[worker] separate encointer from integritee worker
clangenb Apr 10, 2024
6a846f3
[worker] finalize separation of workers
clangenb Apr 10, 2024
57ab509
[worker] separate types of integritee and encointer
clangenb Apr 10, 2024
2c11c03
[worker] fix unused imports in encointer worker
clangenb Apr 10, 2024
f21fad8
[worker] skip CI that needs a worker
clangenb Apr 10, 2024
ab2e0d8
[worker] add todo for encointer worker
clangenb Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions packages/types/src/interfaces/augment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import type { BusinessData, BusinessIdentifier, OfferingData, OfferingIdentifier
import type { Assignment, AssignmentCount, AssignmentParams, Attestation, AttestationIndexType, CeremonyIndexType, CeremonyPhaseType, ClaimOfAttendance, ClaimOfAttendanceSigningPayload, CommunityCeremonyStats, CommunityReputation, Meetup, MeetupAssignment, MeetupIndexType, MeetupResult, MeetupTimeOffsetType, ParticipantIndexType, ParticipantRegistration, ProofOfAttendance, RegistrationType, Reputation } from '@encointer/types/interfaces/ceremony';
import type { FixedI64F64, IpfsCid, PalletString } from '@encointer/types/interfaces/common';
import type { AnnouncementSigner, Bip340, CidDigest, CidName, CommunityCeremony, CommunityIdentifier, CommunityMetadataType, CommunityRules, DegreeFixed, DegreeRpc, GeoHash, Location, LocationRpc, NominalIncomeType } from '@encointer/types/interfaces/community';
import type { EncointerBalanceTransferArgs, EncointerGetter, EncointerGetterArgs, EncointerPublicGetter, EncointerTrustedCall, EncointerTrustedCallSigned, EncointerTrustedGetter, EncointerTrustedGetterSigned, GrantReputationArgs, RegisterAttestationsArgs, RegisterParticipantArgs } from '@encointer/types/interfaces/encointerWorker';
import type { BalanceSetBalanceArgs, BalanceShieldArgs, BalanceTransferArgs, BalanceUnshieldArgs, IntegriteeGetter, IntegriteePublicGetter, IntegriteeTrustedCall, IntegriteeTrustedCallSigned, IntegriteeTrustedGetter, IntegriteeTrustedGetterSigned, IntegriteeTrustedOperation, TimestampSetArgs } from '@encointer/types/interfaces/integriteeWorker';
import type { SchedulerState, SystemNumber } from '@encointer/types/interfaces/scheduler';
import type { BalanceTransferArgs, ClientRequest, Enclave, Getter, GetterArgs, GrantReputationArgs, PublicGetter, RegisterAttestationsArgs, RegisterParticipantArgs, Request, ShardIdentifier, TrustedCall, TrustedCallSigned, TrustedGetter, TrustedGetterSigned, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { DirectRequestStatus, Enclave, GetterArgs, ParentchainId, Request, RpcReturnValue, ShardIdentifier, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, F32, F64, I128, I16, I256, I32, I64, I8, ISize, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, f32, f64, i128, i16, i256, i32, i64, i8, isize, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
Expand Down Expand Up @@ -158,8 +160,11 @@ declare module '@polkadot/types/types/registry' {
Balance: Balance;
BalanceEntry: BalanceEntry;
BalanceOf: BalanceOf;
BalanceSetBalanceArgs: BalanceSetBalanceArgs;
BalanceShieldArgs: BalanceShieldArgs;
BalanceTransferArgs: BalanceTransferArgs;
BalanceType: BalanceType;
BalanceUnshieldArgs: BalanceUnshieldArgs;
BeefyAuthoritySet: BeefyAuthoritySet;
BeefyCommitment: BeefyCommitment;
BeefyEquivocationProof: BeefyEquivocationProof;
Expand Down Expand Up @@ -242,7 +247,6 @@ declare module '@polkadot/types/types/registry' {
ClassDetails: ClassDetails;
ClassId: ClassId;
ClassMetadata: ClassMetadata;
ClientRequest: ClientRequest;
CodecHash: CodecHash;
CodeHash: CodeHash;
CodeSource: CodeSource;
Expand Down Expand Up @@ -367,6 +371,7 @@ declare module '@polkadot/types/types/registry' {
Digest: Digest;
DigestItem: DigestItem;
DigestOf: DigestOf;
DirectRequestStatus: DirectRequestStatus;
DispatchClass: DispatchClass;
DispatchError: DispatchError;
DispatchErrorModule: DispatchErrorModule;
Expand Down Expand Up @@ -406,6 +411,14 @@ declare module '@polkadot/types/types/registry' {
Enclave: Enclave;
EncodedFinalityProofs: EncodedFinalityProofs;
EncodedJustification: EncodedJustification;
EncointerBalanceTransferArgs: EncointerBalanceTransferArgs;
EncointerGetter: EncointerGetter;
EncointerGetterArgs: EncointerGetterArgs;
EncointerPublicGetter: EncointerPublicGetter;
EncointerTrustedCall: EncointerTrustedCall;
EncointerTrustedCallSigned: EncointerTrustedCallSigned;
EncointerTrustedGetter: EncointerTrustedGetter;
EncointerTrustedGetterSigned: EncointerTrustedGetterSigned;
Epoch: Epoch;
EpochAuthorship: EpochAuthorship;
Era: Era;
Expand Down Expand Up @@ -542,7 +555,6 @@ declare module '@polkadot/types/types/registry' {
FungiblesAccessError: FungiblesAccessError;
Gas: Gas;
GeoHash: GeoHash;
Getter: Getter;
GetterArgs: GetterArgs;
GiltBid: GiltBid;
GlobalValidationData: GlobalValidationData;
Expand Down Expand Up @@ -628,6 +640,13 @@ declare module '@polkadot/types/types/registry' {
InstantiateReturnValueTo267: InstantiateReturnValueTo267;
InstructionV2: InstructionV2;
InstructionWeights: InstructionWeights;
IntegriteeGetter: IntegriteeGetter;
IntegriteePublicGetter: IntegriteePublicGetter;
IntegriteeTrustedCall: IntegriteeTrustedCall;
IntegriteeTrustedCallSigned: IntegriteeTrustedCallSigned;
IntegriteeTrustedGetter: IntegriteeTrustedGetter;
IntegriteeTrustedGetterSigned: IntegriteeTrustedGetterSigned;
IntegriteeTrustedOperation: IntegriteeTrustedOperation;
InteriorMultiLocation: InteriorMultiLocation;
InvalidDisputeStatementKind: InvalidDisputeStatementKind;
InvalidTransaction: InvalidTransaction;
Expand Down Expand Up @@ -830,6 +849,7 @@ declare module '@polkadot/types/types/registry' {
ParathreadClaimQueue: ParathreadClaimQueue;
ParathreadEntry: ParathreadEntry;
ParaValidatorIndex: ParaValidatorIndex;
ParentchainId: ParentchainId;
ParticipantIndexType: ParticipantIndexType;
ParticipantRegistration: ParticipantRegistration;
Pays: Pays;
Expand Down Expand Up @@ -876,7 +896,6 @@ declare module '@polkadot/types/types/registry' {
ProxyDefinition: ProxyDefinition;
ProxyState: ProxyState;
ProxyType: ProxyType;
PublicGetter: PublicGetter;
PvfCheckStatement: PvfCheckStatement;
PvfExecTimeoutKind: PvfExecTimeoutKind;
PvfPrepTimeoutKind: PvfPrepTimeoutKind;
Expand Down Expand Up @@ -947,6 +966,7 @@ declare module '@polkadot/types/types/registry' {
RoundSnapshot: RoundSnapshot;
RoundState: RoundState;
RpcMethods: RpcMethods;
RpcReturnValue: RpcReturnValue;
RuntimeApiMetadataLatest: RuntimeApiMetadataLatest;
RuntimeApiMetadataV15: RuntimeApiMetadataV15;
RuntimeApiMethodMetadataV15: RuntimeApiMethodMetadataV15;
Expand Down Expand Up @@ -1132,6 +1152,7 @@ declare module '@polkadot/types/types/registry' {
TAssetDepositBalance: TAssetDepositBalance;
Text: Text;
Timepoint: Timepoint;
TimestampSetArgs: TimestampSetArgs;
TokenError: TokenError;
TombstoneContractInfo: TombstoneContractInfo;
TraceBlockResponse: TraceBlockResponse;
Expand All @@ -1152,10 +1173,7 @@ declare module '@polkadot/types/types/registry' {
TreasuryProposal: TreasuryProposal;
TrieId: TrieId;
TrieIndex: TrieIndex;
TrustedCall: TrustedCall;
TrustedCallSigned: TrustedCallSigned;
TrustedGetter: TrustedGetter;
TrustedGetterSigned: TrustedGetterSigned;
TrustedOperationStatus: TrustedOperationStatus;
Type: Type;
u128: u128;
U128: U128;
Expand Down Expand Up @@ -1203,6 +1221,7 @@ declare module '@polkadot/types/types/registry' {
ValidDisputeStatementKind: ValidDisputeStatementKind;
ValidityAttestation: ValidityAttestation;
ValidTransaction: ValidTransaction;
Vault: Vault;
VecInboundHrmpMessage: VecInboundHrmpMessage;
VersionedMultiAsset: VersionedMultiAsset;
VersionedMultiAssets: VersionedMultiAssets;
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/interfaces/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export { default as ceremony } from './ceremony/definitions.js';
export { default as community } from './community/definitions.js';
export { default as scheduler } from './scheduler/definitions.js';
export { default as worker } from './worker/definitions.js';
export { default as encointerWorker } from './encointerWorker/definitions.js'
export { default as integriteeWorker } from './integriteeWorker/definitions.js'
53 changes: 53 additions & 0 deletions packages/types/src/interfaces/encointerWorker/definitions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export default {
rpc: {},
types: {
EncointerGetterArgs: '(AccountId, CommunityIdentifier)',
EncointerPublicGetter: {
_enum: {
total_issuance: 'CommunityIdentifier',
participant_count: 'CommunityIdentifier',
meetup_count: 'CommunityIdentifier',
ceremony_reward: 'CommunityIdentifier',
location_tolerance: 'CommunityIdentifier',
time_tolerance: 'CommunityIdentifier',
scheduler_state: 'CommunityIdentifier'
}
},
EncointerTrustedGetter: {
_enum: {
balance: '(AccountId, CommunityIdentifier)',
participant_index: '(AccountId, CommunityIdentifier)',
meetup_index: '(AccountId, CommunityIdentifier)',
attestations: '(AccountId, CommunityIdentifier)',
meetup_registry: '(AccountId, CommunityIdentifier)'
}
},
EncointerTrustedGetterSigned: {
getter: 'EncointerTrustedGetter',
signature: 'Signature'
},
EncointerGetter: {
_enum: {
public: 'EncointerPublicGetter',
trusted: 'EncointerTrustedGetterSigned'
}
},
EncointerTrustedCallSigned: {
call: 'EncointerTrustedCall',
nonce: 'u32',
signature: 'Signature'
},
EncointerTrustedCall: {
_enum: {
balance_transfer: 'EncointerBalanceTransferArgs',
ceremonies_register_participant: 'RegisterParticipantArgs',
ceremonies_register_attestations: 'RegisterAttestationsArgs',
ceremonies_grant_reputation: 'GrantReputationArgs'
}
},
EncointerBalanceTransferArgs: '(AccountId, AccountId, CommunityIdentifier, BalanceType)',
RegisterParticipantArgs: '(AccountId, CommunityIdentifier, Option<ProofOfAttendance<MultiSignature, AccountId>>)',
RegisterAttestationsArgs: '(AccountId, Vec<Attestation<MultiSignature, AccountId, u64>>)',
GrantReputationArgs: '(AccountId, CommunityIdentifier, AccountId)'
}
}
4 changes: 4 additions & 0 deletions packages/types/src/interfaces/encointerWorker/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */

export * from './types.js';
96 changes: 96 additions & 0 deletions packages/types/src/interfaces/encointerWorker/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */

import type { BalanceType } from '@encointer/types/interfaces/balances';
import type { Attestation, ProofOfAttendance } from '@encointer/types/interfaces/ceremony';
import type { CommunityIdentifier } from '@encointer/types/interfaces/community';
import type { Enum, Option, Struct, Vec, u32 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { Signature } from '@polkadot/types/interfaces/extrinsics';
import type { AccountId } from '@polkadot/types/interfaces/runtime';

/** @name EncointerBalanceTransferArgs */
export interface EncointerBalanceTransferArgs extends ITuple<[AccountId, AccountId, CommunityIdentifier, BalanceType]> {}

/** @name EncointerGetter */
export interface EncointerGetter extends Enum {
readonly isPublic: boolean;
readonly asPublic: EncointerPublicGetter;
readonly isTrusted: boolean;
readonly asTrusted: EncointerTrustedGetterSigned;
readonly type: 'Public' | 'Trusted';
}

/** @name EncointerGetterArgs */
export interface EncointerGetterArgs extends ITuple<[AccountId, CommunityIdentifier]> {}

/** @name EncointerPublicGetter */
export interface EncointerPublicGetter extends Enum {
readonly isTotalIssuance: boolean;
readonly asTotalIssuance: CommunityIdentifier;
readonly isParticipantCount: boolean;
readonly asParticipantCount: CommunityIdentifier;
readonly isMeetupCount: boolean;
readonly asMeetupCount: CommunityIdentifier;
readonly isCeremonyReward: boolean;
readonly asCeremonyReward: CommunityIdentifier;
readonly isLocationTolerance: boolean;
readonly asLocationTolerance: CommunityIdentifier;
readonly isTimeTolerance: boolean;
readonly asTimeTolerance: CommunityIdentifier;
readonly isSchedulerState: boolean;
readonly asSchedulerState: CommunityIdentifier;
readonly type: 'TotalIssuance' | 'ParticipantCount' | 'MeetupCount' | 'CeremonyReward' | 'LocationTolerance' | 'TimeTolerance' | 'SchedulerState';
}

/** @name EncointerTrustedCall */
export interface EncointerTrustedCall extends Enum {
readonly isBalanceTransfer: boolean;
readonly asBalanceTransfer: EncointerBalanceTransferArgs;
readonly isCeremoniesRegisterParticipant: boolean;
readonly asCeremoniesRegisterParticipant: RegisterParticipantArgs;
readonly isCeremoniesRegisterAttestations: boolean;
readonly asCeremoniesRegisterAttestations: RegisterAttestationsArgs;
readonly isCeremoniesGrantReputation: boolean;
readonly asCeremoniesGrantReputation: GrantReputationArgs;
readonly type: 'BalanceTransfer' | 'CeremoniesRegisterParticipant' | 'CeremoniesRegisterAttestations' | 'CeremoniesGrantReputation';
}

/** @name EncointerTrustedCallSigned */
export interface EncointerTrustedCallSigned extends Struct {
readonly call: EncointerTrustedCall;
readonly nonce: u32;
readonly signature: Signature;
}

/** @name EncointerTrustedGetter */
export interface EncointerTrustedGetter extends Enum {
readonly isBalance: boolean;
readonly asBalance: ITuple<[AccountId, CommunityIdentifier]>;
readonly isParticipantIndex: boolean;
readonly asParticipantIndex: ITuple<[AccountId, CommunityIdentifier]>;
readonly isMeetupIndex: boolean;
readonly asMeetupIndex: ITuple<[AccountId, CommunityIdentifier]>;
readonly isAttestations: boolean;
readonly asAttestations: ITuple<[AccountId, CommunityIdentifier]>;
readonly isMeetupRegistry: boolean;
readonly asMeetupRegistry: ITuple<[AccountId, CommunityIdentifier]>;
readonly type: 'Balance' | 'ParticipantIndex' | 'MeetupIndex' | 'Attestations' | 'MeetupRegistry';
}

/** @name EncointerTrustedGetterSigned */
export interface EncointerTrustedGetterSigned extends Struct {
readonly getter: EncointerTrustedGetter;
readonly signature: Signature;
}

/** @name GrantReputationArgs */
export interface GrantReputationArgs extends ITuple<[AccountId, CommunityIdentifier, AccountId]> {}

/** @name RegisterAttestationsArgs */
export interface RegisterAttestationsArgs extends ITuple<[AccountId, Vec<Attestation>]> {}

/** @name RegisterParticipantArgs */
export interface RegisterParticipantArgs extends ITuple<[AccountId, CommunityIdentifier, Option<ProofOfAttendance>]> {}

export type PHANTOM_ENCOINTERWORKER = 'encointerWorker';
60 changes: 60 additions & 0 deletions packages/types/src/interfaces/integriteeWorker/definitions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export default {
rpc: {},
types: {
IntegriteePublicGetter: {
_enum: {
total_issuance: 'CommunityIdentifier',
participant_count: 'CommunityIdentifier',
meetup_count: 'CommunityIdentifier',
ceremony_reward: 'CommunityIdentifier',
location_tolerance: 'CommunityIdentifier',
time_tolerance: 'CommunityIdentifier',
scheduler_state: 'CommunityIdentifier'
}
},
IntegriteeTrustedGetter: {
_enum: {
free_balance: 'AccountId',
reserved_balance: 'AccountId',
nonce: 'AccountId',
}
},
IntegriteeTrustedGetterSigned: {
getter: 'IntegriteeTrustedGetter',
signature: 'MultiSignature'
},
IntegriteeGetter: {
_enum: {
public: 'IntegriteePublicGetter',
trusted: 'IntegriteeTrustedGetterSigned'
}
},
IntegriteeTrustedOperation: {
_enum: {
indirect_call: 'IntegriteeTrustedCallSigned',
direct_call: 'IntegriteeTrustedCallSigned',
get: 'IntegriteeGetter'
}
},
IntegriteeTrustedCallSigned: {
call: 'IntegriteeTrustedCall',
nonce: 'u32',
signature: 'MultiSignature'
},
IntegriteeTrustedCall: {
_enum: {
noop: 'AccountId',
balance_set_balance: 'BalanceSetBalanceArgs',
balance_transfer: 'BalanceTransferArgs',
balance_unshield: 'BalanceUnshieldArgs',
balance_shield: 'BalanceShieldArgs',
timestamp_set: 'TimestampSetArgs',
}
},
BalanceSetBalanceArgs: '(AccountId, AccountId, BalanceType, BalanceType)',
BalanceTransferArgs: '(AccountId, AccountId, BalanceType)',
BalanceUnshieldArgs: '(AccountId, AccountId, BalanceType, ShardIdentifier)',
BalanceShieldArgs: '(AccountId, AccountId, BalanceType, ParentchainId)',
TimestampSetArgs: '(AccountId, H160, BalanceType)',
}
}
4 changes: 4 additions & 0 deletions packages/types/src/interfaces/integriteeWorker/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */

export * from './types.js';
Loading
Loading