Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Feat/embedded bcdns supported #19

Merged
merged 35 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e0d4174
[feat][r-cli][doc]: improve cli README.md
dawn-to-dusk Jan 2, 2024
007103f
Merge remote-tracking branch 'origin/develop' into antcode_repo/develop
zouxyan Jan 3, 2024
fd7b616
Merge remote-tracking branch 'origin/develop' into antcode_repo/develop
zouxyan Jan 10, 2024
a979e03
Merge branch 'develop' into antcode_repo/develop
zouxyan Jan 23, 2024
d7bdd5a
[refactor][*][*]: remove all charset setting from ddl.sql
zouxyan Feb 20, 2024
5b669f7
Merge branch 'develop' into antcode_repo/develop
zouxyan Feb 21, 2024
39d2c93
Merge remote-tracking branch 'refs/remotes/origin/develop' into antco…
zouxyan May 16, 2024
71ca046
[feat][*][*]: module `r-facade` ready for admin rpc client
zouxyan May 16, 2024
dc1b112
[feat][*][0.1.1]: using acb sdk `0.2.3` to fix BIF chain calling prob…
zouxyan May 21, 2024
c757577
Merge remote-tracking branch 'refs/remotes/origin/feat/facade/admin' …
zouxyan May 22, 2024
51c2255
Merge remote-tracking branch 'refs/remotes/origin/feat/facade/admin' …
zouxyan May 23, 2024
aae75bb
Merge remote-tracking branch 'refs/remotes/origin/feat/facade/admin' …
zouxyan May 27, 2024
babc958
Merge remote-tracking branch 'refs/remotes/origin/feat/facade/admin' …
zouxyan Jul 1, 2024
cf66cb3
PullRequest: 10 [feat][facade][0.2.0] add `facade` module provides a …
zouxyan Jul 1, 2024
b7023f1
[fix][facade][*] update acb sdk version to `0.2.3`
zouxyan Jul 1, 2024
b591f02
PullRequest: 11 [fix][facade][*] update acb sdk version to `0.2.3`
zouxyan Jul 1, 2024
954900f
[fix][ut][*] fix ut cases
zouxyan Jul 1, 2024
5cc1d8e
Merge remote-tracking branch 'refs/remotes/origin/develop' into antco…
zouxyan Jul 3, 2024
c86fe5f
Merge remote-tracking branch 'refs/remotes/origin/develop' into antco…
zouxyan Jul 5, 2024
952c2ae
[feat][*][*]: support embedded bcdns client and server
zouxyan Aug 4, 2024
deaebbd
[doc][*][*]: update README.md for embedded bcdns
zouxyan Aug 6, 2024
f8009b1
[feat][*][*]: add CLI cmds `generate-bcdns-root-cert`, `generate-rela…
zouxyan Aug 6, 2024
9ffac5d
[doc][*][*]: update project CONTRIBUTING.md
zouxyan Aug 6, 2024
69c5874
[ci][*][*]: add `.aci.yml`
zouxyan Aug 7, 2024
4dbabe7
PullRequest: 12 support embedded bcdns client and server
zouxyan Aug 8, 2024
b2c6942
[fix][*][*]: incorrect way to start mysql container in README.md
zouxyan Aug 8, 2024
e4f628f
[fix][*][*]: default using mysql container in mysql version 8
zouxyan Aug 8, 2024
a7e45b6
[doc][*][*]: update relayer README.md about embedded bcdns start
zouxyan Aug 9, 2024
ad3bb48
[doc][*][*]: del the pub ip
zouxyan Aug 9, 2024
2e661eb
[fix][*][*]: use `relayer.engine.schedule.duty.biz-period` for `bizDu…
zouxyan Aug 9, 2024
91e1c12
[refactor][*][*]: start with no relayer cert
zouxyan Aug 9, 2024
874b73d
[doc][*][*]: update README.md
zouxyan Aug 9, 2024
a5c5d1c
[doc][*][*]: add file predix for path in config yaml
zouxyan Aug 12, 2024
ef53a6f
[ci][*][*]: delete `.aci.yml`
zouxyan Aug 12, 2024
28a4e2c
Merge remote-tracking branch 'refs/remotes/antcode/fix/biz-duty-period'
zouxyan Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ hs_err_pid*
replay_pid*
/.idea/
logs
/r-facade/target/
9 changes: 4 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

## Branch Strategy

