Search in sources :

Example 1 with ONE_HUNDRED_HBARS

use of com.hedera.services.bdd.suites.HapiApiSuite.ONE_HUNDRED_HBARS in project hedera-services by hashgraph.

the class UtilVerbs method updateSpecialFile.

public static HapiSpecOperation updateSpecialFile(final String payer, final String fileName, final ByteString contents, final int bytesPerOp, final int appendsPerBurst) {
    return withOpContext((spec, opLog) -> {
        final var bytesToUpload = contents.size();
        final var bytesToAppend = bytesToUpload - bytesPerOp;
        final var appendsRequired = bytesToAppend / bytesPerOp + Math.min(1, bytesToAppend % bytesPerOp);
        COMMON_MESSAGES.info("Beginning update for " + fileName + " (" + appendsRequired + " appends required)");
        final var numBursts = appendsRequired / appendsPerBurst + Math.min(1, appendsRequired % appendsPerBurst);
        int position = Math.min(bytesPerOp, bytesToUpload);
        final var updateSubOp = fileUpdate(fileName).fee(ONE_HUNDRED_HBARS).contents(contents.substring(0, position)).alertingPre(fid -> COMMON_MESSAGES.info("Submitting initial update for file 0.0." + fid.getFileNum())).alertingPost(code -> COMMON_MESSAGES.info("Finished initial update with " + code)).noLogging().payingWith(payer).signedBy(payer);
        allRunFor(spec, updateSubOp);
        final AtomicInteger burstNo = new AtomicInteger(1);
        while (position < bytesToUpload) {
            final var totalBytesLeft = bytesToUpload - position;
            final var appendsLeft = totalBytesLeft / bytesPerOp + Math.min(1, totalBytesLeft % bytesPerOp);
            final var appendsHere = new AtomicInteger(Math.min(appendsPerBurst, appendsLeft));
            boolean isFirstAppend = true;
            final List<HapiSpecOperation> theBurst = new ArrayList<>();
            final CountDownLatch burstLatch = new CountDownLatch(1);
            final AtomicReference<Instant> burstStart = new AtomicReference<>();
            while (appendsHere.getAndDecrement() >= 0) {
                final var bytesLeft = bytesToUpload - position;
                final var bytesThisAppend = Math.min(bytesLeft, bytesPerOp);
                final var newPosition = position + bytesThisAppend;
                final var appendSubOp = fileAppend(fileName).content(contents.substring(position, newPosition).toByteArray()).fee(ONE_HUNDRED_HBARS).noLogging().payingWith(payer).signedBy(payer).deferStatusResolution();
                if (isFirstAppend) {
                    final var fixedBurstNo = burstNo.get();
                    final var fixedAppendsHere = appendsHere.get() + 1;
                    appendSubOp.alertingPre(fid -> {
                        burstStart.set(Instant.now());
                        COMMON_MESSAGES.info("Starting burst " + fixedBurstNo + "/" + numBursts + " (" + fixedAppendsHere + " ops)");
                    });
                    isFirstAppend = false;
                }
                if (appendsHere.get() < 0) {
                    final var fixedBurstNo = burstNo.get();
                    appendSubOp.alertingPost(code -> {
                        final var burstSecs = Duration.between(burstStart.get(), Instant.now()).getSeconds();
                        COMMON_MESSAGES.info("Completed burst #" + fixedBurstNo + "/" + numBursts + " in " + burstSecs + "s with " + code);
                        burstLatch.countDown();
                    });
                }
                theBurst.add(appendSubOp);
                position = newPosition;
            }
            allRunFor(spec, theBurst);
            burstLatch.await();
            burstNo.getAndIncrement();
        }
    });
}
Also used : FeesJsonToGrpcBytes(com.hedera.services.bdd.suites.utils.sysfiles.serdes.FeesJsonToGrpcBytes) TxnUtils.asTransactionID(com.hedera.services.bdd.spec.transactions.TxnUtils.asTransactionID) COMMON_MESSAGES(com.hedera.services.yahcli.output.CommonMessages.COMMON_MESSAGES) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) ParallelSpecOps(com.hedera.services.bdd.spec.utilops.grouping.ParallelSpecOps) VerifyGetLiveHashNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetLiveHashNotSupported) CryptoTransferSuite(com.hedera.services.bdd.suites.crypto.CryptoTransferSuite) RecordStreamVerification(com.hedera.services.bdd.spec.utilops.streams.RecordStreamVerification) Duration(java.time.Duration) Map(java.util.Map) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) HapiPropertySource.asAccount(com.hedera.services.bdd.spec.HapiPropertySource.asAccount) Set(java.util.Set) SpecKeyFromPem(com.hedera.services.bdd.spec.utilops.inventory.SpecKeyFromPem) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) FREEZE_ONLY(com.hederahashgraph.api.proto.java.FreezeType.FREEZE_ONLY) CountDownLatch(java.util.concurrent.CountDownLatch) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) Stream(java.util.stream.Stream) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TxnVerbs.tokenDissociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDissociate) BUSY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) PLATFORM_TRANSACTION_NOT_CREATED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PLATFORM_TRANSACTION_NOT_CREATED) FeeSchedule(com.hederahashgraph.api.proto.java.FeeSchedule) SpecKeyFromMnemonic(com.hedera.services.bdd.spec.utilops.inventory.SpecKeyFromMnemonic) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HapiFileCreate(com.hedera.services.bdd.spec.transactions.file.HapiFileCreate) SequentialID(com.hedera.services.bdd.spec.assertions.SequentialID) ObjIntConsumer(java.util.function.ObjIntConsumer) Supplier(java.util.function.Supplier) Setting(com.hederahashgraph.api.proto.java.Setting) ArrayList(java.util.ArrayList) NewSpecKey(com.hedera.services.bdd.spec.utilops.inventory.NewSpecKey) OptionalLong(java.util.OptionalLong) NodeLivenessTimeout(com.hedera.services.bdd.spec.utilops.pauses.NodeLivenessTimeout) StartThroughputObs(com.hedera.services.bdd.spec.utilops.throughput.StartThroughputObs) DUPLICATE_TRANSACTION(com.hederahashgraph.api.proto.java.ResponseCodeEnum.DUPLICATE_TRANSACTION) RecordSystemProperty(com.hedera.services.bdd.spec.utilops.inventory.RecordSystemProperty) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AccountID(com.hederahashgraph.api.proto.java.AccountID) HapiPropertySource.asAccountString(com.hedera.services.bdd.spec.HapiPropertySource.asAccountString) Properties(java.util.Properties) SysFileSerde(com.hedera.services.bdd.suites.utils.sysfiles.serdes.SysFileSerde) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Files(java.nio.file.Files) ADDRESS_BOOK_CONTROL(com.hedera.services.bdd.suites.HapiApiSuite.ADDRESS_BOOK_CONTROL) IOException(java.io.IOException) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) SpecKeyFromMutation(com.hedera.services.bdd.spec.utilops.inventory.SpecKeyFromMutation) SpecKeyFromLiteral(com.hedera.services.bdd.spec.utilops.inventory.SpecKeyFromLiteral) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) HapiMessageSubmit(com.hedera.services.bdd.spec.transactions.consensus.HapiMessageSubmit) Paths(java.nio.file.Paths) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) FinishThroughputObs(com.hedera.services.bdd.spec.utilops.throughput.FinishThroughputObs) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) FREEZE_ABORT(com.hederahashgraph.api.proto.java.FreezeType.FREEZE_ABORT) System.arraycopy(java.lang.System.arraycopy) HapiSpecWaitUntil(com.hedera.services.bdd.spec.utilops.pauses.HapiSpecWaitUntil) EXCHANGE_RATE_CONTROL(com.hedera.services.bdd.suites.HapiApiSuite.EXCHANGE_RATE_CONTROL) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) VerifyGetFastRecordNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetFastRecordNotSupported) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) ContractID(com.hederahashgraph.api.proto.java.ContractID) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) VerifyGetTokenNftInfosNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetTokenNftInfosNotSupported) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VerifyGetAccountNftInfosNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetAccountNftInfosNotSupported) OpProvider(com.hedera.services.bdd.spec.infrastructure.OpProvider) ParseException(java.text.ParseException) HapiSpecSleep(com.hedera.services.bdd.spec.utilops.pauses.HapiSpecSleep) APP_PROPERTIES(com.hedera.services.bdd.suites.HapiApiSuite.APP_PROPERTIES) GENESIS(com.hedera.services.bdd.suites.HapiApiSuite.GENESIS) NewSpecKeyList(com.hedera.services.bdd.spec.utilops.inventory.NewSpecKeyList) CurrentAndNextFeeSchedule(com.hederahashgraph.api.proto.java.CurrentAndNextFeeSchedule) UsableTxnId(com.hedera.services.bdd.spec.utilops.inventory.UsableTxnId) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ONE_HBAR(com.hedera.services.bdd.suites.HapiApiSuite.ONE_HBAR) ByteString(com.google.protobuf.ByteString) List(java.util.List) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) FREEZE_UPGRADE(com.hederahashgraph.api.proto.java.FreezeType.FREEZE_UPGRADE) Optional(java.util.Optional) PREPARE_UPGRADE(com.hederahashgraph.api.proto.java.FreezeType.PREPARE_UPGRADE) VerifyGetStakersNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetStakersNotSupported) HapiCryptoTransfer(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer) HapiFileUpdate(com.hedera.services.bdd.spec.transactions.file.HapiFileUpdate) BYTES_4K(com.hedera.services.bdd.spec.transactions.TxnUtils.BYTES_4K) ONE_HUNDRED_HBARS(com.hedera.services.bdd.suites.HapiApiSuite.ONE_HUNDRED_HBARS) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) HashMap(java.util.HashMap) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Tuple(com.esaulpaugh.headlong.abi.Tuple) InBlockingOrder(com.hedera.services.bdd.spec.utilops.grouping.InBlockingOrder) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.fileAppend(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileAppend) HCSChunkingRealisticPerfSuite(com.hedera.services.bdd.suites.perf.topic.HCSChunkingRealisticPerfSuite) VerifyGetBySolidityIdNotSupported(com.hedera.services.bdd.spec.utilops.checks.VerifyGetBySolidityIdNotSupported) QueryVerbs.getFileContents(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents) SpecKeyFromFile(com.hedera.services.bdd.spec.utilops.inventory.SpecKeyFromFile) FEE_SCHEDULE_FILE_PART_UPLOADED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FEE_SCHEDULE_FILE_PART_UPLOADED) HapiFileAppend(com.hedera.services.bdd.spec.transactions.file.HapiFileAppend) HapiFreeze(com.hedera.services.bdd.spec.transactions.system.HapiFreeze) TELEMETRY_UPGRADE(com.hederahashgraph.api.proto.java.FreezeType.TELEMETRY_UPGRADE) FeeData(com.hederahashgraph.api.proto.java.FeeData) FileInputStream(java.io.FileInputStream) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) Consumer(java.util.function.Consumer) AbstractMap(java.util.AbstractMap) FEE_SCHEDULE(com.hedera.services.bdd.suites.HapiApiSuite.FEE_SCHEDULE) Assertions(org.junit.jupiter.api.Assertions) TransactionRecordAsserts(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts) Collections(java.util.Collections) InputStream(java.io.InputStream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Instant(java.time.Instant) ArrayList(java.util.ArrayList) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Tuple (com.esaulpaugh.headlong.abi.Tuple)1 ByteString (com.google.protobuf.ByteString)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 HapiPropertySource.asAccount (com.hedera.services.bdd.spec.HapiPropertySource.asAccount)1 HapiPropertySource.asAccountString (com.hedera.services.bdd.spec.HapiPropertySource.asAccountString)1 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 ContractInfoAsserts.contractWith (com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith)1 SequentialID (com.hedera.services.bdd.spec.assertions.SequentialID)1 TransactionRecordAsserts (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts)1 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)1 OpProvider (com.hedera.services.bdd.spec.infrastructure.OpProvider)1 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)1 QueryVerbs.getContractInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo)1 QueryVerbs.getFileContents (com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents)1 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)1 HapiGetTxnRecord (com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord)1 BYTES_4K (com.hedera.services.bdd.spec.transactions.TxnUtils.BYTES_4K)1 TxnUtils.asId (com.hedera.services.bdd.spec.transactions.TxnUtils.asId)1 TxnUtils.asTransactionID (com.hedera.services.bdd.spec.transactions.TxnUtils.asTransactionID)1