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

Testing #1454

Closed
wants to merge 17 commits into from
Prev Previous commit
Next Next commit
fixing typos
shotaronowhere committed Apr 15, 2022
commit 448a8313c7ad7fa2a3d880c15e41e291717b11bc
11 changes: 5 additions & 6 deletions contracts/src/arbitration/KlerosCore.sol
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ import {SortitionSumTreeFactory} from "../data-structures/SortitionSumTreeFactor
* Core arbitrator contract for Kleros v2.
*/
contract KlerosCore is IArbitrator {
using SimpleSquanch for bytes32; // Use library functions for deserialization to reduce L1 calldata costs on Optimistic Rollups.
using SSQ for bytes32; // Use library functions for deserialization to reduce L1 calldata costs on Optimistic Rollups.
using SortitionSumTreeFactory for SortitionSumTreeFactory.SortitionSumTrees; // Use library functions for sortition sum trees.

// ************************************* //
@@ -344,12 +344,12 @@ contract KlerosCore is IArbitrator {
// ************************************* //

/** @dev Sets the caller's stake in a subcourt by passing serialized args to reduce L1 calldata gas costs on optimistic rollups.
* @param _agrs The SSQ serialized arguments.
* @param _args The SSQ serialized arguments.
*/
function setStake(bytes32 _args) external{
uint256 subcourtID;
uint256 stake;
(tmp, _args) = _args.unsquanchUint256();
(subcourtID, _args) = _args.unsquanchUint256();
(stake, _args) = _args.unsquanchUint256();
require(setStakeForAccount(msg.sender, uint96(subcourtID), stake, 0), "Staking failed");
}
@@ -385,9 +385,11 @@ contract KlerosCore is IArbitrator {
*/
function createDispute(uint256 _numberOfChoices, bytes calldata _extraData)
external
override
payable
returns (uint256 disputeID)
{
require(msg.value >= arbitrationCost(_extraData), "Not enough ETH to cover arbitration cost.");
return _createDispute(_numberOfChoices, _extraData);
}

@@ -399,11 +401,8 @@ contract KlerosCore is IArbitrator {
*/
function _createDispute(uint256 _numberOfChoices, bytes memory _extraData)
internal
payable
override
returns (uint256 disputeID)
{
require(msg.value >= arbitrationCost(_extraData), "Not enough ETH to cover arbitration cost.");
(uint96 subcourtID, , uint8 disputeKitID) = extraDataToSubcourtIDMinJurorsDisputeKit(_extraData);

uint256 bitToCheck = 1 << disputeKitID; // Get the bit that corresponds with dispute kit's ID.
10 changes: 5 additions & 5 deletions contracts/src/libraries/SSQ.sol
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ library SSQ {
* @param decodedBytes Left zero padded bytes array containing decoded values.
* @param remainder The remaining encoded byte32.
*/
function unsquanchBytesLeftPadded(bytes32 encoded) public returns (bytes memory decodedBytes, bytes32 remainder){
function unsquanchBytesLeftPadded(bytes32 encoded) public pure returns (bytes memory decodedBytes, bytes32 remainder){

assembly {

@@ -129,7 +129,7 @@ library SSQ {
* @param decodedUint256 Decoded uint256
* @param remainder The remaining encoded byte32.
*/
function unsquanchUint256(bytes32 encoded) public returns (uint256 decodedUint256, bytes32 remainder){
function unsquanchUint256(bytes32 encoded) public pure returns (uint256 decodedUint256, bytes32 remainder){
assembly {
let decodedIndex := 0
for { let j := 0 } lt(j,0x20) {j := add(j,1)} {
@@ -148,7 +148,7 @@ library SSQ {
* @param decodedUint256Array Left zero padded bytes array containing decoded values.
* @param remainder The remaining encoded byte32.
*/
function unsquanchUint256Array(bytes32 encoded) public returns (uint256[] memory decodedUint256Array, bytes32 remainder){
function unsquanchUint256Array(bytes32 encoded) public pure returns (uint256[] memory decodedUint256Array, bytes32 remainder){

assembly {

@@ -191,7 +191,7 @@ library SSQ {
* @param _input Input to be serialized.
* @param _result Serialized 'Squanched' result.
*/
function encode(bytes32 _input) public returns (bytes32 _result){
function encode(bytes32 _input) public pure returns (bytes32 _result){
assembly {
let i := 0
for { } gt(_input,0x7F) {i := add(i,1)} {
@@ -206,7 +206,7 @@ library SSQ {
* @param _input Input to be deserialized.
* @param _result Deserialized 'Unsquanched' result.
*/
function decode(bytes32 _input) public returns (bytes32 _result){
function decode(bytes32 _input) public pure returns (bytes32 _result){
assembly {
for { let i := 0x0 } gt(_input,0) {i := add(i,0x1)} {
_result := add(_result,shl(mul(7,i),and(_input, 0x7F)))