Skip to content

Commit bace899

Browse files
author
danlaine
authored
Merge pull request #1 from StephenButtolph/custom-genesis
Custom genesis
2 parents a76787e + 4f432cb commit bace899

11 files changed

+101
-106
lines changed

vms/platformvm/add_nondefault_subnet_validator_tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (tx *addNonDefaultSubnetValidatorTx) SemanticVerify(db database.Database) (
162162
}
163163
var subnet *CreateSubnetTx
164164
for _, sn := range subnets {
165-
if sn.ID.Equals(tx.SubnetID()) {
165+
if sn.id.Equals(tx.SubnetID()) {
166166
subnet = sn
167167
break
168168
}

vms/platformvm/add_nondefault_subnet_validator_tx_test.go

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
2828
uint64(defaultValidateStartTime.Unix()),
2929
uint64(defaultValidateEndTime.Unix()),
3030
defaultKey.PublicKey().Address(),
31-
testSubnet1.ID,
31+
testSubnet1.id,
3232
testNetworkID,
3333
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
3434
defaultKey,
@@ -48,7 +48,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
4848
uint64(defaultValidateStartTime.Unix()),
4949
uint64(defaultValidateEndTime.Unix()),
5050
defaultKey.PublicKey().Address(),
51-
testSubnet1.ID,
51+
testSubnet1.id,
5252
testNetworkID+1,
5353
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
5454
defaultKey,
@@ -67,7 +67,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
6767
uint64(defaultValidateStartTime.Unix()),
6868
uint64(defaultValidateEndTime.Unix()),
6969
defaultKey.PublicKey().Address(),
70-
testSubnet1.ID,
70+
testSubnet1.id,
7171
testNetworkID,
7272
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
7373
defaultKey,
@@ -87,7 +87,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
8787
uint64(defaultValidateStartTime.Unix()),
8888
uint64(defaultValidateEndTime.Unix()),
8989
defaultKey.PublicKey().Address(),
90-
testSubnet1.ID,
90+
testSubnet1.id,
9191
testNetworkID,
9292
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
9393
defaultKey,
@@ -107,7 +107,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
107107
uint64(defaultValidateStartTime.Unix()),
108108
uint64(defaultValidateEndTime.Unix()),
109109
defaultKey.PublicKey().Address(),
110-
testSubnet1.ID,
110+
testSubnet1.id,
111111
testNetworkID,
112112
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
113113
defaultKey,
@@ -126,7 +126,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
126126
uint64(defaultValidateStartTime.Unix()),
127127
uint64(defaultValidateEndTime.Unix())-1,
128128
defaultKey.PublicKey().Address(),
129-
testSubnet1.ID,
129+
testSubnet1.id,
130130
testNetworkID,
131131
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
132132
defaultKey,
@@ -147,7 +147,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
147147
uint64(defaultValidateStartTime.Unix()),
148148
uint64(defaultValidateStartTime.Add(MinimumStakingDuration).Unix())-1,
149149
defaultKey.PublicKey().Address(),
150-
testSubnet1.ID,
150+
testSubnet1.id,
151151
testNetworkID,
152152
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
153153
defaultKey,
@@ -167,7 +167,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
167167
uint64(defaultValidateStartTime.Unix()),
168168
uint64(defaultValidateStartTime.Add(MaximumStakingDuration).Unix())+1,
169169
defaultKey.PublicKey().Address(),
170-
testSubnet1.ID,
170+
testSubnet1.id,
171171
testNetworkID,
172172
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
173173
defaultKey,
@@ -187,7 +187,7 @@ func TestAddNonDefaultSubnetValidatorTxSyntacticVerify(t *testing.T) {
187187
uint64(defaultValidateStartTime.Unix()),
188188
uint64(defaultValidateEndTime.Unix()),
189189
defaultKey.PublicKey().Address(),
190-
testSubnet1.ID,
190+
testSubnet1.id,
191191
testNetworkID,
192192
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
193193
defaultKey,
@@ -212,7 +212,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
212212
uint64(defaultValidateStartTime.Unix()),
213213
uint64(defaultValidateEndTime.Unix())+1,
214214
defaultKey.PublicKey().Address(),
215-
testSubnet1.ID,
215+
testSubnet1.id,
216216
testNetworkID,
217217
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
218218
defaultKey,
@@ -235,7 +235,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
235235
uint64(defaultValidateStartTime.Unix()),
236236
uint64(defaultValidateEndTime.Unix()),
237237
defaultKey.PublicKey().Address(),
238-
testSubnet1.ID,
238+
testSubnet1.id,
239239
testNetworkID,
240240
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
241241
defaultKey,
@@ -245,15 +245,15 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
245245
}
246246
_, _, _, _, err = tx.SemanticVerify(vm.DB)
247247
if err != nil {
248-
t.Log(testSubnet1.ID)
248+
t.Log(testSubnet1.id)
249249
subnets, err := vm.getSubnets(vm.DB)
250250
if err != nil {
251251
t.Fatal(err)
252252
}
253253
if len(subnets) == 0 {
254254
t.Fatal("no subnets found")
255255
}
256-
t.Logf("subnets[0].ID: %v", subnets[0].ID)
256+
t.Logf("subnets[0].ID: %v", subnets[0].id)
257257
t.Fatal(err)
258258
}
259259

@@ -290,7 +290,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
290290
uint64(DSStartTime.Unix()), // start validating non-default subnet before default subnet
291291
uint64(DSEndTime.Unix()),
292292
pendingDSValidatorID,
293-
testSubnet1.ID,
293+
testSubnet1.id,
294294
testNetworkID,
295295
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
296296
defaultKey,
@@ -324,7 +324,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
324324
uint64(DSStartTime.Unix())-1, // start validating non-default subnet before default subnet
325325
uint64(DSEndTime.Unix()),
326326
pendingDSValidatorID,
327-
testSubnet1.ID,
327+
testSubnet1.id,
328328
testNetworkID,
329329
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
330330
defaultKey,
@@ -346,7 +346,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
346346
uint64(DSStartTime.Unix()),
347347
uint64(DSEndTime.Unix())+1, // stop validating non-default subnet after stopping validating default subnet
348348
pendingDSValidatorID,
349-
testSubnet1.ID,
349+
testSubnet1.id,
350350
testNetworkID,
351351
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
352352
defaultKey,
@@ -368,7 +368,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
368368
uint64(DSStartTime.Unix()), // same start time as for default subnet
369369
uint64(DSEndTime.Unix()), // same end time as for default subnet
370370
pendingDSValidatorID,
371-
testSubnet1.ID,
371+
testSubnet1.id,
372372
testNetworkID,
373373
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
374374
defaultKey,
@@ -389,12 +389,12 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
389389
}
390390

391391
tx, err = vm.newAddNonDefaultSubnetValidatorTx(
392-
defaultNonce+1, // nonce
393-
defaultWeight, // weight
394-
uint64(newTimestamp.Unix()), // start time
392+
defaultNonce+1, // nonce
393+
defaultWeight, // weight
394+
uint64(newTimestamp.Unix()), // start time
395395
uint64(newTimestamp.Add(MinimumStakingDuration).Unix()), // end time
396396
defaultKey.PublicKey().Address(), // node ID
397-
testSubnet1.ID, // subnet ID
397+
testSubnet1.id, // subnet ID
398398
testNetworkID, // network ID
399399
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
400400
defaultKey, // tx fee payer
@@ -429,7 +429,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
429429
uint64(defaultValidateStartTime.Unix()), // start time
430430
uint64(defaultValidateEndTime.Unix()), // end time
431431
defaultKey.PublicKey().Address(), // node ID
432-
testSubnet1.ID, // subnet ID
432+
testSubnet1.id, // subnet ID
433433
testNetworkID, // network ID
434434
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
435435
newAcctKey.(*crypto.PrivateKeySECP256K1R), // tx fee payer
@@ -451,7 +451,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
451451
uint64(defaultValidateStartTime.Unix()), // start time
452452
uint64(defaultValidateEndTime.Unix()), // end time
453453
defaultKey.PublicKey().Address(), // node ID
454-
testSubnet1.ID, // subnet ID
454+
testSubnet1.id, // subnet ID
455455
testNetworkID, // network ID
456456
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
457457
defaultKey, // tx fee payer
@@ -465,7 +465,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
465465
SortByStartTime: false,
466466
Txs: []TimedTx{tx},
467467
},
468-
testSubnet1.ID,
468+
testSubnet1.id,
469469
)
470470
// Node with ID nodeIDKey.PublicKey().Address() now validating subnet with ID testSubnet1.ID
471471

