MystenLabs / sui

Sui, a next-generation smart contract platform with high throughput, low latency, and an asset-oriented programming model powered by the Move programming language
https://sui.io
Apache License 2.0
5.91k stars 11.09k forks source link

Error in Poseidon hashing. #17893

Open purusang opened 1 month ago

purusang commented 1 month ago

Steps to Reproduce Issue

Whenever poseidon::poseidon_bn254( ) is called I get error. Simplest way to reproduce is to deploy the following package.

module test_poseidon::test {
    use sui::poseidon;
    fun init(ctx: &mut TxContext) {
        init_tree(ctx);
    }
    public entry fun init_tree(ctx: &mut TxContext) {
        let  hash_value =  poseidon::poseidon_bn254( &vector[232223u256] );
    }
    #[test]
    fun test_poseidon(){
        let  hash_value =  poseidon::poseidon_bn254( &vector[232223u256] );
        assert!(hash_value == 9403926361891226276855360605123709468282972937875825299715520399635063203567u256, 0);
    }
}

The same issue can be reproduced even when calling init_tree through interface of suiscan.xyz by commenting out the constructor in the module.

sui move test Result

Test passes on sui move test.

Devnet test

The code runs in devnet as expected.

Expected Result

Should have deployed without any error.

Actual Result

Successfully verified dependencies on-chain against source. Error executing transaction: Failure { error: "MoveAbort(MoveLocation { module: ModuleId { address: 0000000000000000000000000000000000000000000000000000000000000002, name: Identifier(\"poseidon\") }, function: 1, instruction: 0, function_name: Some(\"poseidon_bn254_internal\") }, 1) in command 0", }

System Information

kchalkias commented 1 month ago

Indeed poseidon is still only available in devnet, as community devs are working on tooling / apis and battle-test it before it gets available in the rest of the networks. Afaik, we'll soon promote it to testnet and then mainnet.

purusang commented 1 month ago

Thank you so much for the information @kchalkias . I was about to deploy my code to mainnet to test it out. Poseidon hash is the key component of our zk based project which we will be presenting in Hackathon too. So can we submit our work to hackathon in Devnet?

kchalkias commented 1 month ago

@purusang yes devnet is totally fine