Skip to content

Commit

Permalink
Simply logic; Rename EVMTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Oct 25, 2023
1 parent 0299768 commit 3dee973
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
12 changes: 4 additions & 8 deletions src/dfi/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Res CustomTxVisit(const CCustomTxMessage &txMessage, BlockContext &blockCtx, con

if (!evmTemplate && isEvmEnabledForBlock) {
std::string minerAddress{};
blockCtx.SetEVMTemplateId(CScopedTemplate::Create(height, minerAddress, 0u, time));
blockCtx.SetEVMTemplate(CScopedTemplate::Create(height, minerAddress, 0u, time));
if (!evmTemplate) {
return Res::Err("Failed to create queue");
}
Expand Down Expand Up @@ -604,15 +604,11 @@ Res ApplyCustomTx(BlockContext &blockCtx, const TransactionContext &txCtx, uint2
if (!res) {
res.msg = strprintf("%sTx: %s", ToString(txType), res.msg);

if (height >= static_cast<uint32_t>(consensus.DF6DakotaHeight)) {
res.code |= CustomTxErrCodes::Fatal;
} else if (IsBelowDakotaMintTokenOrAccountToUtxos(txType, height)) {
if (ShouldReturnNonFatalError(tx, height)) {
return res;
}
res.code |= CustomTxErrCodes::Fatal;
if (IsBelowDakotaMintTokenOrAccountToUtxos(txType, height) && ShouldReturnNonFatalError(tx, height)) {
return res;
}

res.code |= CustomTxErrCodes::Fatal;
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ ResVal<std::unique_ptr<CBlockTemplate>> BlockAssembler::CreateNewBlock(const CSc
const auto &evmTemplate = blockCtx.GetEVMTemplate();

if (isEvmEnabledForBlock) {
blockCtx.SetEVMTemplateId(CScopedTemplate::Create(nHeight, evmBeneficiary, pos::GetNextWorkRequired(pindexPrev, pblock->nTime, consensus), blockTime));
blockCtx.SetEVMTemplate(CScopedTemplate::Create(nHeight, evmBeneficiary, pos::GetNextWorkRequired(pindexPrev, pblock->nTime, consensus), blockTime));
if (!evmTemplate) {
return Res::Err("Failed to create block template");
}
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
return state.Invalid(ValidationInvalidReason::CONSENSUS, error("%s: Failed to process XVM in coinbase", __func__),
REJECT_INVALID, "bad-xvm-coinbase");
}
blockCtx.SetEVMTemplateId(CScopedTemplate::Create(pindex->nHeight, xvmRes->evm.beneficiary, block.nBits, pindex->GetBlockTime()));
blockCtx.SetEVMTemplate(CScopedTemplate::Create(pindex->nHeight, xvmRes->evm.beneficiary, block.nBits, pindex->GetBlockTime()));
if (!evmTemplate) {
return state.Invalid(ValidationInvalidReason::CONSENSUS, error("%s: Failed to create block template", __func__),
REJECT_INVALID, "bad-evm-template");
Expand Down Expand Up @@ -6340,6 +6340,6 @@ void BlockContext::SetEVMPreValidate(const bool other) {
evmPreValidate = other;
}

void BlockContext::SetEVMTemplateId(const std::shared_ptr<CScopedTemplate> &id) {
void BlockContext::SetEVMTemplate(const std::shared_ptr<CScopedTemplate> &id) {
evmTemplate = id;
}
6 changes: 3 additions & 3 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class BlockContext {
public:
explicit BlockContext(CCustomCSView *view = {},
const std::optional<bool> enabled = {},
const std::shared_ptr<CScopedTemplate> &id = {},
const std::shared_ptr<CScopedTemplate> &evmTemplate = {},
const bool prevalidate = {}) :
view(view),
isEvmEnabledForBlock(enabled),
evmTemplate(id),
evmTemplate(evmTemplate),
evmPreValidate(prevalidate) {}

[[nodiscard]] CCustomCSView &GetView();
Expand All @@ -86,7 +86,7 @@ class BlockContext {

void SetView(CCustomCSView &other);
void SetEVMPreValidate(const bool other);
void SetEVMTemplateId(const std::shared_ptr<CScopedTemplate> &id);
void SetEVMTemplate(const std::shared_ptr<CScopedTemplate> &evmTemplate);
};

class TransactionContext {
Expand Down

0 comments on commit 3dee973

Please sign in to comment.