@@ -475,7 +475,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
475475
uint64(defaultValidateStartTime.Unix()), // start time
476476
uint64(defaultValidateEndTime.Unix()), // end time
477477
defaultKey.PublicKey().Address(), // node ID
478-
testSubnet1.ID, // subnet ID
478+
testSubnet1.id, // subnet ID
479479
testNetworkID, // network ID
480480
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
481481
defaultKey, // tx fee payer
@@ -494,17 +494,17 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
494494
&EventHeap{
495495
SortByStartTime: false,
496496
},
497-
testSubnet1.ID,
497+
testSubnet1.id,
498498
)
499499

500500
// Case 9: Too many signatures
501501
tx, err = vm.newAddNonDefaultSubnetValidatorTx(
502-
defaultNonce+1, // nonce
503-
defaultWeight, // weight
504-
uint64(defaultGenesisTime.Unix()), // start time
502+
defaultNonce+1, // nonce
503+
defaultWeight, // weight
504+
uint64(defaultGenesisTime.Unix()), // start time
505505
uint64(defaultGenesisTime.Add(MinimumStakingDuration).Unix())+1, // end time
506506
keys[0].PublicKey().Address(), // node ID
507-
testSubnet1.ID, // subnet ID
507+
testSubnet1.id, // subnet ID
508508
testNetworkID, // network ID
509509
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1], testSubnet1ControlKeys[2]},
510510
defaultKey, // tx fee payer
@@ -520,12 +520,12 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
520520

