Search in sources :

Example 1 with TokensConstraintScryptV3

use of com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3 in project radixdlt by radixdlt.

the class ResourceFeeTest method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new TokensConstraintScryptV3(Set.of("xrd"), Pattern.compile("[a-z0-9]+")));
    cmAtomOS.load(new SystemConstraintScrypt());
    var feeTable = FeeTable.create(Amount.zero(), Map.of(TokenResource.class, Amount.ofTokens(1)));
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization(), UpSubstateFeeMeter.create(feeTable.getPerUpSubstateFee()));
    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(FeeReserveComplete.class, new FeeReserveCompleteConstructor(feeTable)).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, Amount.ofTokens(4).toSubunits()))).buildWithoutSignature();
    this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) TokenResource(com.radixdlt.application.tokens.state.TokenResource) FeeReserveCompleteConstructor(com.radixdlt.application.system.construction.FeeReserveCompleteConstructor) 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) 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 2 with TokensConstraintScryptV3

use of com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3 in project radixdlt by radixdlt.

the class TxnSizeFeeTest 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(), TxnSizeFeeMeter.create(costPerByte.toSubunits(), MAX_SIZE));
    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(FeeReserveComplete.class, new FeeReserveCompleteConstructor(FeeTable.create(costPerByte, Map.of()))).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, Amount.ofTokens(2).toSubunits()))).buildWithoutSignature();
    this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Also used : SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) FeeReserveCompleteConstructor(com.radixdlt.application.system.construction.FeeReserveCompleteConstructor) 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) 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 3 with TokensConstraintScryptV3

use of com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3 in project radixdlt by radixdlt.

the class BurnTokensV3Test method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    cmAtomOS.load(new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")));
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
    var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    var serialization = cmAtomOS.buildSubstateSerialization();
    EngineStore<Void> store = new InMemoryEngineStore<>();
    this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(BurnToken.class, new BurnTokenConstructor()).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) InMemoryEngineStore(com.radixdlt.store.InMemoryEngineStore) MintTokenConstructor(com.radixdlt.application.tokens.construction.MintTokenConstructor) CMAtomOS(com.radixdlt.atomos.CMAtomOS) TokensConstraintScryptV3(com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3) BurnTokenConstructor(com.radixdlt.application.tokens.construction.BurnTokenConstructor) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) Before(org.junit.Before)

Example 4 with TokensConstraintScryptV3

use of com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3 in project radixdlt by radixdlt.

