use of com.radixdlt.constraintmachine.ConstraintMachine 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);
}
use of com.radixdlt.constraintmachine.ConstraintMachine in project radixdlt by radixdlt.
the class UniqueTest method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new MutexConstraintScrypt());
cmAtomOS.load(new SystemConstraintScrypt());
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.sut = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(CreateSystem.class, new CreateSystemConstructorV2()).build(), cm, store);
this.genesis = this.sut.construct(TxnConstructionRequest.create().action(new CreateSystem(0))).buildWithoutSignature();
this.sut.execute(List.of(genesis), null, PermissionLevel.SYSTEM);
}
use of com.radixdlt.constraintmachine.ConstraintMachine in project radixdlt by radixdlt.
the class RegisterValidatorTest method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new SystemConstraintScrypt());
cmAtomOS.load(new RoundUpdateConstraintScrypt(2));
cmAtomOS.load(new EpochUpdateConstraintScrypt(2, UInt256.NINE, 1, 1, 100));
cmAtomOS.load(new ValidatorConstraintScryptV2());
cmAtomOS.load(new ValidatorRegisterConstraintScrypt());
cmAtomOS.load(new ValidatorUpdateRakeConstraintScrypt(2));
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
this.serialization = cmAtomOS.buildSubstateSerialization();
this.store = new InMemoryEngineStore<>();
this.engine = new RadixEngine<>(parser, serialization, REConstructor.newBuilder().put(RegisterValidator.class, new RegisterValidatorConstructor()).put(CreateSystem.class, new CreateSystemConstructorV2()).put(UpdateValidatorMetadata.class, new UpdateValidatorMetadataConstructor()).put(UpdateValidatorSystemMetadata.class, new UpdateValidatorSystemMetadataConstructor()).put(UpdateValidatorFee.class, new UpdateRakeConstructor(2, 2000)).build(), cm, store);
var txn = this.engine.construct(new CreateSystem(0)).buildWithoutSignature();
this.engine.execute(List.of(txn), null, PermissionLevel.SYSTEM);
}
use of com.radixdlt.constraintmachine.ConstraintMachine in project radixdlt by radixdlt.
the class UpdateValidatorSystemMetadataTest method setup.
@Before
public void setup() throws Exception {
var cmAtomOS = new CMAtomOS();
cmAtomOS.load(new SystemConstraintScrypt());
cmAtomOS.load(new RoundUpdateConstraintScrypt(2));
cmAtomOS.load(new EpochUpdateConstraintScrypt(2, UInt256.NINE, 1, 1, 100));
cmAtomOS.load(new ValidatorConstraintScryptV2());
var cm = new ConstraintMachine(cmAtomOS.getProcedures(), cmAtomOS.buildSubstateDeserialization(), cmAtomOS.buildVirtualSubstateDeserialization());
var parser = new REParser(cmAtomOS.buildSubstateDeserialization());
this.store = new InMemoryEngineStore<>();
this.engine = new RadixEngine<>(parser, cmAtomOS.buildSubstateSerialization(), REConstructor.newBuilder().put(UpdateValidatorSystemMetadata.class, new UpdateValidatorSystemMetadataConstructor()).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);
}
use of com.radixdlt.constraintmachine.ConstraintMachine in project radixdlt by radixdlt.
the class RadixEngine method replaceConstraintMachine.
public void replaceConstraintMachine(ConstraintMachineConfig constraintMachineConfig, SubstateSerialization serialization, REConstructor actionToConstructorMap, BatchVerifier<M> batchVerifier, REParser parser) {
synchronized (stateUpdateEngineLock) {
this.constraintMachine = new ConstraintMachine(constraintMachineConfig.getProcedures(), constraintMachineConfig.getDeserialization(), constraintMachineConfig.getVirtualSubstateDeserialization(), constraintMachineConfig.getMeter());
this.actionConstructors = actionToConstructorMap;
this.batchVerifier = batchVerifier;
this.parser = parser;
this.serialization = serialization;
}
}
Aggregations