Skip to content

Commit

Permalink
Revert "chore: prepare for 2.18.2 release (#1236)"
Browse files Browse the repository at this point in the history
This reverts commit 8e81003.
  • Loading branch information
dikel committed Nov 29, 2022
1 parent f3b2d59 commit e81ce33
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 326 deletions.
14 changes: 1 addition & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.19.0

### Added
- `freezeWith()` and `sign()` to `ContractCreateFlow`

### Fixed
- `Executable.execute(Client client, Duration timeout)` now sets gRPC deadline to the underlying gRPC request
- Transaction sometimes being reported as duplicate when submitting large number of transactions
- `RejectedExecutionException` under heavy load
- `nodes` not clearing when reusing transaction
- Renamed allowanceSpenderAccountId to spenderId in TokenNftInfo

## 2.18.2
## Unreleased

### Fixed
- `Client.close()` now tracks and automatically unsubscribes from Mirror Node Topic Queries
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Select _one_ of the following depending on your target platform.

```groovy
// Android, Corda DJVM, Java 7+
implementation 'com.hedera.hashgraph:sdk-jdk7:2.19.0'
implementation 'com.hedera.hashgraph:sdk-jdk7:2.18.1'
// Java 9+, Kotlin
implementation 'com.hedera.hashgraph:sdk:2.19.0'
implementation 'com.hedera.hashgraph:sdk:2.18.1'
```

Select _one_ of the following to provide the gRPC implementation.
Expand Down Expand Up @@ -61,14 +61,14 @@ Select _one_ of the following depending on your target platform.
<dependency>
<groupId>com.hedera.hashgraph</groupId>
<artifactId>sdk-jdk7</artifactId>
<version>2.19.0</version>
<version>2.18.1</version>
</dependency>

<!-- Java 9+, Kotlin -->
<dependency>
<groupId>com.hedera.hashgraph</groupId>
<artifactId>sdk</artifactId>
<version>2.19.0</version>
<version>2.18.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
errorprone "com.google.errorprone:error_prone_core:2.16"

// https://github.com/uber/NullAway
errorprone "com.uber.nullaway:nullaway:0.10.5"
errorprone "com.uber.nullaway:nullaway:0.10.4"

// https://github.com/grpc/grpc-java-api-checker
errorprone "io.grpc:grpc-java-api-checker:1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion example-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.hedera.hashgraph:sdk-jdk7:2.19.0'
implementation 'com.hedera.hashgraph:sdk-jdk7:2.18.1'

implementation 'org.slf4j:slf4j-simple:2.0.3'
implementation 'io.grpc:grpc-okhttp:1.46.0'
Expand Down
4 changes: 2 additions & 2 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ dependencies {
implementation project(":sdk")

implementation "com.google.code.gson:gson:2.10"
implementation "org.slf4j:slf4j-simple:2.0.5"
implementation "io.grpc:grpc-netty-shaded:1.51.0"
implementation "org.slf4j:slf4j-simple:2.0.3"
implementation "io.grpc:grpc-netty-shaded:1.50.2"
implementation "io.github.cdimascio:java-dotenv:5.3.1"
implementation "com.google.errorprone:error_prone_core:2.16"
}
Expand Down
16 changes: 8 additions & 8 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ dependencies {
implementation group: 'org.bouncycastle', name: 'bcpkix-jdk15to18', version: '1.72'

// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:2.0.5'
implementation 'org.slf4j:slf4j-api:2.0.3'

implementation "io.grpc:grpc-core:1.51.0"
implementation "io.grpc:grpc-stub:1.51.0"
implementation "io.grpc:grpc-core:1.50.2"
implementation "io.grpc:grpc-stub:1.50.2"

implementation "com.google.code.gson:gson:2.10"
implementation 'javax.annotation:javax.annotation-api:1.3.2'
Expand All @@ -55,12 +55,12 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.9.1"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.9.1"

testRuntimeOnly "org.slf4j:slf4j-simple:2.0.5"
testRuntimeOnly "io.grpc:grpc-netty-shaded:1.51.0"
testRuntimeOnly 'org.slf4j:slf4j-nop:2.0.5'
testRuntimeOnly "org.slf4j:slf4j-simple:2.0.3"
testRuntimeOnly "io.grpc:grpc-netty-shaded:1.50.2"
testRuntimeOnly 'org.slf4j:slf4j-nop:2.0.3'

integrationTestRuntimeOnly 'io.grpc:grpc-netty-shaded:1.50.2'
integrationTestRuntimeOnly 'org.slf4j:slf4j-nop:2.0.4'
integrationTestRuntimeOnly 'org.slf4j:slf4j-nop:2.0.2'
}

