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

Illegal argument with createShieldedContractParameters #6165

Open
317787106 opened this issue Feb 12, 2025 · 2 comments · Fixed by #6174
Open

Illegal argument with createShieldedContractParameters #6165

317787106 opened this issue Feb 12, 2025 · 2 comments · Fixed by #6174
Labels

Comments

@317787106
Copy link
Contributor

Software Versions

OS : Linux
JVM : Oracle Corporation 1.8.0_161 amd64
Version : 4.7.4
Code : 18306

Expected behavior

The gRPC API of the wallet should specify the root cause when request failed, not the error log stack.

Actual behavior

I was running a fullnode on Nile, and constructed PrivateShieldedTRC20Parameters with the following values in my program:

{
    "ask":"c2513e9e308494932bd82e0ce53662d17421d90b72a8471a0a12b8552a336e02",
    "nsk":"4c6bf3dd4a0643d20b628f7e45980c5e187f07a51d6f3e86aaf1ab916c07eb0d",
    "ovk":"17a58d9a5058da6e42ca12cd289d0a6aa169b926c18e19bca518b8d6f8674e43",
    "from_amount":"100",
    "shielded_receives":[
        {
            "note":{
                "value":10,
                "payment_address":"",
                "rcm":"16b6f5e40444ab7eeab11ae6613c27f35117971efa87b71560b5813829c9390d"
            }
        }
    ],
    "shielded_TRC20_contract_address":"41D7175DEDFD7EA842493CB4CDA6B066501F0FA1C8"
}

Then I called the gRPC API createShieldedContractParameters with above PrivateShieldedTRC20Parameters. I found the fullnode throws error stack in tron.log:

11:08:59.477 ERROR [rpc-full-executor-1] [API](RpcApiService.java:2485) createShieldedContractParameters: 
java.lang.IllegalArgumentException: Input too short: 0
        at org.tron.common.utils.Bech32.decode(Bech32.java:149)
        at org.tron.core.zen.address.KeyIo.decodePaymentAddress(KeyIo.java:33)
        at org.tron.core.Wallet.buildShieldedTRC20Output(Wallet.java:3467)
        at org.tron.core.Wallet.createShieldedContractParameters(Wallet.java:3536)
        at org.tron.core.Wallet$$FastClassBySpringCGLIB$$3f6b5781.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
        at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
        at org.tron.common.prometheus.MetricAspect.walletAroundAdvice(MetricAspect.java:43)
        at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
        at org.tron.core.Wallet$$EnhancerBySpringCGLIB$$476d52c3.createShieldedContractParameters(<generated>)
        at org.tron.core.services.RpcApiService$WalletApi.createShieldedContractParameters(RpcApiService.java:2477)
        at org.tron.api.WalletGrpc$MethodHandlers.invoke(WalletGrpc.java:11234)
        at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
        at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35)
        at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23)
        at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40)
        at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:355)
        at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:867)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

It was an uncaught exception. This interface should deal with it elegantly.

Therefore, I tried with the HTTP API wallet/createshieldedcontractparameters using the same parameter:

curl --location 'http://localhost:8090/wallet/createshieldedcontractparameters' --header 'Content-Type:application/json' --data '{
    "ask":"c2513e9e308494932bd82e0ce53662d17421d90b72a8471a0a12b8552a336e02",
    "nsk":"4c6bf3dd4a0643d20b628f7e45980c5e187f07a51d6f3e86aaf1ab916c07eb0d",
    "ovk":"17a58d9a5058da6e42ca12cd289d0a6aa169b926c18e19bca518b8d6f8674e43",
    "from_amount":"100",
    "shielded_receives":[
        {
            "note":{
                "value":10,
                "payment_address":"",
                "rcm":"16b6f5e40444ab7eeab11ae6613c27f35117971efa87b71560b5813829c9390d"
            }
        }
    ],
    "shielded_TRC20_contract_address":"41D7175DEDFD7EA842493CB4CDA6B066501F0FA1C8"
}

I got the following result:

{"Error":"class java.lang.IllegalArgumentException : Input too short: 0"}

but the log didn’t show any error. It’s more elegant.

Frequency

I can repeat it certainly using the gRPC API.

Backtrace

[backtrace]

When submitting logs: please submit them in text, not screenshots.

@AbuKram032012
Copy link

Y

@Sunny6889
Copy link

Sunny6889 commented Feb 14, 2025

Hi @317787106,

This issue is caused by your "payment_address":"". According to the java-tron logic, it must contain between 8 to 90 characters. However, your suggestion is very good; it would be better to output a detailed error reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants