使用网络地图服务更改Corda网络参数

时间:2018-12-05 10:45:00

标签: corda

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

如果更改了网络参数文件,并且不再匹配网络地图服务正在播发的内容,则该节点将自动关闭。

就我而言,所有节点都已关闭,这是预期的。在启动时收到消息“节点正在使用带有哈希值的参数:X,但网络地图正在通告:Y”。删除网络参数后,它可以正常启动。

根据here中提到的文档,要手动接受更新的网络参数并将参数批准发送回区域操作员,必须使用更新中的parametersHash调用RPC方法funAcceptNewNetworkParameters(parametersHash:SecureHash)。

我从corda shell调用了上述功能,如下所示:

run acceptNewNetworkParameters parametersHash: "ba19fc1b9e9c1c7cbea712efda5f78b53ae4e5d123c89d02c9da44ec50e9c17d"

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

我需要弄清楚Corda节点如何从Network Map Service接收更新的网络参数,以及如何防止在获得新参数后关闭Corda节点。

注意:使用网络地图服务进行以下配置更改:

缓存超时:2秒 param-update-delay:10秒 network-map-delay: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

1 个答案:

答案 0 :(得分:1)

Corda 3.2 / 3.3有一个bug,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);
    }
}
相关问题