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

Cannot reduce multiple actions in the same block on Berkeley #798

Closed
garethtdavies opened this issue Mar 18, 2023 · 3 comments
Closed

Cannot reduce multiple actions in the same block on Berkeley #798

garethtdavies opened this issue Mar 18, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@garethtdavies
Copy link
Contributor

garethtdavies commented Mar 18, 2023

I am submitting multiple transactions containing an action that is being included in the same block e.g., this block contains 2 https://berkeley.minaexplorer.com/block/3NL7njoFxYFhLXdVQmbtp47KR2qnAGsdvYgrxgkXT8mD1M9KLmx3

When I reduce this, i.e.,

let { state: newCounter, actionsHash: newActionsHash } =
            this.reducer.reduce(
                pendingActions,
                // state type
                Field,
                // function that says how to apply an action
                (state: Field, _action: Field) => {
                    return state.add(1);
                },
                { state: counter, actionsHash }
            );

        Circuit.log('newCounter', newCounter);
        Circuit.log('newActionsHash', newActionsHash);

The result of this is:

console.log
    rolling up pending actions..

      at Object.<anonymous> (src/actions.test.ts:229:17)

  console.log
    state before: 0

      at Object.<anonymous> (src/actions.test.ts:231:17)

  console.log
    actionsHash 12935064460869035604753254773225484359407575580289870070671311469994328713165

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    pendingActions []

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newCounter 0

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newActionsHash 12935064460869035604753254773225484359407575580289870070671311469994328713165

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    actionsHash 12935064460869035604753254773225484359407575580289870070671311469994328713165

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    pendingActions [ [ '1', '1' ] ]

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newCounter 0

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newActionsHash 20181218591800334489462324119362690974902046257048050553209249805515233657889

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    actionsHash 12935064460869035604753254773225484359407575580289870070671311469994328713165

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    pendingActions [ [ '1', '1' ] ]

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newCounter 0

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

  console.log
    newActionsHash 20181218591800334489462324119362690974902046257048050553209249805515233657889

      at node_modules/snarkyjs/src/lib/circuit_value.ts:1058:13

The sequence state of this account after these 2 actions have been included in the block is this. As the newActionsHash isn't the same the tx fails on a precondition. here https://berkeley.minaexplorer.com/transaction/5JtZjKU4jcmz8FXneSqXjmpqtvYS5rJARUvntTCPFm1Xy14ebkMM

"sequenceEvents": [
        "27901414991262126135412371664144148540281626029327762954351708127423118004668",
        "12935064460869035604753254773225484359407575580289870070671311469994328713165",
        "12935064460869035604753254773225484359407575580289870070671311469994328713165",
        "12935064460869035604753254773225484359407575580289870070671311469994328713165",
        "12935064460869035604753254773225484359407575580289870070671311469994328713165"
      ],

If I run this with only one action in the block, it works just fine, updating the on-chain state to newCounter.

Could there be an issue with the way the API is handling the data when there are multiple actions in the same block?

Should be labelled ITN-zkApps-E2E-testing

@garethtdavies
Copy link
Contributor Author

I think pendingActions [ [ '1', '1' ] ] should be pendingActions [ ['1'], ['1'] ]?

@garethtdavies
Copy link
Contributor Author

When running locally on tests that pass, the logging does indicate the formatting is incorrect:

 console.log
    pendingActions [ [ '1' ], [ '1' ] ]

@mitschabaude
Copy link
Contributor

@MartinMinkov we should check if there is an inconsistency between archive node and protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants