Skip to content

Commit d36033b

Browse files
authored
Merge pull request #912 from ava-labs/erictaylor/acp-77-nomenclature
feat: acp-77 nomenclature changes
2 parents 7900273 + 2ec0263 commit d36033b

36 files changed

+408
-403
lines changed

cspell.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,14 @@
1919
"ignoreRegExpList": ["/.*[0-9].*/"],
2020
"language": "en",
2121
"minWordLength": 5,
22-
"words": ["amounter", "avalabs", "locktime", "stakeable", "unstakeable", "utxo", "utxos"]
22+
"words": [
23+
"amounter",
24+
"avalabs",
25+
"locktime",
26+
"permissioned",
27+
"stakeable",
28+
"unstakeable",
29+
"utxo",
30+
"utxos"
31+
]
2332
}

examples/p-chain/etna/convertSubnet.ts renamed to examples/p-chain/etna/convertSubnetToL1.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import { addTxSignatures, pvm, utils } from '../../../src';
1+
import {
2+
L1Validator,
3+
PChainOwner,
4+
addTxSignatures,
5+
pvm,
6+
pvmSerial,
7+
utils,
8+
} from '../../../src';
29
import { setupEtnaExample } from './utils/etna-helper';
3-
import { ConvertSubnetValidator } from '../../../src/serializable/fxs/pvm/convertSubnetValidator';
4-
import { ProofOfPossession } from '../../../src/serializable/pvm';
5-
import { PChainOwner } from '../../../src/serializable/fxs/pvm/pChainOwner';
610
import { getEnvVars } from '../../utils/getEnvVars';
711

812
const AMOUNT_TO_VALIDATE_AVAX: number = 1;
913
const BALANCE_AVAX: number = 1;
1014

