Skip to content

Commit

Permalink
VRF-1028: Add migration commands to VRF V2Plus superscripts (#12908)
Browse files Browse the repository at this point in the history
  • Loading branch information
iljapavlovs authored Apr 22, 2024
1 parent 1fce16e commit 9d359de
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/scripts/vrfv2plus/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,24 @@ func main() {
tx, err := coordinator.DeregisterProvingKey(e.Owner, [2]*big.Int{pk.X, pk.Y})
helpers.PanicErr(err)
helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID)
case "coordinator-register-migratable-coordinator":
coordinatorRegisterMigratableCoordinator := flag.NewFlagSet("coordinator-register-migratable-coordinator", flag.ExitOnError)
coordinatorAddress := coordinatorRegisterMigratableCoordinator.String("address", "", "coordinator address from which to register migratable coordinator")
coordinatorMigrateToAddress := coordinatorRegisterMigratableCoordinator.String("coordinator-migrate-to-address", "", "coordinator address to register in order for perform sub migration to")
helpers.ParseArgs(coordinatorRegisterMigratableCoordinator, os.Args[2:], "address", "coordinator-migrate-to-address")
coordinator, err := vrf_coordinator_v2_5.NewVRFCoordinatorV25(common.HexToAddress(*coordinatorAddress), e.Ec)
helpers.PanicErr(err)
v2plusscripts.RegisterMigratableCoordinator(e, *coordinator, common.HexToAddress(*coordinatorMigrateToAddress))
case "coordinator-migrate-sub":
coordinatorMigrateSub := flag.NewFlagSet("coordinator-migrate-sub", flag.ExitOnError)
coordinatorAddress := coordinatorMigrateSub.String("address", "", "coordinator address from which to migrate a sub")
coordinatorMigrateToAddress := coordinatorMigrateSub.String("coordinator-migrate-to-address", "", "coordinator address to migrate sub to")
subID := coordinatorMigrateSub.String("sub-id", "", "sub-id")
helpers.ParseArgs(coordinatorMigrateSub, os.Args[2:], "address", "coordinator-migrate-to-address", "sub-id")
parsedSubID := parseUInt256String(*subID)
coordinator, err := vrf_coordinator_v2_5.NewVRFCoordinatorV25(common.HexToAddress(*coordinatorAddress), e.Ec)
helpers.PanicErr(err)
v2plusscripts.MigrateSub(e, *coordinator, common.HexToAddress(*coordinatorMigrateToAddress), parsedSubID)
case "coordinator-subscription":
coordinatorSub := flag.NewFlagSet("coordinator-subscription", flag.ExitOnError)
address := coordinatorSub.String("address", "", "coordinator address")
Expand Down
35 changes: 35 additions & 0 deletions core/scripts/vrfv2plus/testnet/v2plusscripts/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,41 @@ func RegisterCoordinatorProvingKey(e helpers.Environment,
)
}

func RegisterMigratableCoordinator(
e helpers.Environment,
coordinator vrf_coordinator_v2_5.VRFCoordinatorV25,
coordinatorMigrateToAddress common.Address,
) {
tx, err := coordinator.RegisterMigratableCoordinator(e.Owner, coordinatorMigrateToAddress)
helpers.PanicErr(err)
helpers.ConfirmTXMined(
context.Background(),
e.Ec,
tx,
e.ChainID,
fmt.Sprintf("Coordinator %s registered migratable coordinator %s", coordinator.Address().String(), coordinatorMigrateToAddress.String()),
)
}

func MigrateSub(
e helpers.Environment,
coordinatorMigrateSubFrom vrf_coordinator_v2_5.VRFCoordinatorV25,
coordinatorMigrateSubTo common.Address,
subID *big.Int,
) {
tx, err := coordinatorMigrateSubFrom.Migrate(e.Owner, subID, coordinatorMigrateSubTo)
helpers.PanicErr(err)
helpers.ConfirmTXMined(
context.Background(),
e.Ec,
tx,
e.ChainID,
fmt.Sprintf("Sub Migrated from Coordinator: %s,", coordinatorMigrateSubFrom.Address().String()),
fmt.Sprintf("Sub Migrated TO Coordinator: %s,", coordinatorMigrateSubTo.String()),
fmt.Sprintf("Sub ID which was migrated: %s,", subID.String()),
)
}

func WrapperDeploy(
e helpers.Environment,
link, linkEthFeed, coordinator common.Address, subID *big.Int,
Expand Down

0 comments on commit 9d359de

Please sign in to comment.