Skip to content

Commit 0aed8ca

Browse files
authored
Harmonize YML internal variables to proper case (#171)
1 parent 3a2591f commit 0aed8ca

File tree

9 files changed

+124
-123
lines changed

9 files changed

+124
-123
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
1313

1414
- Use no more `iexec-commons-poco` deprecated code in integration tests. (#163)
1515
- Fix Spring Security deprecations after Spring Boot 3.3.8 upgrade. (#169)
16+
- Harmonize YML internal variables to proper case. (#171)
1617

1718
### Breaking API changes
1819

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ To run properly, the iExec Blockchain Adapter API requires:
2626
| `IEXEC_BLOCKCHAIN_ADAPTER_API_PASSWORD` | Login password of the server. | String | `whatever` |
2727
| `IEXEC_BLOCKCHAIN_ADAPTER_API_MONGO_HOST` | Mongo server host. Cannot be set with URI. | String | `localhost` |
2828
| `IEXEC_BLOCKCHAIN_ADAPTER_API_MONGO_PORT` | Mongo server port. Cannot be set with URI. | Positive integer | `13012` |
29-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID` | Chain ID of the blockchain network to connect. | Positive integer | `134` |
30-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN` | Define whether iExec on-chain protocol is built on top of token (`false`) or native currency (`true`). | Boolean | `true` |
31-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS` | URL to connect to the blockchain network. | URL | `https://bellecour.iex.ec` |
32-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME` | Duration between consecutive blocks on the blockchain network, in seconds. | Positive integer | `5` |
33-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS` | Proxy contract address to interact with the iExec on-chain protocol. | Ethereum Address | `0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f` |
34-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_MULTIPLIER` | Transactions will be sent with `networkGasPrice * gasPriceMultiplier`. | Float | `1.0` |
35-
| `IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_CAP` | In Wei, will be used for transactions if `networkGasPrice * gasPriceMultiplier > gasPriceCap`. | Positive integer | `22000000000` |
29+
| `IEXEC_CHAIN_ID` | Chain ID of the blockchain network to connect. | Positive integer | `134` |
30+
| `IEXEC_IS_SIDECHAIN` | Define whether iExec on-chain protocol is built on top of token (`false`) or native currency (`true`). | Boolean | `true` |
31+
| `IEXEC_BLOCKCHAIN_NODE_ADDRESS` | URL to connect to the blockchain network. | URL | `https://bellecour.iex.ec` |
32+
| `IEXEC_BLOCK_TIME` | Duration between consecutive blocks on the blockchain network, in seconds. | Positive integer | `5` |
33+
| `IEXEC_HUB_ADDRESS` | Proxy contract address to interact with the iExec on-chain protocol. | Ethereum Address | `0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f` |
34+
| `IEXEC_GAS_PRICE_MULTIPLIER` | Transactions will be sent with `networkGasPrice * gasPriceMultiplier`. | Float | `1.0` |
35+
| `IEXEC_GAS_PRICE_CAP` | In Wei, will be used for transactions if `networkGasPrice * gasPriceMultiplier > gasPriceCap`. | Positive integer | `22000000000` |
3636
| `IEXEC_BLOCKCHAIN_ADAPTER_API_MAX_ALLOWED_TX_PER_BLOCK` | Max number of transactions per block, between `1` and `4`. | Positive integer | `1` |
3737
| `IEXEC_BLOCKCHAIN_ADAPTER_API_WALLET_PATH` | Path to the wallet of the server. | String | `src/main/resources/wallet.json` |
3838
| `IEXEC_BLOCKCHAIN_ADAPTER_API_WALLET_PASSWORD` | Password to unlock the wallet of the server. | String | `whatever` |

src/main/java/com/iexec/blockchain/chain/ChainConfig.java

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,52 @@
1616

1717
package com.iexec.blockchain.chain;
1818

19-
import com.iexec.common.chain.validation.ValidNonZeroEthereumAddress;
20-
import jakarta.annotation.PostConstruct;
21-
import jakarta.validation.*;
22-
import jakarta.validation.constraints.Max;
23-
import jakarta.validation.constraints.NotEmpty;
24-
import jakarta.validation.constraints.NotNull;
25-
import jakarta.validation.constraints.Positive;
19+
import com.iexec.commons.poco.chain.validation.ValidNonZeroEthereumAddress;
20+
import jakarta.validation.constraints.*;
2621
import lombok.Builder;
2722
import lombok.Value;
2823
import lombok.extern.slf4j.Slf4j;
2924
import org.hibernate.validator.constraints.URL;
25+
import org.hibernate.validator.constraints.time.DurationMax;
26+
import org.hibernate.validator.constraints.time.DurationMin;
3027
import org.springframework.boot.context.properties.ConfigurationProperties;
28+
import org.springframework.validation.annotation.Validated;
3129

32-
import java.util.Set;
30+
import java.time.Duration;
3331

3432
@Slf4j
3533
@Value
3634
@Builder
35+
@Validated
3736
@ConfigurationProperties(prefix = "chain")
3837
public class ChainConfig {
3938

40-
@Positive(message = "Chain id should be positive")
41-
@NotNull
39+
@Positive(message = "Chain id must be greater than 0")
40+
@NotNull(message = "Chain id must not be null")
4241
int id;
4342

44-
@URL
45-
@NotEmpty
46-
String nodeAddress;
43+
boolean sidechain;
4744

48-
@Positive(message = "Block time should be positive")
49-
@NotNull
50-
int blockTime;
45+
@URL(message = "Node address must be a valid URL")
46+
@NotEmpty(message = "Node address must not be empty")
47+
String nodeAddress;
5148

52-
@ValidNonZeroEthereumAddress
49+
@ValidNonZeroEthereumAddress(message = "Hub address must be a valid non zero Ethereum address")
5350
String hubAddress;
5451

55-
boolean isSidechain;
52+
@DurationMin(millis = 100, message = "Block time must be greater than 100ms")
53+
@DurationMax(seconds = 20, message = "Block time must be less than 20s")
54+
@NotNull(message = "Block time must not be null")
55+
Duration blockTime;
5656

57+
@Positive(message = "Gas price multiplier must be greater than 0")
5758
float gasPriceMultiplier;
5859

60+
@PositiveOrZero(message = "Gas price cap must be greater or equal to 0")
5961
long gasPriceCap;
6062

61-
@Positive
62-
@Max(value = 4)
63+
@Positive(message = "Max allowed tx per block must be greater than 0")
64+
@Max(value = 4, message = "Max allowed tx per block must be less or equal to 4")
6365
int maxAllowedTxPerBlock;
6466

65-
@PostConstruct
66-
private void validate() {
67-
try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
68-
Validator validator = factory.getValidator();
69-
Set<ConstraintViolation<ChainConfig>> violations = validator.validate(this);
70-
if (!violations.isEmpty()) {
71-
throw new ConstraintViolationException(violations);
72-
}
73-
}
74-
}
7567
}

src/main/java/com/iexec/blockchain/chain/Web3jService.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2025 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,20 +19,18 @@
1919
import com.iexec.commons.poco.chain.Web3jAbstractService;
2020
import org.springframework.stereotype.Service;
2121

22-
import java.time.Duration;
23-
2422
@Service
2523
public class Web3jService extends Web3jAbstractService {
2624

2725
public Web3jService(ChainConfig chainConfig) {
2826
super(
2927
chainConfig.getId(),
3028
chainConfig.getNodeAddress(),
31-
Duration.ofSeconds(chainConfig.getBlockTime()),
29+
chainConfig.getBlockTime(),
3230
chainConfig.getGasPriceMultiplier(),
3331
chainConfig.getGasPriceCap(),
3432
chainConfig.isSidechain()
3533
);
3634
}
3735

38-
}
36+
}

src/main/java/com/iexec/blockchain/chain/WebSocketBlockchainListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public WebSocketBlockchainListener(final ChainConfig chainConfig, final SignerSe
6363
final String wsUrl = chainConfig.getNodeAddress().replace("http", "ws");
6464
this.webSocketService = new WebSocketService(wsUrl, false);
6565
this.web3Client = Web3j.build(new HttpService(chainConfig.getNodeAddress()),
66-
chainConfig.getBlockTime(), Async.defaultExecutorService());
66+
chainConfig.getBlockTime().toMillis(), Async.defaultExecutorService());
6767
lastSeenBlock = Metrics.gauge(LATEST_BLOCK_METRIC_NAME, new AtomicLong(0));
6868
latestTxGauge = Metrics.gauge(TX_COUNT_METRIC_NAME, List.of(Tag.of("block", "latest")), new AtomicLong(0));
6969
pendingTxGauge = Metrics.gauge(TX_COUNT_METRIC_NAME, List.of(Tag.of("block", "pending")), new AtomicLong(0));

src/main/resources/application.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ spring:
1414
auto-index-creation: true
1515

1616
chain:
17-
id: ${IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID:134}
18-
node-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS:https://bellecour.iex.ec}
19-
block-time: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME:5} #in seconds
20-
hub-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS:0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f}
21-
is-sidechain: ${IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN:true}
22-
gas-price-multiplier: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_MULTIPLIER:1.0} # txs will be sent with networkGasPrice*gasPriceMultiplier, 4.0 means super fast
23-
gas-price-cap: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_CAP:22000000000} #in Wei, will be used for txs if networkGasPrice*gasPriceMultiplier > gasPriceCap
17+
id: ${IEXEC_CHAIN_ID:134}
18+
node-address: ${IEXEC_BLOCKCHAIN_NODE_ADDRESS:https://bellecour.iex.ec}
19+
block-time: ${IEXEC_BLOCK_TIME:PT5S} #in seconds
20+
hub-address: ${IEXEC_HUB_ADDRESS:0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f}
21+
sidechain: ${IEXEC_IS_SIDECHAIN:true}
22+
gas-price-multiplier: ${IEXEC_GAS_PRICE_MULTIPLIER:1.0} # txs will be sent with networkGasPrice*gasPriceMultiplier, 4.0 means super fast
23+
gas-price-cap: ${IEXEC_GAS_PRICE_CAP:22000000000} #in Wei, will be used for txs if networkGasPrice*gasPriceMultiplier > gasPriceCap
2424
max-allowed-tx-per-block: ${IEXEC_BLOCKCHAIN_ADAPTER_API_MAX_ALLOWED_TX_PER_BLOCK:1} # 1 or 2
2525
wallet:
2626
path: ${IEXEC_BLOCKCHAIN_ADAPTER_API_WALLET_PATH:src/main/resources/wallet.json}
2727
password: ${IEXEC_BLOCKCHAIN_ADAPTER_API_WALLET_PASSWORD:whatever}
2828

2929
springdoc:
30-
packagesToScan: com.iexec.blockchain
31-
pathsToMatch: /**
30+
packages-to-scan: com.iexec.blockchain
31+
paths-to-match: /**

0 commit comments

Comments
 (0)