Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

first steps to sync #456

Merged
merged 88 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
9c016e6
RocksDbRepository reach 42% cover
aboimpinto Jul 9, 2018
c1cb900
merge with development
aboimpinto Jul 14, 2018
17eccae
Rename abstract class ICrypto to Crypto. I'm sure this was once an in…
aboimpinto Jul 14, 2018
d380115
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 14, 2018
45915e8
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 17, 2018
bd9a3ff
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 17, 2018
318cefc
merge with development
aboimpinto Jul 17, 2018
bf48c58
fix some merge problems
aboimpinto Jul 17, 2018
162316b
Increase Server tests coverage to 94%.
aboimpinto Jul 17, 2018
afd6e97
merge with development
aboimpinto Jul 18, 2018
304fd44
fix merge issues
aboimpinto Jul 18, 2018
3d82e92
* Remove protected fields from TestBase and replace with overload usa…
aboimpinto Jul 14, 2018
7c7c325
Create UtBlockchain and create first tests.
aboimpinto Jul 18, 2018
93077cc
fix issues from the merge
aboimpinto Jul 18, 2018
2c05de5
Adding testing information to the team Contributing page.
Jul 18, 2018
53c78d3
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
Jul 18, 2018
b1ee9aa
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 19, 2018
ef4a592
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
aboimpinto Jul 19, 2018
90e29f1
Small CleanUp the test class with properties that aren't been used an…
aboimpinto Jul 19, 2018
c55c654
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 19, 2018
23d4063
UtBlockChain: InitializeBlockchain_IsGenesisBlock_InitializeComplete
aboimpinto Jul 19, 2018
8931884
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 20, 2018
4e489e8
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 22, 2018
97d8d68
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
Jul 22, 2018
7ec17e4
Firsts UtBlockProcessor tests
Jul 22, 2018
a2af9ca
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
Jul 22, 2018
682f44c
merge with development
aboimpinto Jul 23, 2018
1ee33bb
AddBlock tests added
aboimpinto Jul 23, 2018
ffc1d27
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 25, 2018
c250c36
* UtBlockProcessor: Run test
aboimpinto Jul 25, 2018
74d8eef
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Jul 25, 2018
debba04
Cleanup
aboimpinto Jul 25, 2018
468b5cf
UtBlockProcessor - Loop test: When the received block is not the expe…
aboimpinto Jul 25, 2018
13586e0
Remove comment
aboimpinto Jul 25, 2018
f7bf59b
Remove async modifier from methods that aren't implemented
aboimpinto Jul 25, 2018
a7086ec
.
aboimpinto Jul 25, 2018
6b42b62
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
aboimpinto Jul 25, 2018
a39bee0
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
aboimpinto Jul 25, 2018
c287f10
merge with development
aboimpinto Aug 12, 2018
c4f3557
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
aboimpinto Aug 12, 2018
b06bb31
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Aug 14, 2018
21b0f6d
Add test class, #301
aboimpinto Aug 14, 2018
f0558ea
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Aug 15, 2018
0cefb11
Write tests for Add method.
aboimpinto Aug 18, 2018
87336c1
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Aug 18, 2018
5d6562d
Refactor the Block / BlockHeader in Signed and Unsigned objects (muta…
aboimpinto Aug 19, 2018
5ea86c3
Implement the UpdateHash methods in the creation of the Signed<object>
aboimpinto Aug 19, 2018
f10c060
Signed and Unsigned strucuture return GenenisBlock
aboimpinto Aug 20, 2018
4d587dc
Draft of the BinaryCustomSeralization of TransactionBase
aboimpinto Aug 21, 2018
9d5c273
Revert "Remove stack logs (#321)"
aboimpinto Aug 21, 2018
128b2b5
merge with development
aboimpinto Sep 13, 2018
b69aea7
Add BlockOperationsManager and WitnessOperationManager that will be r…
aboimpinto Sep 13, 2018
ebb3daf
Initial work, removing logic from the model objects and add it into W…
aboimpinto Sep 13, 2018
0c3cba6
Merge branch 'development' of https://github.com/aboimpinto/neo-sharp…
aboimpinto Sep 13, 2018
08cc170
Cleanup and remove code that was not merged.
aboimpinto Sep 13, 2018
1a928c6
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Sep 16, 2018
ffb8365
regreassion test for the case where the current block is null. This h…
aboimpinto Sep 16, 2018
031e39b
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Sep 16, 2018
fc79312
Remove dependencies from BlockProcessor and remove BlockHeader refere…
aboimpinto Sep 17, 2018
313b8af
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Sep 18, 2018
278d50f
now the Persist consider the genesis block for the case of start a no…
aboimpinto Sep 18, 2018
e4fcadb
Merge pull request #1 from CityOfZion/development
aboimpinto Sep 21, 2018
1701fbc
Merge pull request #2 from CityOfZion/development
aboimpinto Sep 23, 2018
16d74ea
Merge pull request #5 from CityOfZion/development
aboimpinto Sep 25, 2018
0027858
consolidate the TransactionSigner and TransactionVerigy into Operatio…
Sep 27, 2018
620d972
.
aboimpinto Sep 27, 2018
e3fe01b
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Sep 27, 2018
cc4ebfc
Make Genesis and Genesis assets instatiable instead of static classes
aboimpinto Sep 27, 2018
43ac425
UtGenesis refactored to use Generis and GenesisAssets instances
aboimpinto Sep 28, 2018
49d6244
merge
aboimpinto Sep 28, 2018
f4ec481
IBlockchain dependency removed from some of the MessageHandlers
aboimpinto Sep 28, 2018
d4b898d
Replace IServer reference with IServerContext to avoid Circular Refer…
aboimpinto Sep 28, 2018
cb52fb0
merge with development
aboimpinto Sep 28, 2018
ddc1e8b
Adjust the code to BlockSigner / BlockVerifier pattern
aboimpinto Sep 28, 2018
76d7cf3
Rename the Model classes to Repository
aboimpinto Sep 28, 2018
4e30b24
Genesis class renamed to GenesisBuilder.
aboimpinto Sep 28, 2018
22cd149
rename IGenesis to IGenenisBuilder and IGenesisAssets to IGenesisAsse…
aboimpinto Sep 28, 2018
e663cc7
conflicts with development solved.
aboimpinto Sep 28, 2018
48a417d
replace IRepository dependency with IBlockRepository
aboimpinto Sep 28, 2018
98cb426
Merge branch 'development' of https://github.com/CityOfZion/neo-shar…
aboimpinto Sep 29, 2018
ba36ae0
Implement ISignerT and IVerifierT concept discussed with @melanke
aboimpinto Sep 29, 2018
22a5939
fixing red test. missing registration.
aboimpinto Sep 29, 2018
c3e6ca4
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Sep 30, 2018
f084888
Remove some exception throw because they are getting swallow by async…
aboimpinto Oct 1, 2018
c190933
Fixing unit test
aboimpinto Oct 1, 2018
983e556
Merge branch 'development' of https://github.com/CityOfZion/neo-sharp…
aboimpinto Oct 1, 2018
ad7257a
remove assignment of the Block Type as header. The Serialization is d…
aboimpinto Oct 1, 2018
b22c32e
merge with development
aboimpinto Oct 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public async Task Persist(params BlockHeader[] blockHeaders)

foreach (var blockHeader in blockHeadersToPersist)
{
blockHeader.Type = HeaderType.Header;
Copy link
Member

Choose a reason for hiding this comment

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

This never should be made

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove from my PR

if (blockHeader.Hash == null)
{
_blockHeaderSigner.Sign(blockHeader);
Expand Down Expand Up @@ -94,7 +95,7 @@ private bool Validate(BlockHeader blockHeader)
}
}

return blockHeader.Type == HeaderType.Extended;
return blockHeader.Type == HeaderType.Header;
}
}
}
8 changes: 5 additions & 3 deletions src/NeoSharp.Core/Blockchain/Processing/BlockPersister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ public async Task Persist(params BlockHeader[] blockHeaders)