the class TokenResourceTest method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    cmAtomOS.load(new TokensConstraintScryptV3(Set.of("xrd"), Pattern.compile("[a-z0-9]+")));
    var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
    this.parser = new REParser(cmAtomOS.buildSubstateDeserialization());
    this.serialization = cmAtomOS.buildSubstateSerialization();
    this.store = new InMemoryEngineStore<>();
    this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).build(), cm, store);
    this.genesis = this.engine.construct(new CreateSystem(0)).buildWithoutSignature();
    this.engine.execute(List.of(this.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) TokensConstraintScryptV3(com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) Before(org.junit.Before)

Example 5 with TokensConstraintScryptV3

use of com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3 in project radixdlt by radixdlt.

the class NextViewV2Test method setup.

@Before
public void setup() throws Exception {
    var cmAtomOS = new CMAtomOS();
    cmAtomOS.load(new SystemConstraintScrypt());
    scrypts.forEach(cmAtomOS::load);
    cmAtomOS.load(new StakingConstraintScryptV4(Amount.ofTokens(10).toSubunits()));
    cmAtomOS.load(new TokensConstraintScryptV3(Set.of(), Pattern.compile("[a-z0-9]+")));
    cmAtomOS.load(new ValidatorConstraintScryptV2());
    cmAtomOS.load(new ValidatorRegisterConstraintScrypt());
    cmAtomOS.load(new ValidatorUpdateRakeConstraintScrypt(2));
    cmAtomOS.load(new ValidatorUpdateOwnerConstraintScrypt());
    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.sut = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(NextEpoch.class, new NextEpochConstructorV3(Amount.ofTokens(10).toSubunits(), 9800, 1, 10)).put(CreateSystem.class, new CreateSystemConstructorV2()).put(CreateMutableToken.class, new CreateMutableTokenConstructor(SystemConstraintScrypt.MAX_SYMBOL_LENGTH)).put(MintToken.class, new MintTokenConstructor()).put(StakeTokens.class, new StakeTokensConstructorV3(Amount.ofTokens(10).toSubunits())).put(NextRound.class, nextViewConstructor).put(RegisterValidator.class, new RegisterValidatorConstructor()).build(), cm, store);
    this.key = ECKeyPair.generateNew();
    var accountAddr = REAddr.ofPubKeyAccount(key.getPublicKey());
    var txn = this.sut.construct(TxnConstructionRequest.create().action(new CreateSystem(0)).action(new CreateMutableToken(REAddr.ofNativeToken(), "xrd", "xrd", "", "", "", null)).action(new MintToken(REAddr.ofNativeToken(), accountAddr, Amount.ofTokens(10).toSubunits())).action(new StakeTokens(accountAddr, key.getPublicKey(), Amount.ofTokens(10).toSubunits())).action(new RegisterValidator(key.getPublicKey())).action(new NextEpoch(0))).buildWithoutSignature();
    this.sut.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
Also used : StakingConstraintScryptV4(com.radixdlt.application.tokens.scrypt.StakingConstraintScryptV4) SystemConstraintScrypt(com.radixdlt.application.system.scrypt.SystemConstraintScrypt) StakeTokensConstructorV3(com.radixdlt.application.tokens.construction.StakeTokensConstructorV3) REParser(com.radixdlt.engine.parser.REParser) RegisterValidatorConstructor(com.radixdlt.application.validators.construction.RegisterValidatorConstructor) ValidatorConstraintScryptV2(com.radixdlt.application.validators.scrypt.ValidatorConstraintScryptV2) MintTokenConstructor(com.radixdlt.application.tokens.construction.MintTokenConstructor) CMAtomOS(com.radixdlt.atomos.CMAtomOS) ValidatorUpdateOwnerConstraintScrypt(com.radixdlt.application.validators.scrypt.ValidatorUpdateOwnerConstraintScrypt) ValidatorRegisterConstraintScrypt(com.radixdlt.application.validators.scrypt.ValidatorRegisterConstraintScrypt) NextEpochConstructorV3(com.radixdlt.application.system.construction.NextEpochConstructorV3) CreateSystemConstructorV2(com.radixdlt.application.system.construction.CreateSystemConstructorV2) TokensConstraintScryptV3(com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3) ConstraintMachine(com.radixdlt.constraintmachine.ConstraintMachine) ValidatorUpdateRakeConstraintScrypt(com.radixdlt.application.validators.scrypt.ValidatorUpdateRakeConstraintScrypt) CreateMutableTokenConstructor(com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor) Before(org.junit.Before)

Aggregations

TokensConstraintScryptV3 (com.radixdlt.application.tokens.scrypt.TokensConstraintScryptV3)8 SystemConstraintScrypt (com.radixdlt.application.system.scrypt.SystemConstraintScrypt)7 CreateSystemConstructorV2 (com.radixdlt.application.system.construction.CreateSystemConstructorV2)6 CreateMutableTokenConstructor (com.radixdlt.application.tokens.construction.CreateMutableTokenConstructor)6 MintTokenConstructor (com.radixdlt.application.tokens.construction.MintTokenConstructor)6 CMAtomOS (com.radixdlt.atomos.CMAtomOS)6 ConstraintMachine (com.radixdlt.constraintmachine.ConstraintMachine)6 REParser (com.radixdlt.engine.parser.REParser)6 Before (org.junit.Before)6 FeeReservePutConstructor (com.radixdlt.application.system.construction.FeeReservePutConstructor)3 StakeTokensConstructorV3 (com.radixdlt.application.tokens.construction.StakeTokensConstructorV3)3 TransferTokensConstructorV2 (com.radixdlt.application.tokens.construction.TransferTokensConstructorV2)3 StakingConstraintScryptV4 (com.radixdlt.application.tokens.scrypt.StakingConstraintScryptV4)3 ValidatorConstraintScryptV2 (com.radixdlt.application.validators.scrypt.ValidatorConstraintScryptV2)3 ValidatorUpdateOwnerConstraintScrypt (com.radixdlt.application.validators.scrypt.ValidatorUpdateOwnerConstraintScrypt)3 FeeReserveCompleteConstructor (com.radixdlt.application.system.construction.FeeReserveCompleteConstructor)2 ArrayList (java.util.ArrayList)2 FeeReserveTakeConstructor (com.radixdlt.application.system.construction.FeeReserveTakeConstructor)1 NextEpochConstructorV3 (com.radixdlt.application.system.construction.NextEpochConstructorV3)1 EpochUpdateConstraintScrypt (com.radixdlt.application.system.scrypt.EpochUpdateConstraintScrypt)1