Skip to content

refactoring#288

Merged
erikzhang merged 53 commits into
masterfrom
Neo.Actor
Sep 14, 2018
Merged

refactoring#288
erikzhang merged 53 commits into
masterfrom
Neo.Actor

Conversation

@erikzhang

@erikzhang erikzhang commented Jun 25, 2018

Copy link
Copy Markdown
Member

Refactor the code using the actor model. (Akka.NET)

Close #282
Close neo-project/neo-node#116

@erikzhang erikzhang added this to the NEO 3.0 milestone Jun 25, 2018
@erikzhang erikzhang requested a review from shargon June 25, 2018 12:43
// if (engine.EvaluationStack.Count != 1 || !engine.EvaluationStack.Pop().GetBoolean()) return false;
// }
//}
return true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code if no longer used.

Comment thread neo/Network/P2P/Peer.cs Outdated
private readonly Dictionary<IPAddress, int> ConnectedAddresses = new Dictionary<IPAddress, int>();
protected readonly Dictionary<IActorRef, IPEndPoint> ConnectedPeers = new Dictionary<IActorRef, IPEndPoint>();
protected readonly HashSet<IPEndPoint> UnconnectedPeers = new HashSet<IPEndPoint>();
//TODO: badPeers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO ?

Comment thread neo/Network/P2P/Peer.cs Outdated
catch { }
}
tcp.Tell(new Tcp.Bind(Self, new IPEndPoint(IPAddress.Any, ListenerPort), options: new[] { new Inet.SO.ReuseAddress(true) }));
//TODO: Websocket

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO?

Comment thread neo/Network/RPC/RpcServer.cs Outdated
// peerJson["address"] = peer.Address.ToString();
// peerJson["port"] = peer.Port;
// unconnectedPeers.Add(peerJson);
//}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code / TODO

Comment thread neo/Network/RPC/RpcServer.cs Outdated
// peerJson["address"] = peer.Address.ToString();
// peerJson["port"] = peer.Port;
// badPeers.Add(peerJson);
//}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented Code / TODO

@vncoelho

Copy link
Copy Markdown
Member

OMG, @erikzhang.

if (Blockchain.GetConsensusAddress(Blockchain.Singleton.Snapshot.GetValidators(context.Transactions.Values).ToArray()).Equals(context.NextConsensus))
{
Log($"send perpare response");
Log($"send prepare response");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was waiting for this...aehuaheuaea

Comment thread neo/Consensus/ConsensusService.cs
Message = Message.Create("inv", payload)
});
}
TimeSpan span = DateTime.Now - block_received_time;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erik, let's consider a startup time here.

TimeSpan span = DateTime.Now + averageStartupTimeTimeOfKPreviousBlocks - block_received_time;

But, perhaps, not now, right? It would make harder to detect any different in this refactoring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DateTime.UtcNow please

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference, Sharrrgon brothers?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important thing here would be to have something unified in terms of clock and time syncing. The template has almost not so much effects.

Comment thread neo/Consensus/ConsensusService.cs
Comment thread neo/Implementations/Blockchains/LevelDB/LevelDBBlockchain.cs
Comment thread neo/Cryptography/Base58.cs
Comment thread neo/IO/Json/JString.cs
@erikzhang

Copy link
Copy Markdown
Member Author

Now we can test this PR with neo-gui and neo-cli.

@vncoelho

vncoelho commented Jul 2, 2018

Copy link
Copy Markdown
Member

Testing are starting: NeoResearch/neo-tests@95e5e49
Thanks @AshRolls 🗡️

@vncoelho

vncoelho commented Jul 2, 2018

Copy link
Copy Markdown
Member

Great implementation, @erikzhang, congratulations for the concise modification. Apparently, basic functionalities are working pretty smooth.
NeoCompiler is very interlaced and everything seems to be working in the desired manner.
Notoriously, I fell that things are running softer. However, it is a biased analyses. aheuahueaea

image

I noticed that 29 free transactions were broadcasted in a single block, perhaps, I should adjust the freemaxtransaction per block here.

We gonna check it with time and verify the boundaries defined in Neo 3.0

Checking with additional features, I am getting the following errors:

[ERROR][07/02/2018 16:48:03][Thread 0006][akka://NeoSystem/user/$b/connection_c13547dc-7bc6-48db-bdd3-0a1bd009a2f6/$a] Operation is not valid due to the current state of the object.
Cause: System.Net.ProtocolViolationException: Operation is not valid due to the current state of the object.
   at Neo.Network.P2P.ProtocolHandler.OnReceive(Object message)
   at Akka.Actor.UntypedActor.Receive(Object message)
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
   at Akka.Actor.ActorCell.ReceiveMessage(Object message)
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)