We recommend that developers following the rules [here](https://jeffkreeftmeijer.com/git-flow/git-flow.png).
We recommend that developers following the `Trunk-based development` rules [here](https://trunkbaseddevelopment.com/).

- Branch `main` with stable code and tags on it.
- Branch `develop` for "next release" development.
- Trunk branch `main` with stable code.
- Feature branches start with prefix `feat/`
- Release branches start with prefix `release/`
- Hotfix branches start with prefix `hotfix/`
- Hotfix branches start with prefix `hotfix/` or `fix/`

## Contributing

- Fork the repository or create branches.
- Checkout your branch like a feature or bugfix.
- Make a pull request to the `develop` branch of this repository.
- Make a pull request to the `main` branch of this repository.
- Wait for review and PR merged.

---
Expand Down
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ AntChain Bridge Relayer将功能实现分为两部分,分别为通信和可信

**确保安装了AntChain Bridge Plugin SDK,详情请[见](https://github.com/AntChainOpenLabs/AntChainBridgePluginSDK?tab=readme-ov-file#%E6%9E%84%E5%BB%BA)*

> [!IMPORTANT]
>
> 注意当前Relayer要求SDK版本为0.3.0

### 编译

在项目根目录运行maven命令即可:
Expand Down Expand Up @@ -80,7 +84,7 @@ wget -qO- https://get.docker.com/ | bash
然后下载MySQL镜像并启动容器,注意这里指定了时区为`+08:00`,请修改为您的时区。

```
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD='YOUR_PWD' mysql --default-authentication-plugin=mysql_native_password --default_time_zone +08:00
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD='YOUR_PWD' mysql:8 --mysql-native-password=ON --default_time_zone +08:00
```

然后下载Redis镜像并启动容器:
Expand Down Expand Up @@ -333,7 +337,37 @@ relayer:
{"destDomain":{"domain":"domain.web3.net","domainSpace":false},"destRelayer":{"netAddressList":["https://localhost:8082"],"relayerCert":{"credentialSubject":"AADVAAAAAAAD...hNDRjY2UifV19","credentialSubjectInstance":{"applicant":{"rawId":"ZGlkOmJpZDplZmJ...1b1FHWDZMVUd3Zw==","type":"BID"},"name":"relay","rawSubjectPublicKey":"r2Ze5VBjX...yWnSkTM4=","subject":"eyJwdWJsaWNLZXkiO...jZSJ9XX0=","subjectInfo":"eyJwd...J9XX0=","subjectPublicKey":{"algorithm":"Ed25519","encoded":"MCowBQYDK2V...qJKDyWnSkTM4=","format":"X.509","pointEncoding":"r2Ze5V...ifV19","expirationDate":1733811853,"id":"did:bid:efGeAv4Jr7V2FSyun77m4xTFmTDfG8nh","issuanceDate":1702275853,"issuer":{"rawId":"ZGlkOmJpZDpl...NTdtRENwQw==","type":"BID"},"proof":{"certHash":"Gaw4gcwXzn2i...K6HaPWBxXM=","hashAlgo":"SM3","rawProof":"kMZ/tvT19Tk...TQ4IVYlXkYjSBw==","sigAlgo":"Ed25519"},"type":"RELAYER_CERTIFICATE","version":"1"},"relayerCertId":"did:bid:efGeAv4Jr7V2FSyun77m4xTFmTDfG8nh"}}
```



### 启动Embedded BCDNS

> [!IMPORTANT]
> Relayer从0.3.0版本开始支持启动内嵌的BCDNS服务,注意Relayer使用的Embedded BCDNS相关依赖的版本。

Embedded BCDNS是内嵌在服务内部的BCDNS,提供中心化的权威服务,会使用一把私钥为跨链网络提供认证、准入等功能,按照服务端要求可以通过简单配置接入BCDNS,具体内容可以参考[这里](https://github.com/AntChainOpenLabs/AntChainBridgePluginSDK/tree/main/bcdns-services/embedded-bcdns/README.md)。

通过在中继的配置增加下面一项,重启即可启动Embedded BCDNS,详细的配置可以参考AntChain Bridge SDK关于如何使用Embedded的[README](https://github.com/AntChainOpenLabs/AntChainBridgePluginSDK/tree/main/bcdns-services/embedded-bcdns/README.md)。

```yaml
acb:
bcdns:
embedded:
server-on: true
root-private-key-file: file:/path/to/embedded-bcdns-root-private-key.key
root-cert-file: file:/path/to/embedded-bcdns-root.crt
```

上面配置中的`root-private-key-file`和`root-cert-file`,可以通过CLI命令`generate-bcdns-root-cert`来生成,详细用法参考[这里](r-cli/README.md#5.5 生成BCDNS根证书)。

需要在DB额外创建一些Embedded BCDNS的表,通过这里的SQL[脚本](https://github.com/AntChainOpenLabs/AntChainBridgePluginSDK/tree/main/bcdns-services/embedded-bcdns/embedded-bcdns-state-jdbc-spring-boot-starter/src/main/resources/ddl/mysql/ddl.sql)

重新启动Relayer,启动日志中会看到:

```
INFO 63164 --- [ main] .EmbeddedBcdnsJdbcStateAutoConfiguration : start jdbc bcdns state
INFO 63164 --- [ main] b.b.e.s.a.EmbeddedBcdnsAutoConfiguration : start embedded bcdns server on 0.0.0.0:8090
```



## 社区治理

Expand Down
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>antchain-bridge-relayer</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
<packaging>pom</packaging>
<modules>
<module>r-bootstrap</module>
Expand All @@ -36,7 +36,8 @@
<redisson-spring.version>3.23.5</redisson-spring.version>
<spring-boot.version>2.7.16</spring-boot.version>
<mysql-connector.version>8.0.33</mysql-connector.version>
<acb-sdk.version>0.2.3</acb-sdk.version>
<acb-sdk.version>0.3.0</acb-sdk.version>
<acb-embedded-bcdns.version>0.1.0</acb-embedded-bcdns.version>
<hutool.version>5.8.22</hutool.version>
<junit.version>4.13.2</junit.version>
<h2.version>2.2.224</h2.version>
Expand Down Expand Up @@ -116,9 +117,19 @@
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>antchain-bridge-bcdns</artifactId>
<artifactId>antchain-bridge-bcdns-factory</artifactId>
<version>${acb-sdk.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>embedded-bcdns-state-jdbc-spring-boot-starter</artifactId>
<version>${acb-embedded-bcdns.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>embedded-bcdns-spring-boot-starter</artifactId>
<version>${acb-embedded-bcdns.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -198,7 +209,7 @@
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>r-facade</artifactId>
<version>${project.version}</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
12 changes: 10 additions & 2 deletions r-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>antchain-bridge-relayer</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
</parent>

<artifactId>r-bootstrap</artifactId>
Expand Down Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
Expand Down Expand Up @@ -86,6 +86,14 @@
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>embedded-bcdns-state-jdbc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>embedded-bcdns-spring-boot-starter</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.PemUtil;
import com.alipay.antchain.bridge.commons.bcdns.AbstractCrossChainCertificate;
import com.alipay.antchain.bridge.commons.bcdns.CrossChainCertificateFactory;
Expand All @@ -44,6 +45,7 @@
import com.alipay.antchain.bridge.relayer.server.network.WSRelayerServer;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.BeanInitializationException;
Expand All @@ -55,6 +57,7 @@
import org.springframework.core.io.Resource;
import org.springframework.transaction.support.TransactionTemplate;

@Slf4j
@Configuration
public class RelayerCoreConfig {

Expand Down Expand Up @@ -98,7 +101,15 @@ public class RelayerCoreConfig {
private boolean isDiscoveryService;

public AbstractCrossChainCertificate getLocalRelayerCrossChainCertificate() {
AbstractCrossChainCertificate relayerCertificate = null;
if (StrUtil.equals("null", relayerCrossChainCert.getFilename())) {
log.warn("your relayer crosschain certificate is not set");
return null;
}
if (!relayerCrossChainCert.exists()) {
log.error("your relayer crosschain certificate {} not exist", relayerCrossChainCert.getFilename());
return null;
}
AbstractCrossChainCertificate relayerCertificate;
try {
relayerCertificate = CrossChainCertificateFactory.createCrossChainCertificateFromPem(
FileUtil.readBytes(relayerCrossChainCert.getFile())
Expand All @@ -111,7 +122,8 @@ public AbstractCrossChainCertificate getLocalRelayerCrossChainCertificate() {
}

public RelayerCredentialSubject getLocalRelayerCredentialSubject() {
return RelayerCredentialSubject.decode(getLocalRelayerCrossChainCertificate().getCredentialSubject());
return ObjectUtil.isNull(getLocalRelayerCrossChainCertificate()) ?
null : RelayerCredentialSubject.decode(getLocalRelayerCrossChainCertificate().getCredentialSubject());
}

public String getLocalRelayerIssuerDomainSpace() {
Expand All @@ -136,7 +148,8 @@ public PrivateKey getLocalPrivateKey() {
}

public String getLocalRelayerNodeId() {
return RelayerNodeInfo.calculateNodeId(getLocalRelayerCrossChainCertificate());
return ObjectUtil.isNull(getLocalRelayerCrossChainCertificate()) ?
null : RelayerNodeInfo.calculateNodeId(getLocalRelayerCrossChainCertificate());
}

@Bean
Expand Down
25 changes: 25 additions & 0 deletions r-bootstrap/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@
<onMismatch>ACCEPT</onMismatch>
</filter>
</appender>
<appender name="embeddedBcdnsAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logging.path}/${APP_NAME}/embedded-bcdns.log</file>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -
%msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${logging.path}/${APP_NAME}/embedded-bcdns.log.%d{yyyy-MM-dd}.%i</FileNamePattern>
<maxHistory>7</maxHistory>
<maxFileSize>50MB</maxFileSize>
<totalSizeCap>2GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
</appender>
<appender name="full-application" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
Expand All @@ -85,6 +106,10 @@
</filter>
</appender>

<logger name="com.alipay.antchain.bridge.bcdns.embedded.server" level="INFO" additivity="false">
<appender-ref ref="embeddedBcdnsAppender"/>
</logger>

<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="full-application"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.map.MapUtil;
import com.alipay.antchain.bridge.bcdns.impl.BlockChainDomainNameServiceFactory;
import com.alipay.antchain.bridge.bcdns.factory.BlockChainDomainNameServiceFactory;
import com.alipay.antchain.bridge.bcdns.service.BCDNSTypeEnum;
import com.alipay.antchain.bridge.bcdns.service.IBlockChainDomainNameService;
import com.alipay.antchain.bridge.bcdns.types.base.DomainRouter;
Expand Down
Loading
Loading