521521
// Case 10: Too few signatures
522522
tx, err = vm.newAddNonDefaultSubnetValidatorTx(
523-
defaultNonce+1, // nonce
524-
defaultWeight, // weight
525-
uint64(defaultGenesisTime.Unix()), // start time
523+
defaultNonce+1, // nonce
524+
defaultWeight, // weight
525+
uint64(defaultGenesisTime.Unix()), // start time
526526
uint64(defaultGenesisTime.Add(MinimumStakingDuration).Unix()), // end time
527527
keys[0].PublicKey().Address(), // node ID
528-
testSubnet1.ID, // subnet ID
528+
testSubnet1.id, // subnet ID
529529
testNetworkID, // network ID
530530
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[2]},
531531
defaultKey, // tx fee payer
@@ -541,12 +541,12 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
541541

542542
// Case 10: Control Signature from invalid key
543543
tx, err = vm.newAddNonDefaultSubnetValidatorTx(
544-
defaultNonce+1, // nonce
545-
defaultWeight, // weight
546-
uint64(defaultGenesisTime.Unix()), // start time
544+
defaultNonce+1, // nonce
545+
defaultWeight, // weight
546+
uint64(defaultGenesisTime.Unix()), // start time
547547
uint64(defaultGenesisTime.Add(MinimumStakingDuration).Unix()), // end time
548548
keys[0].PublicKey().Address(), // node ID
549-
testSubnet1.ID, // subnet ID
549+
testSubnet1.id, // subnet ID
550550
testNetworkID, // network ID
551551
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], keys[3]},
552552
defaultKey, // tx fee payer
@@ -563,12 +563,12 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
563563
// Case 11: Proposed validator in pending validator set for subnet
564564
// First, add validator to pending validator set of subnet
565565
tx, err = vm.newAddNonDefaultSubnetValidatorTx(
566-
defaultNonce+1, // nonce
567-
defaultWeight, // weight
568-
uint64(defaultGenesisTime.Unix())+1, // start time
566+
defaultNonce+1, // nonce
567+
defaultWeight, // weight
568+
uint64(defaultGenesisTime.Unix())+1, // start time
569569
uint64(defaultGenesisTime.Add(MinimumStakingDuration).Unix())+1, // end time
570570
defaultKey.PublicKey().Address(), // node ID
571-
testSubnet1.ID, // subnet ID
571+
testSubnet1.id, // subnet ID
572572
testNetworkID, // network ID
573573
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
574574
defaultKey, // tx fee payer
@@ -582,7 +582,7 @@ func TestAddNonDefaultSubnetValidatorTxSemanticVerify(t *testing.T) {
582582
SortByStartTime: true,
583583
Txs: []TimedTx{tx},
584584
},
585-
testSubnet1.ID,
585+
testSubnet1.id,
586586
)
587587
// Node with ID nodeIDKey.PublicKey().Address() now pending validator for subnet with ID testSubnet1.ID
588588