public async Task<bool> IsBlockPersisted(Block block)
{
this._logger.LogDebug($"Verify if the {block.Hash} is already in the blockchain.");
this._logger.LogDebug($"Verify if the block {block.Hash} is already in the blockchain.");
var blockHeader = await this._blockRepository.GetBlockHeader(block.Hash);

if (blockHeader?.Type == HeaderType.Extended)
{
throw new InvalidOperationException($"The block \"{block.Hash.ToString(true)}\" exists already on the blockchain.");
this._logger.LogDebug($"The block \"{block.Hash.ToString(true)}\" exists already on the blockchain.");
return true;
}

if (blockHeader != null && blockHeader.Hash != block.Hash)
{
throw new InvalidOperationException($"The block \"{block.Hash.ToString(true)}\" has an invalid hash.");
this._logger.LogDebug($"The block \"{block.Hash.ToString(true)}\" has an invalid hash."); // <-- [AboimPinto] I'm not sure if this validation should be on this method.
return true;
}

this._logger.LogDebug($"The block with the hash {block.Hash} is not int the blockchain.");
Expand Down
4 changes: 2 additions & 2 deletions src/NeoSharp.Core/Blockchain/Processing/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public void Run(Block currentBlock)
{
if (this._blockchainContext.IsPeerConnected && this._blockchainContext.NeedPeerSync && !this._blockchainContext.IsSyncing)
{
this._broadcaster.Broadcast(new GetBlocksMessage(this._blockchainContext.CurrentBlock.Hash));
this._broadcaster.Broadcast(new GetBlocksMessage(this._blockchainContext.CurrentBlock?.Hash));
this._blockchainContext.IsSyncing = true;
}

var nextBlockHeight = currentBlock?.Index + 1 ?? 0;
var nextBlockHeight = this._blockchainContext.CurrentBlock?.Index + 1 ?? 0;

if (!_blockPool.TryGet(nextBlockHeight, out var block))
{
Expand Down
5 changes: 3 additions & 2 deletions src/NeoSharp.Core/Messaging/Handlers/BlockMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public override async Task Handle(BlockMessage message, IPeer sender)
this._blockOperationsManager.Sign(block);
}

if (this._blockOperationsManager.Verify(block))
if (!this._blockOperationsManager.Verify(block))
{
await _blockProcessor.AddBlock(block);
this._logger.LogInformation($"Block {block.Hash} verification failed and will not be added.");
return;
}

this._logger.LogInformation($"Adding block {block.Hash} to the BlockPool with Index {block.Index}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public void Sign(Witness witness)

public bool Verify(Witness witness)
{
throw new System.NotImplementedException();
// TODO [AboimPinto]: need to be implemented.
return true;
}
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using NeoSharp.Core.Helpers;
using NeoSharp.Core.Models;
using NeoSharp.Core.Models.OperationManger;
using NeoSharp.Core.Network;
using NeoSharp.Core.Persistence;
using NeoSharp.Core.Types;
using NeoSharp.TestHelpers;
Expand Down Expand Up @@ -201,6 +202,11 @@ public void Run_WhenAddBlockThisIsProcessed_OnBlockProcessedEventRaised()

var blockPersisterMock = this.AutoMockContainer.GetMock<IBlockPersister>();

this.AutoMockContainer
.GetMock<IBlockchainContext>()
.SetupGet(x => x.CurrentBlock)
.Returns(currentBlock);

var testee = this.AutoMockContainer.Create<BlockProcessor>();

testee.OnBlockProcessed += (_, block) =>
Expand Down