// https://github.com/google/protobuf-gradle-plugin
Expand All @@ -70,7 +70,7 @@ protobuf {
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.51.0"
artifact = "io.grpc:protoc-gen-grpc-java:1.50.2"
}
}
}
Expand Down
104 changes: 5 additions & 99 deletions sdk/src/integrationTest/java/ContractCreateFlowIntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import com.hedera.hashgraph.sdk.*;
import com.hedera.hashgraph.sdk.ContractCreateFlow;
import com.hedera.hashgraph.sdk.ContractDeleteTransaction;
import com.hedera.hashgraph.sdk.ContractExecuteTransaction;
import com.hedera.hashgraph.sdk.ContractFunctionParameters;
import com.hedera.hashgraph.sdk.Status;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Objects;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class ContractCreateFlowIntegrationTest {
private static final String SMART_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b506040516104d73803806104d78339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b506040525050600080546001600160a01b0319163317905550805161010890600190602084019061010f565b50506101aa565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015057805160ff191683800117855561017d565b8280016001018555821561017d579182015b8281111561017d578251825591602001919060010190610162565b5061018992915061018d565b5090565b6101a791905b808211156101895760008155600101610193565b90565b61031e806101b96000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063368b87721461004657806341c0e1b5146100ee578063ce6d41de146100f6575b600080fd5b6100ec6004803603602081101561005c57600080fd5b81019060208101813564010000000081111561007757600080fd5b82018360208201111561008957600080fd5b803590602001918460018302840111640100000000831117156100ab57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610173945050505050565b005b6100ec6101a2565b6100fe6101ba565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610138578181015183820152602001610120565b50505050905090810190601f1680156101655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000546001600160a01b0316331461018a5761019f565b805161019d906001906020840190610250565b505b50565b6000546001600160a01b03163314156101b85733ff5b565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156102455780601f1061021a57610100808354040283529160200191610245565b820191906000526020600020905b81548152906001019060200180831161022857829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061029157805160ff19168380011785556102be565b828001600101855582156102be579182015b828111156102be5782518255916020019190600101906102a3565b506102ca9291506102ce565b5090565b61024d91905b808211156102ca57600081556001016102d456fea264697066735822122084964d4c3f6bc912a9d20e14e449721012d625aa3c8a12de41ae5519752fc89064736f6c63430006000033";
Expand Down Expand Up @@ -43,101 +46,4 @@ void createContractWithFlow() throws Throwable {

testEnv.close();
}

@Test
@DisplayName("Create contract with flow without signing")
void createContractWithFlowWithoutSigning() throws Throwable {
var testEnv = new IntegrationTestEnv(1);
var adminKey = PrivateKey.generateED25519();

assertThatThrownBy(() -> new ContractCreateFlow()
.setBytecode(SMART_CONTRACT_BYTECODE)
.setAdminKey(adminKey)
.setGas(100000)
.setConstructorParameters(new ContractFunctionParameters().addString("Hello from Hedera."))
.setContractMemo("[e2e::ContractCreateFlow]")
.execute(testEnv.client))
.isInstanceOf(RuntimeException.class)
.hasMessageEndingWith("raised status INVALID_SIGNATURE");

testEnv.close();
}

@Test
@DisplayName("Create contract with flow and sign with private key")
void createContractWithFlowPrivateKeySign() throws Throwable {
var testEnv = new IntegrationTestEnv(1);
var adminKey = PrivateKey.generateED25519();

var response = new ContractCreateFlow()
.setBytecode(SMART_CONTRACT_BYTECODE)
.setAdminKey(testEnv.operatorKey)
.setGas(100000)
.setConstructorParameters(new ContractFunctionParameters().addString("Hello from Hedera."))
.setContractMemo("[e2e::ContractCreateFlow]")
.freezeWith(testEnv.client)
.sign(adminKey)
.execute(testEnv.client);

var contractId = Objects.requireNonNull(response.getReceipt(testEnv.client).contractId);

var receipt = new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(100000)
.setFunction("setMessage", new ContractFunctionParameters().addString("new message"))
.execute(testEnv.client)
.getReceipt(testEnv.client);

assertThat(receipt.status).isEqualTo(Status.SUCCESS);

new ContractDeleteTransaction()
.setTransferAccountId(testEnv.operatorId)
.setContractId(contractId)
.setTransferAccountId(testEnv.operatorId)
.freezeWith(testEnv.client)
.sign(adminKey)
.execute(testEnv.client)
.getReceipt(testEnv.client);

testEnv.close();
}

@Test
@DisplayName("Create contract with flow and sign with public key and transaction signer")
void createContractWithFlowPublicKeySign() throws Throwable {
var testEnv = new IntegrationTestEnv(1);
var adminKey = PrivateKey.generateED25519();

var response = new ContractCreateFlow()
.setBytecode(SMART_CONTRACT_BYTECODE)
.setAdminKey(testEnv.operatorKey)
.setGas(100000)
.setConstructorParameters(new ContractFunctionParameters().addString("Hello from Hedera."))
.setContractMemo("[e2e::ContractCreateFlow]")
.freezeWith(testEnv.client)
.signWith(adminKey.getPublicKey(), adminKey::sign)
.execute(testEnv.client);

var contractId = Objects.requireNonNull(response.getReceipt(testEnv.client).contractId);

var receipt = new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(100000)
.setFunction("setMessage", new ContractFunctionParameters().addString("new message"))
.execute(testEnv.client)
.getReceipt(testEnv.client);

assertThat(receipt.status).isEqualTo(Status.SUCCESS);

new ContractDeleteTransaction()
.setTransferAccountId(testEnv.operatorId)
.setContractId(contractId)
.setTransferAccountId(testEnv.operatorId)
.freezeWith(testEnv.client)
.sign(adminKey)
.execute(testEnv.client)
.getReceipt(testEnv.client);

testEnv.close();
}
}
1 change: 0 additions & 1 deletion sdk/src/main/java/com/hedera/hashgraph/sdk/BaseNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ synchronized ManagedChannel getChannel() {
.keepAliveTimeout(10, TimeUnit.SECONDS)
.userAgent(getUserAgent())
.executor(executor)
.disableRetry()
.build();

return channel;
Expand Down
39 changes: 3 additions & 36 deletions sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import static com.hedera.hashgraph.sdk.BaseNodeAddress.PORT_NODE_PLAIN;
Expand All @@ -61,7 +60,6 @@ public final class Client implements AutoCloseable {
static final Duration DEFAULT_MIN_NODE_BACKOFF = Duration.ofSeconds(8L);
static final Duration DEFAULT_CLOSE_TIMEOUT = Duration.ofSeconds(30L);
static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofMinutes(2L);
static final Duration DEFAULT_GRPC_DEADLINE = Duration.ofSeconds(10L);
static final Duration DEFAULT_NETWORK_UPDATE_PERIOD = Duration.ofHours(24);
// Initial delay of 10 seconds before we update the network for the first time,
// so that this doesn't happen in unit tests.
Expand All @@ -85,7 +83,6 @@ public final class Client implements AutoCloseable {

private Duration requestTimeout = DEFAULT_REQUEST_TIMEOUT;
private Duration closeTimeout = DEFAULT_CLOSE_TIMEOUT;
private final AtomicReference<Duration> grpcDeadline = new AtomicReference(DEFAULT_GRPC_DEADLINE);

private int maxAttempts = DEFAULT_MAX_ATTEMPTS;

Expand Down Expand Up @@ -139,11 +136,9 @@ static ExecutorService createExecutor() {
.setDaemon(true)
.build();

int nThreads = Runtime.getRuntime().availableProcessors();
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
return Executors.newFixedThreadPool(
Runtime.getRuntime().availableProcessors(),
threadFactory);
}

/**
Expand Down Expand Up @@ -1245,34 +1240,6 @@ public Client setCloseTimeout(Duration closeTimeout) {
return this;
}

/**
* Maximum amount of time a gRPC request can run
*
* @return the gRPC deadline value
*/
@SuppressFBWarnings(
value = "EI_EXPOSE_REP",
justification = "A Duration can't actually be mutated"
)
public Duration getGrpcDeadline() {
return grpcDeadline.get();
}

/**
* Set the maximum amount of time a gRPC request can run.
*
* @param grpcDeadline the gRPC deadline value
* @return {@code this}
*/
@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "A Duration can't actually be mutated"
)
public Client setGrpcDeadline(Duration grpcDeadline) {
this.grpcDeadline.set(Objects.requireNonNull(grpcDeadline));
return this;
}

/**
* Extract the operator.
*
Expand Down
Loading

0 comments on commit e81ce33

Please sign in to comment.