Search in sources :

Example 6 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testProhibitionWithZeroTolerance.

@Test
public void testProhibitionWithZeroTolerance() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(0, 10, 0);
    // Version 1 is permitted over blocks [0, 9]
    // Version 2 is permitted over blocks 10 onwards.
    // Verify when version 1 is prohibited.
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 9));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 10));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, Long.MAX_VALUE));
    // Verify when version 2 is prohibited.
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 0));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 9));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 10));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 7 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmTestConfig method supportBothAvmVersions.

/**
 * Uses an avm version schedule that supports both version 1 and 2 at the specified block
 * numbers.
 *
 * The tolerance parameter is the amount of blocks (plus/minus) to keep an avm version alive
 * at a block where it is no longer used.
 *
 * @param blockNumberToUseVersion1 The block number at which version 1 starts being used.
 * @param blockNumberToUseVersion2 The block number at which version 2 starts being used.
 * @param activeVersionTolerance The amount of blocks to keep an old version alive.
 */
public static void supportBothAvmVersions(long blockNumberToUseVersion1, long blockNumberToUseVersion2, long activeVersionTolerance) {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(blockNumberToUseVersion1, blockNumberToUseVersion2, activeVersionTolerance);
    String projectRoot = AvmPathManager.getPathOfProjectRootDirectory();
    AvmConfigurations.initializeConfigurationsAsReadAndWriteable(schedule, projectRoot);
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule)

Example 8 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testWhichVersionToRun2.

@Test
public void testWhichVersionToRun2() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(12, 31, 3);
    Assert.assertNull(schedule.whichVersionToRunWith(0));
    Assert.assertNull(schedule.whichVersionToRunWith(11));
    Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(12));
    Assert.assertEquals(AvmVersion.VERSION_1, schedule.whichVersionToRunWith(30));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(31));
    Assert.assertEquals(AvmVersion.VERSION_2, schedule.whichVersionToRunWith(Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 9 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmVersionScheduleTest method testProhibitionWithOneTolerance.

@Test
public void testProhibitionWithOneTolerance() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForBothVersions(0, 16, 1);
    // Version 1 is permitted over blocks [0, 16]
    // Version 2 is permitted over blocks 15 onwards.
    // Verify when version 1 is prohibited.
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 0));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 15));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 16));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, 17));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_1, Long.MAX_VALUE));
    // Verify when version 2 is prohibited.
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 0));
    Assert.assertTrue(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 14));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 15));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, 16));
    Assert.assertFalse(schedule.isVersionProhibitedAtBlockNumber(AvmVersion.VERSION_2, Long.MAX_VALUE));
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule) Test(org.junit.Test)

Example 10 with AvmVersionSchedule

use of org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule in project aion by aionnetwork.

the class AvmTestConfig method supportOnlyAvmVersion1.

/**
 * Uses an avm version schedule that only supports version 1 - no version 2 support at all.
 * Version 1 is active from block zero onwards.
 */
public static void supportOnlyAvmVersion1() {
    AvmVersionSchedule schedule = AvmVersionSchedule.newScheduleForOnlySingleVersionSupport(0, 0);
    String projectRoot = AvmPathManager.getPathOfProjectRootDirectory();
    AvmConfigurations.initializeConfigurationsAsReadAndWriteable(schedule, projectRoot);
}
Also used : AvmVersionSchedule(org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule)

Aggregations

AvmVersionSchedule (org.aion.zero.impl.vm.avm.schedule.AvmVersionSchedule)19 Test (org.junit.Test)13 Console (java.io.Console)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 AvmVersion (org.aion.avm.stub.AvmVersion)1 LogEnum (org.aion.log.LogEnum)1 LogLevel (org.aion.log.LogLevel)1 AionBlockchainImpl (org.aion.zero.impl.blockchain.AionBlockchainImpl)1 CfgAion (org.aion.zero.impl.config.CfgAion)1 CfgDb (org.aion.zero.impl.config.CfgDb)1 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)1 BeforeClass (org.junit.BeforeClass)1 Logger (org.slf4j.Logger)1 CommandLine (picocli.CommandLine)1 CommandSpec (picocli.CommandLine.Model.CommandSpec)1