Skip to content

Commit

Permalink
limit free gas (#697)
Browse files Browse the repository at this point in the history
* add log when exception happens under debug mode (#686)

* Revert "add log when exception happens under debug mode (#686)" (#689)

This reverts commit 7b661e5.

* limit free gas

* update limit

Co-authored-by: Jinghui Liao <jinghui@wayne.edu>
Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com>
Co-authored-by: Shargon <shargon@gmail.com>
  • Loading branch information
4 people authored Mar 11, 2022
1 parent 5afd15f commit 4b30f3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/TokensTracker/Trackers/NEP-11/Nep11Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void SaveDivisibleNFTBalance(TransferRecord record, DataCache snapshot)
using ScriptBuilder sb = new();
sb.EmitDynamicCall(record.asset, "balanceOf", record.from, record.tokenId);
sb.EmitDynamicCall(record.asset, "balanceOf", record.to, record.tokenId);
using ApplicationEngine engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings);
using ApplicationEngine engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings, gas: 3400_0000);
if (engine.State.HasFlag(VMState.FAULT) || engine.ResultStack.Count != 2)
{
Console.WriteLine($"Fault: from[{record.from}] to[{record.to}] get {record.asset} token [{record.tokenId.GetSpan().ToHexString()}] balance fault", LogLevel.Warning);
Expand Down
3 changes: 1 addition & 2 deletions src/TokensTracker/Trackers/NEP-17/Nep17Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public override void OnPersist(NeoSystem system, Block block, DataCache snapshot
try
{
SaveNep17Balance(balanceChangeRecord, snapshot);

}
catch (Exception e)
{
Expand Down Expand Up @@ -112,7 +111,7 @@ private void SaveNep17Balance(BalanceChangeRecord balanceChanged, DataCache snap
var key = new Nep17BalanceKey(balanceChanged.User, balanceChanged.Asset);
using ScriptBuilder sb = new();
sb.EmitDynamicCall(balanceChanged.Asset, "balanceOf", balanceChanged.User);
using ApplicationEngine engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings);
using ApplicationEngine engine = ApplicationEngine.Run(sb.ToArray(), snapshot, settings: _neoSystem.Settings, gas: 1700_0000);

if (engine.State.HasFlag(VMState.FAULT) || engine.ResultStack.Count == 0)
{
Expand Down

0 comments on commit 4b30f3c

Please sign in to comment.