首页 > 解决方案 > 使用网络地图服务更改 Corda 网络参数

问题描述

我已经在我的虚拟机上运行了 corda 的网络地图服务。当我更改白名单文件时,网络地图服务会重建网络地图以及网络参数。

如果网络参数文件被更改并且不再匹配网络地图服务所宣传的内容,那么节点将自动关闭。

在我的情况下,所有节点都会按预期关闭。启动时收到消息“节点正在使用带有哈希的参数:X,但网络地图正在广告:Y”。删除网络参数后,它会正常启动。

根据此处提到的文档,要手动接受更新的网络参数并将参数批准发送回区域运营商,必须使用更新中的 parametersHash 调用 RPC 方法 fun acceptNewNetworkParameters(parametersHash: SecureHash)。

我从corda shell调用了上述函数,如下所示:

run acceptNewNetworkParameters parametersHash: "ba19fc1b9e9c1c7cbea712efda5f78b53ae4e5d123c89d02c9da44ec50e9c17d"

我收到错误“RPC 失败:java.lang.IllegalArgumentException:参数类型不匹配”。

我需要弄清楚corda节点如何从网络地图服务接受更新的网络参数,以及如何防止corda节点在获取新参数后被关闭。

注意:使用具有以下配置更改的网络地图服务:

缓存超时:2 秒参数更新延迟:10 秒网络映射延迟:1 秒

08:35:13.664 [vert.x-eventloop-thread-3] ERROR i.c.n.s.NetworkMapServiceProcessor - failed during processParamUpdate
io.vertx.core.file.FileSystemException: java.nio.file.NoSuchFileException: /data/corda-workspace/network-map-service-v0.3.0/network-map/parameters-update/next-params-update
        at io.vertx.core.file.impl.FileSystemImpl$10.perform(FileSystemImpl.java:638)
        at io.vertx.core.file.impl.FileSystemImpl$10.perform(FileSystemImpl.java:615)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:275)
        at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.file.NoSuchFileException: /data/corda-workspace/network-map-service-v0.3.0/network-map/parameters-update/next-params-update
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
        at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
        at java.nio.file.Files.walkFileTree(Files.java:2662)
        at java.nio.file.Files.walkFileTree(Files.java:2742)
        at io.vertx.core.file.impl.FileSystemImpl$10.perform(FileSystemImpl.java:620)
        ... 7 common frames omitted

我已经尝试了多次网络参数更改以及 NMS,几次在节点中获取网络参数更新文件,并且很少遇到以下问题:

Couldn't find parameters update for the hash: <Hash>

Refused to accept parameters with hash <Hash> because network map advertises update with hash <Hash>. Please check newest version

标签: corda

解决方案


Corda 3.2/3.3 有一个错误,shell 无法将字符串反序列化为SecureHash对象。修复在这里:https ://github.com/corda/corda/pull/3248 。它将在 Corda 4 中可用。

同时,您应该使用 RPC 客户端来接受新的网络参数。例如:

public class AcceptNetworkParams {
    public static void main(String[] args) {
        // Create an RPC connection to the node.
        if (args.length != 4)
            throw new IllegalArgumentException("Usage: Client <node address> <rpc username> <rpc password> <network params hash");
        final NetworkHostAndPort nodeAddress = parse(args[0]);
        final String rpcUsername = args[1];
        final String rpcPassword = args[2];
        final CordaRPCClient client = new CordaRPCClient(nodeAddress);
        final CordaRPCOps proxy = client.start(rpcUsername, rpcPassword).getProxy();

        // Accept the new network parameters.
        final String networkParamsHashString = args[3];
        final SecureHash networkParamsHash = SecureHash.parse(networkParamsHashString);
        proxy.acceptNewNetworkParameters(networkParamsHash);
    }
}

推荐阅读