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

Invalid checksum error when deploy contract(version3.6.2) #928

Open
Tobeyw opened this issue Apr 8, 2024 · 8 comments
Open

Invalid checksum error when deploy contract(version3.6.2) #928

Tobeyw opened this issue Apr 8, 2024 · 8 comments

Comments

@Tobeyw
Copy link

Tobeyw commented Apr 8, 2024

When we deployed the 3.6.2 version contract withneonjs, an invalid checksum error occurred.
I found that the latest version of n3 compiler 3.6.2 deleted the MaxScriptLength field of the nefFile file, which changed the calculation method of chenkSum. I guess it may be related to this.
neo-project/neo@efa8659#diff-e5a9d7d849aceff46a01663d9e6246d09c4c82e49af60f21dc879d05c40481ee

image

@Tobeyw Tobeyw changed the title invalid checksum Invalid checksum error when deploy contract(version3.6.2) Apr 8, 2024
@ixje
Copy link
Member

ixje commented Apr 8, 2024

The format of the NEF hasn't changed with that commit. It seems to only change the allowed size of the script field from 512*1024 (as defined by MaxScriptLength) to ushort.max * 2 (as defined by ExecutionEngineLimits.Default.MaxItemSize).

I'll try out the new 3.6.2. compiler and see if I can reproduce

@luc10921
Copy link
Contributor

luc10921 commented Apr 9, 2024

I tried running the fromBuffer method using my NEF file generated with the 3.6.2 compiler and it worked.

    const myNef = sc.NEF.fromBuffer(
      readFileSync(
        "path\\to\\nef\\file"
      )
    )

Do you know which neon-js version you are using?

@Tobeyw
Copy link
Author

Tobeyw commented Apr 10, 2024

@cityofzion/neon-js": "^5.5.1",
This is the compiled file of the tested contract. contract.zip
I tried to deploy the contract using other methods and it worked.

@ixje
Copy link
Member

ixje commented Apr 10, 2024

Can you please share the code snippet used that caused the error and also what you now use that works? The checksum in the file seems correct, so this is a strange case and we need a bit more information to investigate.

@Tobeyw
Copy link
Author

Tobeyw commented Apr 10, 2024

This is the code I deploy the contract with neon-js. neonjs

This is the code I deploy the contract with C# and it worked.

@ixje
Copy link
Member

ixje commented Apr 10, 2024

The neonjs code is loading a different file (\Neo3ContractTest.nef) than what the C# code is loading (SampleHelloWorld, link). You previously shared SampleHelloWorld and that file is correct. I can't say anything about Neo3ContractTest.nef

@Tobeyw
Copy link
Author

Tobeyw commented Apr 10, 2024

This is what I tested with other versions of the contract. It has not been updated. The code is the same, just the files are different. Please ignore it.

@luc10921
Copy link
Contributor

The problem was occurring because neon-js had a problem when deserializing a compiler that uses all 64 available characters

And since the compiler you are using is probably some version from the master branch instead of the one at NuGet, the compiler name occupies all 64 chars (Neo.Compiler.CSharp 3.6.2+c9ccbb646657240053065ec7c7ff02f106d...).

I created a PR to fix this problem.

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

No branches or pull requests

3 participants