[ERROR][07/02/2018 16:48:03][Thread 0010][akka://NeoSystem/system/IO-TCP/$g] Transport endpoint is not connected
Cause: System.Net.Sockets.SocketException (0x80004005): Transport endpoint is not connected
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.get_RemoteEndPoint()
   at Akka.IO.TcpConnection.CompleteConnect(IActorRef commander, IEnumerable`1 options)
   at Akka.IO.TcpOutgoingConnection.<>c__DisplayClass12_0.<Connecting>b__0(Object message)
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
   at Akka.Actor.ActorCell.ReceiveMessage(Object message)
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)
[ERROR][07/02/2018 16:48:03][Thread 0005][akka://NeoSystem/system/IO-TCP/$f] Restarting not supported for connection actors.
Cause: [akka://NeoSystem/system/IO-TCP/$f#1048723336]: Akka.Actor.PostRestartException: Exception post restart (System.Net.Sockets.SocketException) ---> Akka.Pattern.IllegalStateException: Restarting not supported for connection actors.
   at Akka.IO.TcpConnection.PostRestart(Exception reason)
   at Akka.Actor.ActorCell.UseThreadContext(Action action)
   at Akka.Actor.ActorCell.FinishRecreate(Exception cause, ActorBase failedActor)
   --- End of inner exception stack trace ---

erikzhang added 3 commits July 3, 2018 12:40
- Microsoft.AspNetCore.ResponseCompression v2.1.1
- Microsoft.AspNetCore.Server.Kestrel v2.1.1
- Microsoft.AspNetCore.Server.Kestrel.Https v2.1.1
- Microsoft.EntityFrameworkCore.Sqlite v2.1.1
- Microsoft.Extensions.Configuration.Json v2.1.1
@vncoelho

vncoelho commented Jul 3, 2018

Copy link
Copy Markdown
Member

Great, Erik.

RPC calls are now responding. However, still stucked on start consensus.

image

image

Is it compulsory to include SimplePolicy.cs plugin?

@erikzhang

Copy link
Copy Markdown
Member Author

This is a caught exception, no problem.

@vncoelho

vncoelho commented Jul 3, 2018

Copy link
Copy Markdown
Member

Perfect, @erikzhang, sorry for my lack of knowledge. aehuahuea
Anyway, maybe I am missing some new configuration of the config.json from neo-cli.
start consensus is stuck.

Should the ports be changed to websocket? Are them necessary now?

@erikzhang

Copy link
Copy Markdown
Member Author

However, still stucked on start consensus.

It's not stucked, just no print log. Now the print log function is placed inside the plugin. When you enable the plugin, you can see that the log is printed on the console. You can also modify the plugin to redirect the log to another location.

Comment thread neo/Ledger/Blockchain.cs Outdated
Comment thread neo/Network/P2P/Peer.cs
Comment thread neo/Network/P2P/Peer.cs
@vncoelho

Copy link
Copy Markdown
Member

Great work, @erikzhang.
Incredible improvements surely were held here!
Pretty stable. Good move on the backwards compatibility, @jsolman.

The last release can be found at https://github.com/NeoResearch/neo-tests/blob/master/releases/neo-release-2.9.0-preview-all-plugins.zip

@jsolman

jsolman commented Sep 12, 2018

Copy link
Copy Markdown
Contributor

Yes, overall, it is cleaner code and there are some nice improvements. I have been having good results testing so far in PrivateNet. I'll be launching some nodes on TestNet and observing metrics and will report back some findings here within the next day or two.

@jsolman

jsolman commented Sep 12, 2018

Copy link
Copy Markdown
Contributor

I'm experiencing an issue now where sometimes in my private net when I stop and start the server it starts syncing the chain from genesis block instead of continuing from the most recent persisted block in leveldb. Anyone else seen this?

Comment thread neo/Persistence/LevelDB/LevelDBStore.cs Outdated
@vncoelho

vncoelho commented Sep 12, 2018

Copy link
Copy Markdown
Member

@jsolman, our node did not presented sync problems, if the "index" param is added in the config ( "Index": "Index_{0}").

@jsolman

jsolman commented Sep 12, 2018

Copy link
Copy Markdown
Contributor

@vncoelho Erik pushed a fix to the sync issue I was mentioning two hours before your comment.

@jsolman

jsolman commented Sep 13, 2018

Copy link
Copy Markdown
Contributor

Some transactions submitted successively via sendrawtransaction to a node running this code seem to be getting lost; the node accepts all the transactions, but after waiting multiple blocks not all of them get confirmed on the consensus nodes in my private net. I'm not sure what the problem is yet, but lets get some others testing this scenario also. In my case the consensus nodes are running 2.8.0 or less

I verified the messages are being relayed from the node running this code; so this code may be fine; still not sure what is happening to the messages just yet.

@jsolman

jsolman commented Sep 13, 2018

Copy link
Copy Markdown
Contributor

After further investigation, if I send the same 6 transactions using sendrawtransaction to the consensus node they all get confirmed without any issue. If I send them to the node running 2.9.0 and it relays them it relays them all, but only 3 or 4 out of 6 actually make it into a block. The last ones stay in the mem_pool on the 2.9.0 node getting re-verified after every block indefinitely and the consensus nodes never confirm them.

I am digging deeper to figure out why they get confirmed if sent directly to the consensus node but when using sendrawtransaction to the 2.9.0 node some never will get confirmed.

Comment thread neo/Ledger/Blockchain.cs Outdated
Comment thread neo/Ledger/Blockchain.cs Outdated
jsolman
jsolman previously approved these changes Sep 13, 2018

@jsolman jsolman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job

@erikzhang erikzhang merged commit c64748e into master Sep 14, 2018
@erikzhang erikzhang deleted the Neo.Actor branch September 14, 2018 09:54
@jsolman

jsolman commented Sep 14, 2018

Copy link
Copy Markdown
Contributor

Sweet to see this merged!

Thacryba pushed a commit to simplitech/neo that referenced this pull request Feb 17, 2020
Fixing grammar. Also added a tip regarding the missing dll when trying to use neon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.