Skip to content
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

sc process audit - 1 #2647

Merged
merged 21 commits into from Jan 18, 2021
Merged

sc process audit - 1 #2647

merged 21 commits into from Jan 18, 2021

Conversation

raduchis
Copy link
Contributor

@raduchis raduchis commented Jan 6, 2021

unit tests for scProcess - Deploy, Execute and some BuiltInFunctions

@raduchis raduchis changed the title [WIP] sc process audit sc process audit Jan 18, 2021
@raduchis raduchis marked this pull request as ready for review January 18, 2021 13:12
@raduchis raduchis changed the title sc process audit sc process audit - 1 Jan 18, 2021
process/smartContract/process.go Outdated Show resolved Hide resolved
process/smartContract/process.go Outdated Show resolved Hide resolved
@@ -641,6 +644,8 @@ func (sc *scProcessor) computeTotalConsumedFeeAndDevRwd(
}

if !sc.flagDeploy.IsSet() {
//TODO: check if the totalFee is computed correctly for backwardsCompatible
Copy link
Contributor

Choose a reason for hiding this comment

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

yes it is. it does not matter here.
gas price modifier code and logic is handled in economicsData

Copy link
Contributor Author

@raduchis raduchis Jan 18, 2021

Choose a reason for hiding this comment

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

removed

@@ -1214,6 +1219,7 @@ func (sc *scProcessor) addBackTxValues(

// DeploySmartContract processes the transaction, than deploy the smart contract into VM, final code is saved in account
func (sc *scProcessor) DeploySmartContract(tx data.TransactionHandler, acntSnd state.UserAccountHandler) (vmcommon.ReturnCode, error) {
// TODO: check return 0 and err is ok? 0 is vmCommon.OK
Copy link
Contributor

Choose a reason for hiding this comment

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

can be deleted

Copy link
Contributor Author

@raduchis raduchis Jan 18, 2021

Choose a reason for hiding this comment

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

removed

@@ -1264,6 +1270,7 @@ func (sc *scProcessor) DeploySmartContract(tx data.TransactionHandler, acntSnd s
return vmcommon.UserError, sc.ProcessIfError(acntSnd, txHash, tx, err.Error(), []byte(""), snapshot, vmInput.GasLocked)
}

//TODO: check why userError in the following ifs and not vmoutput.ReturnCode
Copy link
Contributor

Choose a reason for hiding this comment

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

vmOutput may be nil in case the VM returns nil, err

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, removed

@@ -1551,6 +1559,7 @@ func (sc *scProcessor) createSCRsWhenError(
consumedFee.Sub(consumedFee, moveBalanceCost)
}
} else {
//TODO: just AsynchronousCall here? No need for AsynchronousCallBack?
Copy link
Contributor

Choose a reason for hiding this comment

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

no need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, removed

@@ -150,6 +150,7 @@ func (txProc *baseTxProcessor) checkTxValues(
txFee = txProc.economicsFee.ComputeTxFee(tx)
}

// TODO: check this: if checks the txFee against the balance before the txFee is finalized on the next if
Copy link
Contributor

Choose a reason for hiding this comment

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

this should stay is it is for backward compatibility reasons for the period until flagPenalizedTooMuchGas is not sent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok! removed

@@ -333,6 +333,7 @@ func (inTx *InterceptedTransaction) SenderAddress() []byte {

// Fee returns the estimated cost of the transaction
func (inTx *InterceptedTransaction) Fee() *big.Int {
//TODO: check this, also no: !txProc.flagPenalizedTooMuchGas.IsSet()
Copy link
Contributor

Choose a reason for hiding this comment

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

no. this is correct. this was never changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok! removed

@@ -256,6 +256,8 @@ func (txProc *txProcessor) executingFailedTransaction(
return nil
}

//TODO: check here, there is no if !flagPenalizedTooMuchGas.IsSet():
// could it happen that not all taken fee or too much is taken from the sender account?
Copy link
Contributor

Choose a reason for hiding this comment

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

this is correct. this was never changed. it should stay as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok! removed

@@ -1534,6 +1541,7 @@ func (sc *scProcessor) createSCRsWhenError(
}

accumulatedSCRData := ""
// TODO: check why just ESDTTransfer here. No problem with burn, freeze? Can't they be crossShard?
Copy link
Contributor

Choose a reason for hiding this comment

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

the return data in case of burn and freeze is handled otherwise. The tokens are sent back through ESDTTransfer in case of error from metachain sc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok!

ccorcoveanu
ccorcoveanu previously approved these changes Jan 18, 2021
Copy link
Contributor

@ccorcoveanu ccorcoveanu left a comment

Choose a reason for hiding this comment

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

I think the todos will be removed as Robert answered them, otherwise looks ok

@@ -193,12 +193,15 @@ func (sc *scProcessor) GasScheduleChange(gasSchedule map[string]map[string]uint6
defer sc.mutGasLock.Unlock()

apiCosts := gasSchedule[core.ElrondAPICost]
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for now, but this function could grow in the future, we should either make a structure from gasSchedule map[string]map[string]uint64, or at least have a simple function that fetches or checks nested maps.

mihaib79
mihaib79 previously approved these changes Jan 18, 2021
@LucianMincu LucianMincu merged commit d8e4729 into development Jan 18, 2021
@LucianMincu LucianMincu deleted the scprocess-audit branch January 18, 2021 22:41
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.

None yet

5 participants