Skip to content

Commit

Permalink
Merge pull request #14 from iExecBlockchainComputing/release/2.0.0
Browse files Browse the repository at this point in the history
Release/2.0.0
  • Loading branch information
mcornaton authored May 11, 2023
2 parents 0b68030 + be2e95d commit a989989
Show file tree
Hide file tree
Showing 52 changed files with 4,328 additions and 241 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file.

## [[2.0.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v2.0.0) 2023

### New Features
- Upgrade `web3j` dependency from 4.8.9 to 4.9.7. (#8)
- Regenerate all wrappers with new web3j cli version. (#8)
- Update the readme file with the generation instructions. (#8)
- Add `PLEASE_CONTRIBUTE_AND_FINALIZE` to `TaskNotificationType`. (#9)
- Add `com.iexec.commmons.poco.order` package. (#10)
- Add `com.iexec.commons.poco.eip712` package. (#11)
- Add `MatchOrdersTests` on nethermind `poco-chain`. (#12)
### Bug Fixes
- Set `protected` visibility on abstract classes constructors. (#13)

## [[1.0.2]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v1.0.2) 2023-04-11

### Bug Fixes
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# iexec-commons-poco
PoCo Java wrappers for the iExec platform


## Steps to generate Java Wrappers for Smart Contracts

First you need to install last version of Web3j CLI, the simplest way to install the Web3j CLI is via the following script:

```
curl -L get.web3j.io | sh && source ~/.web3j/source.sh
```
Verify the installation was successful
```
web3j -v
Version: 1.4.2
```

After, you need to clone `Poco-dev` repository
```
git clone https://github.com/iExecBlockchainComputing/PoCo-dev/
cd PoCo-dev
git checkout x.y.z
```

Edit script `generateContractWrappers` and check lines *15* and *18*. If necessary, adjust the directories to match your local work tree.
``` shell
#Put here the PoCo-dev directory that contains smart contracts (JSON files)
POCO_DEV_CONTRACTS_DIRECTORY=${HOME}/iexecdev/PoCo-dev/build/contracts/

#Put here the src/main/java/ directory of commons-poco project
COMMONS_POCO_WRAPPER_DIRECTORY=${HOME}/iexecdev/iexec-commons-poco/src/main/java/
```

Clean `IexecLibOrders_v5.OrderOperationEnum` references from `IexecLibOrders_v5.json` with your favorite editor(Only in abi node).

You can now run the script
``` shell
./generateContractWrappers App AppRegistry Dataset DatasetRegistry Ownable Workerpool WorkerpoolRegistry IexecInterfaceTokenABILegacy IexecLibOrders_v5
```

After this execution and if no error has occurred, you must rename `IexecInterfaceTokenABILegacy.java` to `IexecHubContract.java` and also rename the java class.
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,35 @@ repositories {

dependencies {
implementation platform('org.springframework.boot:spring-boot-dependencies:2.6.14')
api 'org.web3j:core:4.8.9'

// web3j
api 'org.web3j:core:4.9.7'

// apache commons.lang3
implementation 'org.apache.commons:commons-lang3'

// multiaddresses (IPFS)
implementation 'com.github.multiformats:java-multiaddr:v1.4.6'

//jaxb required with Java 11
// jaxb required with Java 11 DataTypeConverter in BytesUtils
implementation 'javax.xml.bind:jaxb-api'

// failsafe
implementation 'net.jodah:failsafe:2.4.4'
//TODO Migrate from Awaitility to Failsafe everywhere
//TODO Migrate from Awaitility to Failsafe everywhere
implementation 'org.awaitility:awaitility'

//json
implementation 'javax.validation:validation-api'

// javax annotations like PostConstruct
implementation 'javax.annotation:javax.annotation-api'

// tests
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.testcontainers:junit-jupiter:1.17.2'

// logback
testRuntimeOnly 'ch.qos.logback:logback-classic'
}

java {
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
poco-chain:
image: docker-regis.iex.ec/poco-chain:native-v5.4.2-5s
expose:
- "8545"
59 changes: 59 additions & 0 deletions generateContractWrappers
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

###################################################################
#Script Name : generateContractWrappers
#Description : Script to facilitate the generation of java wrappers
#Args : list of smart contracts json files without extension
#Exemple : ./generateContractWrappers App AppRegistry
#Author : iExec
###################################################################

set -Eeuo pipefail


#Put here the PoCo-dev directory that contains smart contracts (JSON files)
POCO_DEV_CONTRACTS_DIRECTORY=${HOME}/iexecdev/PoCo-dev/build/contracts/

#Put here the src/main/java/ directory of commons-poco project
COMMONS_POCO_WRAPPER_DIRECTORY=${HOME}/iexecdev/iexec-commons-poco/src/main/java/

#Put here the java package for commons-poco Wrappers
COMMONS_POCO_PACKAGE='com.iexec.commons.poco.contract.generated'


check_mandatory_dependency(){
CMDS="web3j"

for i in $CMDS
do
command -v $i >/dev/null && continue || { echo "$i command not found."; exit 1; }
done
}

check_mandatory_directory(){
if [ ! -d "$1" ];
then
echo "$1 directory does not exist."
exit 1
fi
}

generate_wrapper() {
if test -f "$POCO_DEV_CONTRACTS_DIRECTORY$1.json"; then
web3j generate truffle --truffle-json $POCO_DEV_CONTRACTS_DIRECTORY$1.json -o $COMMONS_POCO_WRAPPER_DIRECTORY -p $COMMONS_POCO_PACKAGE
else
echo "Missing $POCO_DEV_CONTRACTS_DIRECTORY$1.json file"
exit 1
fi
}


check_mandatory_dependency
check_mandatory_directory $POCO_DEV_CONTRACTS_DIRECTORY
check_mandatory_directory $COMMONS_POCO_WRAPPER_DIRECTORY


for var in "$@"
do
generate_wrapper $var
done
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=1.0.2
version=2.0.0

nexusUser
nexusPassword
3 changes: 3 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is generated by the 'io.freefair.lombok' Gradle plugin
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,13 @@ public abstract class IexecHubAbstractService {
// /!\ TODO remove expired task descriptions
private final Map<String, TaskDescription> taskDescriptions = new HashMap<>();

public IexecHubAbstractService(Credentials credentials,
Web3jAbstractService web3jAbstractService,
String iexecHubAddress) {
protected IexecHubAbstractService(
Credentials credentials,
Web3jAbstractService web3jAbstractService,
String iexecHubAddress) {
this(credentials, web3jAbstractService, iexecHubAddress, Duration.ofMillis(DEFAULT_BLOCK_TIME), 6, 3);
}

@Deprecated
public IexecHubAbstractService(Credentials credentials,
Web3jAbstractService web3jAbstractService,
String iexecHubAddress,
int nbBlocksToWaitPerRetry,
int maxRetries) {
this(credentials, web3jAbstractService, iexecHubAddress, Duration.ofMillis(DEFAULT_BLOCK_TIME), nbBlocksToWaitPerRetry, maxRetries);
}

/**
* Base constructor for the IexecHubAbstractService
* @param credentials credentials for sending transaction
Expand All @@ -107,12 +99,13 @@ public IexecHubAbstractService(Credentials credentials,
* @param nbBlocksToWaitPerRetry nb block to wait per retry
* @param maxRetries maximum reties
*/
public IexecHubAbstractService(Credentials credentials,
Web3jAbstractService web3jAbstractService,
String iexecHubAddress,
Duration blockTime,
int nbBlocksToWaitPerRetry,
int maxRetries) {
protected IexecHubAbstractService(
Credentials credentials,
Web3jAbstractService web3jAbstractService,
String iexecHubAddress,
Duration blockTime,
int nbBlocksToWaitPerRetry,
int maxRetries) {
this.credentials = credentials;
this.web3jAbstractService = web3jAbstractService;
this.iexecHubAddress = iexecHubAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Slf4j
public abstract class Web3jAbstractService {

private static final long GAS_LIMIT_CAP = 500000;
static final long GAS_LIMIT_CAP = 1000000;
private final float gasPriceMultiplier;
private final long gasPriceCap;
private final boolean isSidechain;
Expand All @@ -53,7 +53,7 @@ public abstract class Web3jAbstractService {
* Apart from initializing usual business entities, it initializes a single
* and shared web3j instance. This inner web3j instance allows to connect to
* a remote blockchain node.
*
* <p>
* If reusing a whole web3j instance between calls might be overkilled, it
* is important to use a single and shared HttpService.
* The usage of a single HttpService ensures the creation of a single
Expand All @@ -65,10 +65,11 @@ public abstract class Web3jAbstractService {
* @param gasPriceCap gas price cap
* @param isSidechain true if iExec native chain, false if iExec token chain
*/
public Web3jAbstractService(String chainNodeAddress,
float gasPriceMultiplier,
long gasPriceCap,
boolean isSidechain) {
protected Web3jAbstractService(
String chainNodeAddress,
float gasPriceMultiplier,
long gasPriceCap,
boolean isSidechain) {
this.chainNodeAddress = chainNodeAddress;
this.gasPriceMultiplier = gasPriceMultiplier;
this.gasPriceCap = gasPriceCap;
Expand Down Expand Up @@ -328,7 +329,7 @@ static BigInteger getGasLimitForFunction(String functionName) {
gasLimit = 100000;//seen 56333
break;
case FUNC_FINALIZE:
gasLimit = 3000000;//seen 175369 (242641 in reopen case)
gasLimit = 300000;//seen 175369 (242641 in reopen case)
break;
case FUNC_REOPEN:
gasLimit = 500000;//seen 43721
Expand Down
Loading

0 comments on commit a989989

Please sign in to comment.