Closed Hecate2 closed 3 months ago
In order to debug the compiler for NFTLoan, you can set a conditional breakpoint token == 5
at neo-devpack-dotnet/src/Neo.Compiler.CSharp/MethodConvert/CallHelpers.cs:
return AddInstruction(new Instruction
{
OpCode = OpCode.CALLT,
Operand = BitConverter.GetBytes(token)
});
We should have gone into the branch at https://github.com/neo-project/neo-devpack-dotnet/blob/428b91835d9651bc2e8e2b4f67700847e32509fe/src/Neo.Compiler.CSharp/MethodConvert/ExternConvert.cs#L91-L92
It seems we can fix the problem if we change Symbol.AssociatedSymbol!
to Symbol
only, at the following line https://github.com/neo-project/neo-devpack-dotnet/blob/428b91835d9651bc2e8e2b4f67700847e32509fe/src/Neo.Compiler.CSharp/MethodConvert/ExternConvert.cs#L88
But this does not work for small contracts that makes no compilation error. For small contracts, Symbol.GetAttributes()
has Length=0.
My fault. I should have used recent versions of Neo3.Compiler.CSharp.Dev and Neo.SmartContract.Framework. Yet I was using 3.1.0. Maybe we can ask the compiler to check contract dependencies.
It could be arduous work to reproduce the problem.
git checkout 428b91835d9651bc2e8e2b4f67700847e32509fe
(the latest commit) and make the following changes (otherwise compilation would fail, because I usednew
methods):git clone https://github.com/Hecate2/NFTLoan.git
nccs NFTLoan/NFTLoan --debug --optimize=All --assembly
(You may also use--optimize=Basic
)NFTLoan/NFTLoan/bin/sc/NFTFlashLoan.nef.txt
and findCALLT 05-00 # GasToken.hash token call
This is incorrect. If the code is executed, we would call the
Hash
method of GAS contract (which does not exist).GAS.Hash
should be compiled asHowever I failed to reproduce the problem in small contracts like this:
namespace txHash { [DisplayName("txHash")] [ManifestExtra("Author", "NEO")] [ManifestExtra("Email", "developer@neo.org")] [ManifestExtra("Description", "This is a txHash")] public class txHash : SmartContract { public static UInt256 Main() { UInt160 zero = UInt160.Zero; ExecutionEngine.Assert((bool)Contract.Call(GAS.Hash, "transfer", CallFlags.All, zero, zero, 0, null), "Failed to pay GAS"); } } }