Corda network parameter change with Network Map Service

孤人 提交于 2019-12-13 06:29:57

问题


I have run network map service of corda on my VM. When I changed whitelist file, network map service rebuild network map and also network parameter.

If the network-parameters file is changed and no longer matches what the network map service is advertising then the node will automatically shutdown.

In my case all nodes gets shut down which was expected. On start up got message "Node is using parameters with hash: X but network map is advertising: Y". After deleting network-parameter it starts properly.

As per docs mentioned here, to manually accept updated network parameters and to send back parameters approval to the zone operator, the RPC method fun acceptNewNetworkParameters(parametersHash: SecureHash) has to be called with parametersHash from the update.

I have called above mentioned function from corda shell as below:

run acceptNewNetworkParameters parametersHash: "ba19fc1b9e9c1c7cbea712efda5f78b53ae4e5d123c89d02c9da44ec50e9c17d"

I have got error "RPC failed: java.lang.IllegalArgumentException: argument type mismatch".

I need to figure out how corda nodes accept updated network parameters from Network Map service and how can I prevent corda nodes to be shut down after getting new parameter.

Note: Using Network Map service with below config changes:

cache-timeout : 2 Sec param-update-delay : 10 Sec network-map-delay : 1 Sec

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

I have tried multiple time network parameter change along with NMS, few times gets network-parameter-updated files in nodes and few times got below issues:

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:


Corda 3.2/3.3 has a bug whereby the shell cannot deserialise strings into SecureHash objects. The fix is here: https://github.com/corda/corda/pull/3248. It will be available in Corda 4.

In the meantime, you should use an RPC client to accept the new network parameters instead. For example:

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);
    }
}


来源:https://stackoverflow.com/questions/53630493/corda-network-parameter-change-with-network-map-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!