-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fork redeem #565
Fork redeem #565
Conversation
{ | ||
forkSetMgr.Insert(ctxt); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vAddFork和vRemoveFork没有什么区别,是否这里可以优化一下,只需要在297行处理forkSetMgr.insert(CForkContextEx());
// check parent fork | ||
CForkContextEx ctxtParent; | ||
if ((!forkSetMgr.RetrieveByFork(profile.hashParent, ctxtParent) && !unconfirmedForkSetMgr.RetrieveByFork(profile.hashParent, ctxtParent)) || !ctxtParent.IsActive()) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
较验FORK名称和hashParent都存在,forkSetMgr与unconfirmedForkSetMgr重复部分的问题,如果该BLOCK中是短链的,而forkSetMgr是长链的,则forkSetMgr中存在有些名称不应该在短链中存在,但这里被禁用掉了,而hashParent在forkSetMgr中存在,但在短链中不存在,则这里的较验又通过了。
forkSetMgr和unconfirmedForkSetMgr需要整合,去除重复部分的BLOCK后再处理,可以参考UNSPENT的处理方法。
src/bigbang/core.cpp
Outdated
} | ||
|
||
if (tx.sendTo.GetTemplateId().GetType() == TEMPLATE_FORK && tx.nAmount < CTemplateFork::CreatedCoin()) | ||
// check fork template redeem tx | ||
if ((destIn.GetTemplateId().GetType() == TEMPLATE_FORK) && (hashFork == GetGenesisBlockHash())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(hashFork == GetGenesisBlockHash()) 这个在VerifyRedeemTx函数较验了,这里重复了,并且这里也应该较验FORK,如果在该IF语句中,则躲过了FORKID的较验。
src/bigbang/core.cpp
Outdated
|
||
int nCreatedHeight = -1; | ||
CForkContextEx ctxt; | ||
if (forkSetMgr.RetrieveByFork(forkPtr->GetHashFork(), ctxt) || unconfirmedForkSetMgr.RetrieveByFork(forkPtr->GetHashFork(), ctxt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里同样存在forkSetMgr和unconfirmedForkSetMgr重复冲突问题。
src/bigbang/forkmanager.cpp
Outdated
{ | ||
AddNewForkContext(ctxt, vActive); | ||
Log("fork manager add fork: %s, height: %d", ctxt.hashFork.ToString().c_str(), ctxt.nCreatedHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddNewForkContext这个函数添加失败了,未做回滚处理,使用得DB中还有失败的FORK数据。
CBlockIndex* pIndexPrev; | ||
if (!cntrBlock.RetrieveIndex(block.hashPrev, &pIndexPrev)) | ||
{ | ||
Log("AddNewBlock Retrieve Prev Index Error: %s ", block.hashPrev.ToString().c_str()); | ||
return ERR_SYS_STORAGE_ERROR; | ||
} | ||
|
||
if (!IsForkActive(pIndexPrev->GetOriginHash())) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会不会导致同步过来的块是非活跃的FORK,即被回滚的FORK,产生DDOS,即在回滚之前该FORK是激活状态,之后其它节点产生该FORK的块,并开始同步过来,但后面被回滚了,变为非激活状态,但同步该FORK的块也在路上,所以会添加该BLOCK产生DDOS。
bool CNetChannel::HandleEvent(network::CEventPeerBlock& eventBlock)在这个函数中,如果FORK被删除了,则CSchedule& sched = GetSchedule(hashFork);产生失败并产生DDOS。
如何不产生DDOS,因为这个是正常的回滚,非恶意行为,可以在后面不订阅该FORK。
@@ -1089,18 +1072,15 @@ Errno CBlockChain::VerifyPowBlock(const CBlock& block, bool& fLongChain) | |||
Log("VerifyPowBlock Get txContxt Error([%d] %s) : %s ", err, ErrorString(err), txid.ToString().c_str()); | |||
return err; | |||
} | |||
if (!pTxPool->Exists(txid)) | |||
err = pCoreProtocol->VerifyBlockTx(tx, txContxt, pIndexPrev, nForkHeight, pIndexPrev->GetOriginHash(), forkSetMgr, unconfirmedForkSetMgr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该BLOCK可能是短链的块,但forkSetMgr这个是长链的数据,所以此处可能存在问题,需要再分析一下。
Log("The minimum confirmed height of the previous block is %d", MIN_CREATE_FORK_INTERVAL_HEIGHT); | ||
return ERR_TRANSACTION_INVALID_FORK; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有对分叉点BLOCK较验,即该创建FORK的TX,要创建的FORK的分叉点BLOCK,可能不在该TX所以在链上,即在其它短链上,所以该TX应该是无效的。
} | ||
|
||
unconfirmedForkSetMgr.Insert(CForkContextEx(block.GetHash(), block.hashPrev, txid, profile, nBlockHeight, true)); | ||
return OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VerifyForkTx这个函数是较验功能,只对数据读使用,但在这里有写入数据,与这个函数的性质不符,容易产生理解错误,建议把这个添加数据的地方改为较验的上层做,更加明确函数功能。
{ | ||
vActive.push_back(hashFork); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vDeactive.push_back(update.hashFork)这部分是否需要放在 for (const CBlockEx& block : boost::adaptors::reverse(update.vBlockAddNew))之后,如果vBlockAddNew有多个BLOCK,则可能vDeactive.push_back(update.hashFork)被多次调用。
由另一个方案替代了#572 |
No description provided.