PISAresearch / pisa

Accountable Watching Service
https://pisa.watch
28 stars 9 forks source link

Contract should check time windows in response for nonce == nonce #344

Open yahgwai opened 5 years ago

yahgwai commented 5 years ago

we currently have this check:

                uint nonce;
                uint recordedTime;
                bytes32 recordedHash;

                // Block number + nonce recorded
                (recordedTime, nonce, recordedHash) = abi.decode(response[j], (uint, uint, bytes32));

                // A future nonce was used? Will be all good... appointment may be completely different
                if(nonce >= _nonce) { return true; }

                // It must meaningful
                require(recordedTime != 0);

                // PISA should respond between the start time and finish time
                // _timewindow[0] -> recordedTime <- _timewindow[1]
                //
                // We should also find the exact same AppointmentHash :) if so nonce is good too
                if(recordedTime >= _timewindow[0] && // Did PISA respond after the start time?
                   recordedTime <= _timewindow[1] &&
                   recordedHash == _expectedHash) {
                   return true;
                }

but we should be doing something like this:

(uint blockNumber, uint nonce) = abi.decode(dataRegistryItems[j], (uint, uint));

                // we cant check the start and end block here because if the nonce is not equal to the current one
                // the start and end block may be different
                if(nonce > appointment.nonce) return true;
                else if(
                    nonce = appointment.nonce &&
                    blockNumber >= startBlock &&
                    blockNumber <= startBlock + responsePeriod
                    ) {
                    return true;
                }
haiki commented 3 years ago

hi, I'd like to know where the contract codes are? I know the project form the paper "Pisa: Arbitration Outsourcing for State Channels", and I am wondered if there had contracts which were written in the paper, including SC, CC... thanks