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

Commit

Permalink
Merge pull request #2 from AntChainOpenLabs/feat/core_prepare
Browse files Browse the repository at this point in the history
[feat][*][*] finish stage#1: all base functions we need has been migrated
  • Loading branch information
zouxyan authored Nov 13, 2023
2 parents 24f6803 + b87a519 commit acb5ef4
Show file tree
Hide file tree
Showing 191 changed files with 15,134 additions and 747 deletions.
46 changes: 40 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<module>r-bootstrap</module>
<module>r-dal</module>
<module>r-cli</module>
<module>r-service</module>
<module>r-core</module>
<module>r-engine</module>
<module>r-server</module>
Expand All @@ -41,6 +40,11 @@
<junit.version>4.13.2</junit.version>
<h2.version>2.2.224</h2.version>
<embeded-redis.version>0.7.3</embeded-redis.version>
<protobuf-plugin.version>0.6.1</protobuf-plugin.version>
<protobuf.version>3.19.1</protobuf.version>
<grpc.version>1.42.2</grpc.version>
<bouncycastle.version>1.76</bouncycastle.version>
<commons-collections4.version>4.4</commons-collections4.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -76,6 +80,11 @@
<artifactId>spring-boot-starter-data-jdbc</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
Expand Down Expand Up @@ -127,6 +136,21 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>

<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
Expand All @@ -143,11 +167,6 @@
<artifactId>r-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>r-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>r-engine</artifactId>
Expand All @@ -168,6 +187,21 @@
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
6 changes: 5 additions & 1 deletion r-bootstrap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ build/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

src/main/resources/cc_certs/**

src/main/resources/node_keys/**
85 changes: 81 additions & 4 deletions r-bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>r-server</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.antchain.bridge</groupId>
<artifactId>r-service</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -74,6 +70,87 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.kstyrc</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/banner.txt</include>
<include>node_keys/**</include>
<include>cc_certs/**</include>
</includes>
<!-- 是否替换@xx@表示的maven properties属性值 -->
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<outputDirectory>../target/boot</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>jks</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-assembly-plugin</artifactId>-->
<!-- <version>3.1.0</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <configuration>-->
<!-- <finalName>acb-relayer</finalName>-->
<!-- <descriptors>-->
<!-- <descriptor>desc_tar.xml</descriptor>-->
<!-- </descriptors>-->
<!-- </configuration>-->
<!-- <id>make-tar</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>single</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.alipay.antchain.bridge.relayer.bootstrap;

import java.security.Security;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -26,6 +29,7 @@
public class AntChainBridgeRelayerApplication {

public static void main(String[] args) {
Security.addProvider(new BouncyCastleProvider());
new SpringApplicationBuilder(AntChainBridgeRelayerApplication.class)
.web(WebApplicationType.NONE)
.run(args);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2023 Ant Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alipay.antchain.bridge.relayer.bootstrap.config;

import java.util.Map;

import cn.hutool.core.map.MapUtil;
import com.alipay.antchain.bridge.relayer.commons.constant.DistributedTaskTypeEnum;
import com.alipay.antchain.bridge.relayer.engine.core.ScheduleContext;
import com.alipay.antchain.bridge.relayer.engine.executor.*;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Getter
public class EngineConfig {

@Value("${relayer.engine.node_id_mode:IP}")
private String nodeIdMode;

@Bean
public ScheduleContext scheduleContext() {
return new ScheduleContext(nodeIdMode);
}

@Bean
@Autowired
public Map<DistributedTaskTypeEnum, BaseScheduleTaskExecutor> scheduleTaskExecutorMap(
AnchorScheduleTaskExecutor anchorScheduleTaskExecutor,
CommitterScheduleTaskExecutor committerScheduleTaskExecutor,
ProcessScheduleTaskExecutor processScheduleTaskExecutor,
TxConfirmScheduleTaskExecutor txConfirmScheduleTaskExecutor,
ArchiveScheduleTaskExecutor archiveScheduleTaskExecutor,
AsyncDeployScheduleTaskExecutor asyncDeployScheduleTaskExecutor
) {
Map<DistributedTaskTypeEnum, BaseScheduleTaskExecutor> res = MapUtil.newHashMap();
res.put(DistributedTaskTypeEnum.ANCHOR_TASK, anchorScheduleTaskExecutor);
res.put(DistributedTaskTypeEnum.COMMIT_TASK, committerScheduleTaskExecutor);
res.put(DistributedTaskTypeEnum.PROCESS_TASK, processScheduleTaskExecutor);
res.put(DistributedTaskTypeEnum.AM_CONFIRM_TASK, txConfirmScheduleTaskExecutor);
res.put(DistributedTaskTypeEnum.ARCHIVE_TASK, archiveScheduleTaskExecutor);
res.put(DistributedTaskTypeEnum.DEPLOY_SERVICE_TASK, asyncDeployScheduleTaskExecutor);
return res;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2023 Ant Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alipay.antchain.bridge.relayer.bootstrap.config;

import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import com.alipay.antchain.bridge.relayer.commons.model.BlockchainMeta;
import com.alipay.antchain.bridge.relayer.commons.model.DomainCertWrapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MemCacheConfig {

@Value("${relayer.cache.domain_cert.ttl:10000}")
private long domainCertCacheTTL;

@Value("${relayer.cache.domain_cert.ttl:3000}")
private long blockchainMetaCacheTTL;

@Value("${relayer.cache.system_conf.ttl:30000}")
private long systemConfigCacheTTL;

@Bean
public Cache<String, DomainCertWrapper> domainCertWrapperCache() {
return CacheUtil.newLRUCache(30, domainCertCacheTTL);
}

@Bean
public Cache<String, BlockchainMeta> blockchainMetaCache() {
return CacheUtil.newLRUCache(30, blockchainMetaCacheTTL);
}

@Bean(name = "blockchainIdToDomainCache")
public Cache<String, String> blockchainIdToDomainCache() {
return CacheUtil.newLRUCache(30);
}

@Bean(name = "systemConfigCache")
public Cache<String, String> systemConfigCache() {
return CacheUtil.newLRUCache(10, systemConfigCacheTTL);
}
}
Loading

0 comments on commit acb5ef4

Please sign in to comment.