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

Add missing operations #324

Closed
ergomorphic opened this issue Dec 6, 2018 · 1 comment
Closed

Add missing operations #324

ergomorphic opened this issue Dec 6, 2018 · 1 comment
Assignees
Milestone

Comments

@ergomorphic
Copy link
Collaborator

ergomorphic commented Dec 6, 2018

New operations in SigmaPredef

See spec

New methods for various objects

See spec

Unary operations (// Testnet2)

! : SBoolean => SBoolean  // logical Not 
- : SNumeric => SNumeric  // negation operation
~ : SNumeric => SNumeric  // bitwise inversion of all bits

Bitwise operations (// Testnet2)

^ : (SBoolean, SBoolean) => SBoolean // logical XOR  

| : (SNumeric, SNumeric) => SNumeric // bitwise OR for all numeric types 
& : (SNumeric, SNumeric) => SNumeric // bitwise AND for all numeric types 
^ : (SNumeric, SNumeric) => SNumeric // bitwise XOR for all numeric types 

/** Returns this value bit-shifted right by the specified number of bits, 
filling in the left bits with the same value as the left-most bit of this. */
>> : (SNumeric, SNumeric) => SNumeric 

/** Returns this value bit-shifted left by the specified number of bits, 
filling in the new right bits with zeroes. */
<< : (SNumeric, SNumeric) => SNumeric 

/** Returns this value bit-shifted right by the specified number of bits, 
filling in the new left bits with zeroes. */
>>> : (SNumeric, SNumeric) => SNumeric 

/** Returns this collection bit-shifted left by the specified number of bits, 
    filling in the new right bits with zeroes. The size of collection is preserved. */
<< : (Coll[Boolean], SInt) => Coll[Boolean]

/** Returns this collection bit-shifted right by the specified number of bits, 
filling in the left bits with the same value as the left-most bit of this. 
The size of collection is preserved.*/
>> : (Coll[Boolean], SInt) => Coll[Boolean]

/** Returns this collection bit-shifted right by the specified number of bits, 
filling in the new left bits with zeroes. The size of collection is preserved.*/
>>> : (Coll[Boolean], SInt) => Coll[Boolean]

Operation to be replaces/renamed

Existing Exponentiate operation use symbol ^ which should be used for bitwise XOR instead.
See method SGroupElement.exp above.

Using bitwise operations and zip it is possible to implement existing Xor for collections (symbol |)

def Xor[T](c1: Coll[T], c2: Coll[T]): Coll[T] = c1.zipWith(c2, { (x, y) => x ^ y })

UPDATE(Denys, Feb 12):

Status of the new operations in SigmaPredef:
Implemented in parser:

  • xorOf;
  • byteArrayToLong;
  • substConstants;
  • executeFromVar;
  • outerJoin;
    Implemented up to the typer:
  • !(logical Not);
  • -(negation);
  • ~ (bitwise inversion);
  • ^ (logical XOR);
  • | (bitwise OR for Numeric);
  • & (bitwise AND for Numeric);
  • ^ (bitwise XOR for Numeric);
  • <<, >>, >>> (bit shifts for Numeric);
  • <<, >>, >>> (shifts for Collection); Implement >> and << operations #418

Status of the new methods for various objects:

Boolean:
Not implemented:

  • toByte.

Numeric:
Implemented up to the typer:

  • toBytes;
  • toBits;
    Not implemented(need to express "same" type):
  • abs;
  • compare;

BigInt:
Implemented up to the typer:

  • all new methods;

Context:
Not implemented (blocked by #350, see comments);

Header and PreHeader:
Not implemented, need to move in underlying types from ergo;

AvlTree:
Not implemented;

Box:
Implemented up to the typer:

  • tokens;

GroupElement:
Implemented all new methods up to the typer:

  • exp;

Option:
Implemented all new methods up to the typer:

  • toColl;
  • flatMap;
  • map, filter (costing failing, see ignored tests in SigmaCompilerTest and BasicOpsSpec);

Coll:
Implemented all new methods up to the typer.
The following new methods are implemented fully(tests in CollectionOpsSpec):

  • indexOf;
  • segmentLength;
  • indexWhere;
  • lastIndexWhere;
  • zip;
  • partition;
  • patch;
  • updated;
  • updatedMany;
    The following new methods are failing in evaluation (see ignored tests in CollectionOpsSpec):
  • flatMap (output array instantiation error);
  • indices (method call itself ends up in the cost func graph);
@ergomorphic ergomorphic added this to the Mainnet milestone Dec 6, 2018
@ergomorphic ergomorphic changed the title Add Option.map operation Add missing operations Dec 13, 2018
ergomorphic pushed a commit that referenced this issue Dec 19, 2018
* add byteArrayToLong, decodePoint, xorOf parser tests;

* add SBoolean.toByte, SOption.map, SCollection.zip, zipWith, flatMap parser tests;

* add parser tests for new SBigInt, SNumeric, SGroupElement methods;

* add parser tests for HEADERS methods;

* add LogicalNot boolean unary op in parser;

* add Negation unary op for numeric type in parser;

* add BitInversion unary op in parser;

* add BinXor binary op in parser;
commented out tests for ^ bin op (used for exponentiate);

* add BitOp node;
add parser test for bitwise AND;

* make ^ to parse as method;

* add bit-shifted ops to the parser;

* add bit collections shift ops handling in parser;
add BitRotateLeft, BitRotateLeft handling in parser;

* rename parameters, add comments;

* update scala to 2.12.8 (sync with ergo);

* re-arrange op codes after rebase;

* assign | for bit OR for numeric types;

* fixed HEADERS parser test;

* merged BitRotateLeft and BitRotateRight into BitRotate and renamed params (removed TwoArgumentsOperation);

* generalize BitRotate into Rotate to use with collection of any type;

* generalize shifts to use with collection of any type;
@ergomorphic ergomorphic modified the milestones: Mainnet, Testnet2 Dec 25, 2018
@aslesarenko aslesarenko modified the milestones: Testnet2, Mainnet Apr 3, 2019
@greenhat
Copy link
Member

Moving all unfinished operations to #479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants