Search in sources :

Example 11 with SystemConstraintScrypt

use of com.radixdlt.application.system.scrypt.SystemConstraintScrypt in project radixdlt by radixdlt.

the class FixedFeeTest method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")));
    cmAtomOS.load(new SystemConstraintScrypt());
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization(), FixedFeeMeter.create(UInt256.FIVE));
    var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    var serialization = cmAtomOS.buildSubstateSerialization();
    this.store = new InMemoryEngineStore<>();
    this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).put(TransferToken.class, new TransferTokensConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(FeeReservePut.class, new FeeReservePutConstructor()).put(FeeReserveTake.class, new FeeReserveTakeConstructor()).build(), cm, store);
    var txn = this.engine.construct(TxnConstructionRequest.create().action(new CreateSystem(0)).action(new CreateMutableToken(REAddr.ofNativeToken(), "xrd", "xrd", "", "", "", null)).action(new MintToken(REAddr.ofNativeToken(), accountAddr, UInt256.TEN))).buildWithoutSignature();
    this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) REParser(com.radixdlt.engine.parser.REParser) MintTokenConstructor(com.radixdlt.application.tokens.construction.MintTokenConstructor) FeeReservePutConstructor(com.radixdlt.application.system.construction.FeeReservePutConstructor) CMAtomOS(com.radixdlt.atomos.CMAtomOS) TokensConstraintScryptV3(com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3) FeeReserveTakeConstructor(com.radixdlt.application.system.construction.FeeReserveTakeConstructor) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) TransferTokensConstructorV2(com.radixdlt.application.tokens.construction.TransferTokensConstructorV2) Before(org.junit.Before)

Example 12 with SystemConstraintScrypt

use of com.radixdlt.application.system.scrypt.SystemConstraintScrypt in project radixdlt by radixdlt.

the class NextEpochV2Test method setup.

@Before
public void setup() {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    scrypts.forEach(cmAtomOS::load);
    // For v1 start
    cmAtomOS.load(new MutexConstraintScrypt());
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
    this.parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    var serialization = cmAtomOS.buildSubstateSerialization();
    this.store = new InMemoryEngineStore<>();
    this.sut = new RadixEngine<>(parser, serialization, constructors, cm, store);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) MutexConstraintScrypt(com.radixdlt.application.unique.scrypt.MutexConstraintScrypt) REParser(com.radixdlt.engine.parser.REParser) CMAtomOS(com.radixdlt.atomos.CMAtomOS) Before(org.junit.Before)

Example 13 with SystemConstraintScrypt

use of com.radixdlt.application.system.scrypt.SystemConstraintScrypt in project radixdlt by radixdlt.

the class DelegationFlagTest method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    scrypts.forEach(cmAtomOS::load);
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
    var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    var serialization = cmAtomOS.buildSubstateSerialization();
    this.store = new InMemoryEngineStore<>();
    this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(StakeTokens.class, stakeTokensConstructor).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(UpdateAllowDelegationFlag.class, new UpdateAllowDelegationFlagConstructor()).put(UpdateValidatorOwner.class, new UpdateValidatorOwnerConstructor()).put(CreateSystem.class, new CreateSystemConstructorV2()).build(), cm, store);
    var txn = this.engine.construct(new CreateSystem(0)).buildWithoutSignature();
    this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) UpdateValidatorOwnerConstructor(com.radixdlt.application.validators.construction.UpdateValidatorOwnerConstructor) REParser(com.radixdlt.engine.parser.REParser) MintTokenConstructor(com.radixdlt.application.tokens.construction.MintTokenConstructor) CMAtomOS(com.radixdlt.atomos.CMAtomOS) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) UpdateAllowDelegationFlagConstructor(com.radixdlt.application.validators.construction.UpdateAllowDelegationFlagConstructor) Before(org.junit.Before)

Example 14 with SystemConstraintScrypt

use of com.radixdlt.application.system.scrypt.SystemConstraintScrypt in project radixdlt by radixdlt.

