Some nodes like the simulation input have sockets that depend on other nodes in the tree, via dynamic declarations. The first fix here is remapping those inter-node references before adding links and updating declarations. The second is storing link references with socket identifiers instead of socket pointers. This is necessary because the new sockets aren't added to the socket map when the node is copied. Avoiding pointer storage is also less fragile in general. Pull Request: https://projects.blender.org/blender/blender/pulls/122013