0

After saving some value into an sawtooth address, I try to recover it via the rest-api but it responds "There is no state data at the address specified". Here are the steps I've done:

From the tx processor (python sdk) I call "set_state", and check that my address is in returned list.

// address = 7749f2d822961a489fac22690b773c1b613c890197bf65090d3c468f4ba8964b98c555
// value = 327 bytes
addresses = context.set_state({address: value})
//addresses contains the given address

Due to this error, as a validation, I read the value using "get_state", right after that previous line of the tx processor. I can successfully get the value I writed.

state_entries = context.get_state([address])
//state_entries contains the given address

Later from a web client I make a request to the rest-api at 'http://rest-api:8008/state/ADDRESS' (where the address is the one previously set). But the response says "Unable to find entry at address". This is the full response:

sawtooth-nmso-web-client |   size: 0,
sawtooth-nmso-web-client |   timeout: 0,
sawtooth-nmso-web-client |   [Symbol(Body internals)]: {
sawtooth-nmso-web-client |     body: PassThrough {
sawtooth-nmso-web-client |       _readableState: [ReadableState],
sawtooth-nmso-web-client |       readable: true,
sawtooth-nmso-web-client |       _events: [Object: null prototype],
sawtooth-nmso-web-client |       _eventsCount: 2,
sawtooth-nmso-web-client |       _maxListeners: undefined,
sawtooth-nmso-web-client |       _writableState: [WritableState],
sawtooth-nmso-web-client |       writable: false,
sawtooth-nmso-web-client |       allowHalfOpen: true,
sawtooth-nmso-web-client |       _transformState: [Object],
sawtooth-nmso-web-client |       [Symbol(kCapture)]: false
sawtooth-nmso-web-client |     },
sawtooth-nmso-web-client |     disturbed: false,
sawtooth-nmso-web-client |     error: null
sawtooth-nmso-web-client |   },
sawtooth-nmso-web-client |   [Symbol(Response internals)]: {
sawtooth-nmso-web-client |     url: 'http://rest-api:8008/state/7749f2d822961a489fac22690b773c1b613c890197bf65090d3c468f4ba8964b98c555',
sawtooth-nmso-web-client |     status: 404,
sawtooth-nmso-web-client |     statusText: 'Not Found',
sawtooth-nmso-web-client |     headers: Headers { [Symbol(map)]: [Object: null prototype] },
sawtooth-nmso-web-client |     counter: 0
sawtooth-nmso-web-client |   }
sawtooth-nmso-web-client | }
sawtooth-nmso-web-client | UserClient.js > request_to_rest_api > response.json:  {
sawtooth-nmso-web-client |   error: {
sawtooth-nmso-web-client |     code: 75,
sawtooth-nmso-web-client |     message: 'There is no state data at the address specified.',
sawtooth-nmso-web-client |     title: 'State Not Found'
sawtooth-nmso-web-client |   }
sawtooth-nmso-web-client | }

Anyone knows what I'm doing wrong? Thanks

klautern
  • 129
  • 3
  • 7
  • 26
  • 1
    Check if the transaction is successfully committed in a block. A set_state() call does not translate to a persistent storage write. This is not a mere database write operation. The same state shall be synced up across participants. The commit of the transaction in a block guarantees that you should have state information. – Arun Apr 29 '21 at 10:44
  • Thanks for the tip. From the logs something is going on with the block: sawtooth-validator-default | [2021-04-29 14:39:12.710 DEBUG ffi] [src/journal/block_scheduler.rs: 166] Adding block for processing sawtooth-validator-default | [2021-04-29 14:39:12.741 WARNING (unknown file)] [src/journal/block_validator.rs: 272] Block failed validation: Block failed validation: expected state hash , validation found state hash sawtooth-validator-default | [2021-04-29 14:39:12.710 DEBUG ffi] – klautern Apr 29 '21 at 14:44
  • It seems the problem was a not deterministic result of the transaction processor. I was using the current time in the tp logic. – klautern Apr 29 '21 at 15:23

0 Answers0