the class MintTokensTest method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    cmAtomOS.load(scrypt);
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
    var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    var serialization = cmAtomOS.buildSubstateSerialization();
    this.store = new InMemoryEngineStore<>();
    this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).put(TransferToken.class, transferTokensConstructor).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).build(), cm, store);
    var genesis = this.engine.construct(new CreateSystem(0)).buildWithoutSignature();
    this.engine.execute(List.of(genesis), null, PermissionLevel.SYSTEM);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) REParser(com.radixdlt.engine.parser.REParser) MintTokenConstructor(com.radixdlt.application.tokens.construction.MintTokenConstructor) CMAtomOS(com.radixdlt.atomos.CMAtomOS) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) Before(org.junit.Before)

Example 15 with SystemConstraintScrypt

use of com.radixdlt.application.system.scrypt.SystemConstraintScrypt in project radixdlt by radixdlt.

the class StakeTokensTest method parameters.

@Parameterized.Parameters
public static Collection<Object[]> parameters() {
    var startAmounts = List.of(10);
    var stakeAmounts = List.of(10, 6);
    var scrypts = List.of(Pair.of(List.of(new SystemConstraintScrypt(), new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")), new StakingConstraintScryptV4(Amount.ofTokens(10).toSubunits()), new ValidatorConstraintScryptV2(), new ValidatorUpdateOwnerConstraintScrypt()), new StakeTokensConstructorV3(Amount.ofTokens(10).toSubunits())));
    var parameters = new ArrayList<Object[]>();
    for (var scrypt : scrypts) {
        for (var startAmount : startAmounts) {
            for (var stakeAmount : stakeAmounts) {
                var param = new Object[] { startAmount, stakeAmount, scrypt.getFirst(), scrypt.getSecond() };
                parameters.add(param);
            }
        }
    }
    return parameters;
}
Also used : StakingConstraintScryptV4(com.radixdlt.application.tokens.scrypt.StakingConstraintScryptV4) SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) ArrayList(java.util.ArrayList) StakeTokensConstructorV3(com.radixdlt.application.tokens.construction.StakeTokensConstructorV3) ValidatorConstraintScryptV2(com.radixdlt.application.validators.scrypt.ValidatorConstraintScryptV2) TokensConstraintScryptV3(com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3) ValidatorUpdateOwnerConstraintScrypt(com.radixdlt.application.validators.scrypt.ValidatorUpdateOwnerConstraintScrypt)

Aggregations

SystemConstraintScrypt (com.radixdlt.application.system.scrypt.SystemConstraintScrypt)18 CMAtomOS (com.radixdlt.atomos.CMAtomOS)17 ConstraintMachine (com.radixdlt.constraintmachine.ConstraintMachine)17 REParser (com.radixdlt.engine.parser.REParser)17 Before (org.junit.Before)17 CreateSystemConstructorV2 (com.radixdlt.application.system.construction.CreateSystemConstructorV2)16 CreateMutableTokenConstructor (com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor)11 MintTokenConstructor (com.radixdlt.application.tokens.construction.MintTokenConstructor)11 TokensConstraintScryptV3 (com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3)7 ValidatorConstraintScryptV2 (com.radixdlt.application.validators.scrypt.ValidatorConstraintScryptV2)6 EpochUpdateConstraintScrypt (com.radixdlt.application.system.scrypt.EpochUpdateConstraintScrypt)4 RoundUpdateConstraintScrypt (com.radixdlt.application.system.scrypt.RoundUpdateConstraintScrypt)4 TransferTokensConstructorV2 (com.radixdlt.application.tokens.construction.TransferTokensConstructorV2)4 FeeReservePutConstructor (com.radixdlt.application.system.construction.FeeReservePutConstructor)3 RegisterValidatorConstructor (com.radixdlt.application.validators.construction.RegisterValidatorConstructor)3 ValidatorUpdateRakeConstraintScrypt (com.radixdlt.application.validators.scrypt.ValidatorUpdateRakeConstraintScrypt)3 FeeReserveCompleteConstructor (com.radixdlt.application.system.construction.FeeReserveCompleteConstructor)2 NextEpochConstructorV3 (com.radixdlt.application.system.construction.NextEpochConstructorV3)2 StakeTokensConstructorV3 (com.radixdlt.application.tokens.construction.StakeTokensConstructorV3)2 StakingConstraintScryptV4 (com.radixdlt.application.tokens.scrypt.StakingConstraintScryptV4)2