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
sc process audit - 1 #2647
Conversation
added unit Tests for SCPRocessor new and changeGasSchedule
# Conflicts: # integrationTests/vm/testInitializer.go
# Conflicts: # process/smartContract/process.go
# Conflicts: # process/smartContract/process.go
process/smartContract/process.go
Outdated
@@ -641,6 +644,8 @@ func (sc *scProcessor) computeTotalConsumedFeeAndDevRwd( | |||
} | |||
|
|||
if !sc.flagDeploy.IsSet() { | |||
//TODO: check if the totalFee is computed correctly for backwardsCompatible |
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.
yes it is. it does not matter here.
gas price modifier code and logic is handled in economicsData
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.
removed
process/smartContract/process.go
Outdated
@@ -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 |
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.
can be deleted
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.
removed
process/smartContract/process.go
Outdated
@@ -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 |
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.
vmOutput may be nil in case the VM returns nil, err
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.
ok, removed
process/smartContract/process.go
Outdated
@@ -1551,6 +1559,7 @@ func (sc *scProcessor) createSCRsWhenError( | |||
consumedFee.Sub(consumedFee, moveBalanceCost) | |||
} | |||
} else { | |||
//TODO: just AsynchronousCall here? No need for AsynchronousCallBack? |
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.
no need.
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.
ok, removed
process/transaction/baseProcess.go
Outdated
@@ -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 |
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.
this should stay is it is for backward compatibility reasons for the period until flagPenalizedTooMuchGas is not sent
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.
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() |
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.
no. this is correct. this was never changed
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.
ok! removed
process/transaction/shardProcess.go
Outdated
@@ -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? |
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.
this is correct. this was never changed. it should stay as it is.
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.
ok! removed
process/smartContract/process.go
Outdated
@@ -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? |
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.
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.
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.
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.
I think the todos will be removed as Robert answered them, otherwise looks ok
process/smartContract/process.go
Outdated
@@ -193,12 +193,15 @@ func (sc *scProcessor) GasScheduleChange(gasSchedule map[string]map[string]uint6 | |||
defer sc.mutGasLock.Unlock() | |||
|
|||
apiCosts := gasSchedule[core.ElrondAPICost] |
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.
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.
unit tests for scProcess - Deploy, Execute and some BuiltInFunctions