1115
/**
12-
* Converts a subnet to permissionless subnet.
16+
* Converts a subnet to L1.
1317
*
1418
* **Note** A subnet must be created (createSubnetTx) and a chain must be created (createChainTx)
1519
* before a subnet can be converted from permissioned to permissionless.
@@ -20,7 +24,7 @@ const BALANCE_AVAX: number = 1;
2024
* @param subnetId the ID of the subnet that is created via `createSubnetTx`.
2125
* @returns The resulting transaction's ID.
2226
*/
23-
const convertSubnetTxExample = async () => {
27+
const convertSubnetToL1TxExample = async () => {
2428
const {
2529
AVAX_PUBLIC_URL,
2630
P_CHAIN_ADDRESS,
@@ -41,9 +45,9 @@ const convertSubnetTxExample = async () => {
4145

4246
const signature = utils.hexToBuffer(BLS_SIGNATURE);
4347

44-
const signer = new ProofOfPossession(publicKey, signature);
48+
const signer = new pvmSerial.ProofOfPossession(publicKey, signature);
4549

46-
const validator = ConvertSubnetValidator.fromNative(
50+
const validator = L1Validator.fromNative(
4751
NODE_ID,
4852
BigInt(AMOUNT_TO_VALIDATE_AVAX * 1e9),
4953
BigInt(BALANCE_AVAX * 1e9),
@@ -52,7 +56,7 @@ const convertSubnetTxExample = async () => {
5256
pChainOwner,
5357
);
5458

55-
const tx = pvm.e.newConvertSubnetTx(
59+
const tx = pvm.e.newConvertSubnetToL1Tx(
5660
{
5761
feeState,
5862
fromAddressesBytes: [testPAddr],
@@ -74,4 +78,4 @@ const convertSubnetTxExample = async () => {
7478
return pvmApi.issueSignedTx(tx.getSignedTx());
7579
};
7680

77-
convertSubnetTxExample().then(console.log);
81+
convertSubnetToL1TxExample().then(console.log);

examples/p-chain/etna/increaseBalanceTx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const increaseBalanceTx = async () => {
1313

1414
const testPAddr = utils.bech32ToBytes(P_CHAIN_ADDRESS);
1515

16-
const unsignedTx = pvm.e.newIncreaseBalanceTx(
16+
const unsignedTx = pvm.e.newIncreaseL1ValidatorBalanceTx(
1717
{
1818
balance: BigInt(BALANCE_AVAX * 1e9),
1919
feeState,

src/fixtures/pvm.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ import {
1919
RemoveSubnetValidatorTx,
2020
TransferSubnetOwnershipTx,
2121
TransformSubnetTx,
22-
IncreaseBalanceTx,
23-
DisableSubnetValidatorTx,
24-
SetSubnetValidatorWeightTx,
22+
ConvertSubnetToL1Tx,
23+
RegisterL1ValidatorTx,
24+
SetL1ValidatorWeightTx,
25+
IncreaseL1ValidatorBalanceTx,
26+
DisableL1ValidatorTx,
2527
} from '../serializable/pvm';
2628
import {
2729
baseTx,
@@ -67,10 +69,8 @@ import {
6769
import { bytesForInt } from './utils/bytesFor';
6870
import { makeList, makeListBytes } from './utils/makeList';
6971
import type { FeeState } from '../vms/pvm';
70-
import { ConvertSubnetTx } from '../serializable/pvm/convertSubnetTx';
71-
import { ConvertSubnetValidator } from '../serializable/fxs/pvm/convertSubnetValidator';
72+
import { L1Validator } from '../serializable/fxs/pvm/L1Validator';
7273
import { PChainOwner } from '../serializable/fxs/pvm/pChainOwner';
73-
import { RegisterSubnetValidatorTx } from '../serializable/pvm/registerSubnetValidatorTx';
7474

7575
export const validator = () =>
7676
new Validator(nodeId(), bigIntPr(), bigIntPr(), bigIntPr());
@@ -318,8 +318,8 @@ export const pChainOwnerBytes = () =>
318318
addressesBytes(),
319319
);
320320

321-
export const convertSubnetValidator = () =>
322-
new ConvertSubnetValidator(
321+
export const l1Validator = () =>
322+
new L1Validator(
323323
bytes(),
324324
bigIntPr(),
325325
bigIntPr(),
@@ -328,7 +328,7 @@ export const convertSubnetValidator = () =>
328328
pChainOwner(),
329329
);
330330

331-
export const convertSubnetValidatorBytes = () =>
331+
export const l1ValidatorBytes = () =>
332332
concatBytes(
333333
bytesBytes(),
334334
bigIntPrBytes(),
@@ -338,54 +338,54 @@ export const convertSubnetValidatorBytes = () =>
338338
pChainOwnerBytes(),
339339
);
340340

341-
export const convertSubnetTx = () =>
342-
new ConvertSubnetTx(
341+
export const convertSubnetToL1Tx = () =>
342+
new ConvertSubnetToL1Tx(
343343
baseTx(),
344344
id(),
345345
id(),
346346
bytes(),
347-
makeList(convertSubnetValidator)(),
347+
makeList(l1Validator)(),
348348
input(),
349349
);
350350

351-
export const convertSubnetTxBytes = () =>
351+
export const convertSubnetToL1TxBytes = () =>
352352
concatBytes(
353353
baseTxbytes(),
354354
idBytes(),
355355
idBytes(),
356356
bytesBytes(),
357-
makeListBytes(convertSubnetValidatorBytes)(),
357+
makeListBytes(l1ValidatorBytes)(),
358358
bytesForInt(10),
359359
inputBytes(),
360360
);
361361

362-
export const registerSubnetValidatorTx = () =>
363-
new RegisterSubnetValidatorTx(baseTx(), bigIntPr(), blsSignature(), bytes());
362+
export const registerL1ValidatorTx = () =>
363+
new RegisterL1ValidatorTx(baseTx(), bigIntPr(), blsSignature(), bytes());
364364

365-
export const registerSubnetValidatorTxBytes = () =>
365+
export const registerL1ValidatorTxBytes = () =>
366366
concatBytes(
367367
baseTxbytes(),
368368
bigIntPrBytes(),
369369
blsSignatureBytes(),
370370
bytesBytes(),
371371
);
372372

373-
export const setSubnetValidatorWeightTx = () =>
374-
new SetSubnetValidatorWeightTx(baseTx(), bytes());
373+
export const setL1ValidatorWeightTx = () =>
374+
new SetL1ValidatorWeightTx(baseTx(), bytes());
375375

376-
export const setSubnetValidatorWeightTxBytes = () =>
376+
export const setL1ValidatorWeightTxBytes = () =>
377377
concatBytes(baseTxbytes(), bytesBytes());
378378

379-
export const increaseBalanceTx = () =>
380-
new IncreaseBalanceTx(baseTx(), id(), bigIntPr());
379+
export const increaseL1ValidatorBalanceTx = () =>
380+
new IncreaseL1ValidatorBalanceTx(baseTx(), id(), bigIntPr());
381381

382-
export const increaseBalanceTxBytes = () =>
382+
export const increaseL1ValidatorBalanceTxBytes = () =>
383383
concatBytes(baseTxbytes(), idBytes(), bigIntPrBytes());
384384

385-
export const disableSubnetValidatorTx = () =>
386-
new DisableSubnetValidatorTx(baseTx(), id(), input());
385+
export const disableL1ValidatorTx = () =>
386+
new DisableL1ValidatorTx(baseTx(), id(), input());
387387

388-
export const disableSubnetValidatorTxBytes = () =>
388+
export const disableL1ValidatorTxBytes = () =>
389389
concatBytes(baseTxbytes(), idBytes(), bytesForInt(10), inputBytes());
390390

391391
export const feeState = (): FeeState => ({

src/serializable/constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ export enum TypeSymbols {
8181
TransformSubnetTx = 'pvm.TransformSubnetTx',
8282
TransferSubnetOwnershipTx = 'pvm.TransferSubnetOwnershipTx',
8383

84-
ConvertSubnetTx = 'pvm.ConvertSubnetTx',
85-
ConvertSubnetValidator = 'pvm.ConvertSubnetValidator',
86-
RegisterSubnetValidatorTx = 'pvm.RegisterSubnetValidatorTx',
87-
SetSubnetValidatorWeightTx = 'pvm.SetSubnetValidatorWeightTx',
88-
IncreaseBalanceTx = 'pvm.IncreaseBalanceTx',
89-
DisableSubnetValidatorTx = 'pvm.DisableSubnetValidatorTx',
84+
L1Validator = 'pvm.L1Validator',
85+
ConvertSubnetToL1Tx = 'pvm.ConvertSubnetToL1Tx',
86+
RegisterL1ValidatorTx = 'pvm.RegisterL1ValidatorTx',
87+
SetL1ValidatorWeightTx = 'pvm.SetL1ValidatorWeightTx',
88+
IncreaseL1ValidatorBalanceTx = 'pvm.IncreaseL1ValidatorBalanceTx',
89+
DisableL1ValidatorTx = 'pvm.DisableL1ValidatorTx',
9090

9191
PChainOwner = 'pvm.PChainOwner',
9292

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { testPVMCodec } from '../../../fixtures/codec';
2+
import { l1Validator, l1ValidatorBytes } from '../../../fixtures/pvm';
3+
import { testSerialization } from '../../../fixtures/utils/serializable';
4+
import { L1Validator } from './L1Validator';
5+
6+
testSerialization(
7+
'L1Validator',
8+
L1Validator,
9+
l1Validator,
10+
l1ValidatorBytes,
11+
testPVMCodec,
12+
);

src/serializable/fxs/pvm/convertSubnetValidator.ts renamed to src/serializable/fxs/pvm/L1Validator.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { NodeId } from '../common';
88
import { PChainOwner } from './pChainOwner';
99

1010
/**
11-
* @see https://github.com/ava-labs/avalanchego/blob/master/vms/platformvm/txs/convert_subnet_tx.go#86
11+
* @see https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/77-reinventing-subnets/README.md#convertsubnettol1tx
1212
*/
1313
@serializable()
14-
export class ConvertSubnetValidator {
15-
_type = TypeSymbols.ConvertSubnetValidator;
14+
export class L1Validator {
15+
_type = TypeSymbols.L1Validator;
1616

1717
constructor(
1818
public readonly nodeId: Bytes,
@@ -51,7 +51,7 @@ export class ConvertSubnetValidator {
5151
remainingBalanceOwner: PChainOwner,
5252
deactivationOwner: PChainOwner,
5353
) {
54-
return new ConvertSubnetValidator(
54+
return new L1Validator(
5555
new Bytes(NodeId.fromString(nodeId).toBytes()),
5656
new BigIntPr(weight),
5757
new BigIntPr(balance),
@@ -61,10 +61,7 @@ export class ConvertSubnetValidator {
6161
);
6262
}
6363

64-
static fromBytes(
65-
bytes: Uint8Array,
66-
codec: Codec,
67-
): [ConvertSubnetValidator, Uint8Array] {
64+
static fromBytes(bytes: Uint8Array, codec: Codec): [L1Validator, Uint8Array] {
6865
const [
6966
nodeId,
7067
weight,
@@ -80,7 +77,7 @@ export class ConvertSubnetValidator {
8077
);
8178

8279
return [
83-
new ConvertSubnetValidator(
80+
new L1Validator(
8481
nodeId,
8582
weight,
8683
balance,

src/serializable/fxs/pvm/convertSubnetValidator.test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/serializable/fxs/pvm/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './convertSubnetValidator';
1+
export * from './L1Validator';
22
export * from './pChainOwner';

src/serializable/pvm/codec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import { RemoveSubnetValidatorTx } from './removeSubnetValidatorTx';
1818
import { TransferSubnetOwnershipTx } from './transferSubnetOwnershipTx';
1919
import { TransformSubnetTx } from './transformSubnetTx';
2020
import { BaseTx } from './baseTx';
21-
import { ConvertSubnetTx } from './convertSubnetTx';
22-
import { IncreaseBalanceTx } from './increaseBalanceTx';
23-
import { DisableSubnetValidatorTx } from './disableSubnetValidatorTx';
24-
import { SetSubnetValidatorWeightTx } from './setSubnetValidatorWeightTx';
25-
import { RegisterSubnetValidatorTx } from './registerSubnetValidatorTx';
21+
import { ConvertSubnetToL1Tx } from './convertSubnetToL1Tx';
22+
import { IncreaseL1ValidatorBalanceTx } from './increaseL1ValidatorBalanceTx';
23+
import { DisableL1ValidatorTx } from './disableL1ValidatorTx';
24+
import { SetL1ValidatorWeightTx } from './setL1ValidatorWeightTx';
25+
import { RegisterL1ValidatorTx } from './registerL1ValidatorTx';
2626

2727
/**
2828
* @see https://github.com/ava-labs/avalanchego/blob/master/vms/platformvm/txs/codec.go#L35
@@ -63,11 +63,11 @@ export const codec = new Codec([
6363
TransferSubnetOwnershipTx, // 33
6464
BaseTx, // 34
6565

66-
ConvertSubnetTx, // 35
67-
RegisterSubnetValidatorTx, // 36
68-
SetSubnetValidatorWeightTx, // 37
69-
IncreaseBalanceTx, // 38
70-
DisableSubnetValidatorTx, // 39
66+
ConvertSubnetToL1Tx, // 35
67+
RegisterL1ValidatorTx, // 36
68+
SetL1ValidatorWeightTx, // 37
69+
IncreaseL1ValidatorBalanceTx, // 38
70+
DisableL1ValidatorTx, // 39
7171
]);
7272

7373
let manager: Manager;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { testPVMCodec } from '../../fixtures/codec';
2+
import {
3+
convertSubnetToL1Tx,
4+
convertSubnetToL1TxBytes,
5+
} from '../../fixtures/pvm';
6+
import { testSerialization } from '../../fixtures/utils/serializable';
7+
import { ConvertSubnetToL1Tx } from './convertSubnetToL1Tx';
8+
9+
testSerialization(
10+
'ConvertSubnetToL1Tx',
11+
ConvertSubnetToL1Tx,
12+
convertSubnetToL1Tx,
13+
convertSubnetToL1TxBytes,
14+
testPVMCodec,
15+
);

src/serializable/pvm/convertSubnetTx.ts renamed to src/serializable/pvm/convertSubnetToL1Tx.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import type { Serializable } from '../common/types';
77
import { serializable } from '../common/types';
88
import { TypeSymbols } from '../constants';
99
import { Id } from '../fxs/common';
10-
import { ConvertSubnetValidator } from '../fxs/pvm/convertSubnetValidator';
10+
import { L1Validator } from '../fxs/pvm/L1Validator';
1111
import { Bytes } from '../primitives';
1212
import { AbstractSubnetTx } from './abstractSubnetTx';
1313

1414
@serializable()
15-
export class ConvertSubnetTx extends AbstractSubnetTx {
16-
_type = TypeSymbols.ConvertSubnetTx;
15+
export class ConvertSubnetToL1Tx extends AbstractSubnetTx {
16+
_type = TypeSymbols.ConvertSubnetToL1Tx;
1717

1818
constructor(
1919
public readonly baseTx: BaseTx,
2020
public readonly subnetID: Id,
2121
public readonly chainID: Id,
2222
public readonly address: Bytes,
23-
public readonly validators: ConvertSubnetValidator[],
23+
public readonly validators: L1Validator[],
2424
public readonly subnetAuth: Serializable,
2525
) {
2626
super();
@@ -33,15 +33,15 @@ export class ConvertSubnetTx extends AbstractSubnetTx {
3333
static fromBytes(
3434
bytes: Uint8Array,
3535
codec: Codec,
36-
): [ConvertSubnetTx, Uint8Array] {
36+
): [ConvertSubnetToL1Tx, Uint8Array] {
3737
const [baseTx, subnetID, chainID, address, validators, subnetAuth, rest] =
3838
unpack(
3939
bytes,
40-
[BaseTx, Id, Id, Bytes, toListStruct(ConvertSubnetValidator), Codec],
40+
[BaseTx, Id, Id, Bytes, toListStruct(L1Validator), Codec],
4141
codec,
4242
);
4343
return [
44-
new ConvertSubnetTx(
44+
new ConvertSubnetToL1Tx(
4545
baseTx,
4646
subnetID,
4747
chainID,

0 commit comments

Comments
 (0)