@@ -604,7 +604,7 @@ func TestAddNonDefaultSubnetValidatorMarshal(t *testing.T) {
604604
uint64(defaultValidateStartTime.Unix()),
605605
uint64(defaultValidateEndTime.Unix()),
606606
defaultKey.PublicKey().Address(),
607-
testSubnet1.ID,
607+
testSubnet1.id,
608608
testNetworkID,
609609
[]*crypto.PrivateKeySECP256K1R{testSubnet1ControlKeys[0], testSubnet1ControlKeys[1]},
610610
defaultKey,

vms/platformvm/advance_time_tx.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ func (tx *advanceTimeTx) SemanticVerify(db database.Database) (*versiondb.Databa
105105
return nil, nil, nil, nil, err
106106
}
107107
for _, subnet := range subnets {
108-
current, pending, err := tx.vm.calculateValidators(db, tx.Timestamp(), subnet.ID)
108+
current, pending, err := tx.vm.calculateValidators(db, tx.Timestamp(), subnet.id)
109109
if err != nil {
110110
return nil, nil, nil, nil, err
111111
}
112112

113-
if err := tx.vm.putCurrentValidators(onCommitDB, current, subnet.ID); err != nil {
113+
if err := tx.vm.putCurrentValidators(onCommitDB, current, subnet.id); err != nil {
114114
return nil, nil, nil, nil, err
115115
}
116-
if err := tx.vm.putPendingValidators(onCommitDB, pending, subnet.ID); err != nil {
116+
if err := tx.vm.putPendingValidators(onCommitDB, pending, subnet.id); err != nil {
117117
return nil, nil, nil, nil, err
118118
}
119119
}
@@ -127,7 +127,7 @@ func (tx *advanceTimeTx) SemanticVerify(db database.Database) (*versiondb.Databa
127127
return
128128
}
129129
for _, subnet := range subnets {
130-
if err := tx.vm.updateValidators(subnet.ID); err != nil {
130+
if err := tx.vm.updateValidators(subnet.id); err != nil {
131131
tx.vm.Ctx.Log.Debug("failed to update validators on the default subnet: %s", err)
132132
}
133133
}

vms/platformvm/create_chain_tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (tx *CreateChainTx) SemanticVerify(db database.Database) (func(), error) {
156156
}
157157
var subnet *CreateSubnetTx // the subnet that will validate the new chain
158158
for _, sn := range subnets {
159-
if sn.ID.Equals(tx.SubnetID) {
159+
if sn.id.Equals(tx.SubnetID) {
160160
subnet = sn
161161
break
162162
}

0 commit comments

Comments
 (0)