-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: market crud #1565
feat: market crud #1565
Conversation
2cf6c00
to
7f3478e
Compare
14fdcc2
to
b83db58
Compare
d7cde6a
to
b9b5883
Compare
await market.RemoveWorker(accounts[0], master, { from: master }); | ||
}); | ||
}); | ||
// describe('RegisterWorker', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for hide this tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due this section tests cases while market is paused. Now master-worker relations is separated contract. Later, me or @abefimov will update tests and may be administratum would be tested in separate test file. And i leaved (just commented, not deleted) this tests for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep tests clean.
Remove old and write new.
Don't do it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still reviewing
|
||
uint dealAmount = 0; | ||
Deals dl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use better names here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quasisamurai why? Choose better name pls.
await market.RemoveWorker(accounts[0], master, { from: master }); | ||
}); | ||
}); | ||
// describe('RegisterWorker', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep tests clean.
Remove old and write new.
Don't do it like that.
blockchain/source/truffle.js
Outdated
@@ -58,7 +60,7 @@ module.exports = { | |||
}, | |||
solc: { | |||
optimizer: { | |||
enabled: true, | |||
enabled: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope :(
bbc1da5
to
2f0bcb1
Compare
2f0bcb1
to
9cf59d4
Compare
|
||
|
||
|
||
//modifiers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this?
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "./AdministratumCrud.sol"; | ||
|
||
contract Administratum is Ownable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Administratable
or Ownable
9cf59d4
to
af19f6c
Compare
|
||
OpenDeal(askID, GetOrdersAmount()); | ||
OpenDeal(askID, ordersCrud.GetOrdersAmount()); | ||
} | ||
|
||
// Deal functions | ||
|
||
function OpenDeal(uint _askID, uint _bidID) whenNotPaused public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public
should be first modifier
|
||
// if deal is normal | ||
if (ask.duration != 0) { | ||
endTime = startTime.add(bid.duration); | ||
if (ordersCrud.GetOrderDuration(_askID) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is normal
deal is this?
we already have spot
and forward
deals.
orders crud master-worker crud deals crud change requests crud massive market reworking update tests update migrations least crud contracts updations update gas usage in truffle.js contracts works fine migrations updated, will refactor later
0b47038
to
806b999
Compare
9cf59d4
to
806b999
Compare
* administratum: advanced master-worker relations * feat: change onwable => administratable * orders crud * master-worker crud * deals crud * change requests crud * massive market reworking * feat: migrate func added * crud for administratum * fix: cr status bug * fix: counterpartry bid matching * fix: migrate order * rating fields
* administratum: advanced master-worker relations * feat: change onwable => administratable * orders crud * master-worker crud * deals crud * change requests crud * massive market reworking * feat: migrate func added * crud for administratum * fix: cr status bug * fix: counterpartry bid matching * fix: migrate order * rating fields
* administratum: advanced master-worker relations * feat: change onwable => administratable * orders crud * master-worker crud * deals crud * change requests crud * massive market reworking * feat: migrate func added * crud for administratum * fix: cr status bug * fix: counterpartry bid matching * fix: migrate order * rating fields
* administratum: advanced master-worker relations * feat: change onwable => administratable * orders crud * master-worker crud * deals crud * change requests crud * massive market reworking * feat: migrate func added * crud for administratum * fix: cr status bug * fix: counterpartry bid matching * fix: migrate order * rating fields
* administratum: advanced master-worker relations * feat: change onwable => administratable * orders crud * master-worker crud * deals crud * change requests crud * massive market reworking * feat: migrate func added * crud for administratum * fix: cr status bug * fix: counterpartry bid matching * fix: migrate order * rating fields
resolved problem
Here is yet not finished Proof-of-concept CRUD for Market. While I worked on this, i found some critical issues caused by Solidity & EVM design. So let's start:
Order memory ask = orders[_askID]; Order memory bid = orders[_bidID]
This one reffers only for 4 variables, named
But when you're trying to implement CRUD, you need to get exact vars from storage SC.
There are two noticable things aproaching then:
So data taken from storage contract woul'd be look like this:
( Orders.OrderType orderType, address author, address counterparty, uint duration, uint price, bool[] memory netflags, ProfileRegistry.IdentityLevel identityLevel, address blacklist, bytes32 tag, uint64[] memory benchmarks, uint frozenSum) = ord.GetOrderInfo(askID);
Here is the part of order, the immutable data.This situation totally rapes compiler by calling only a part of one order. Even without casting this vars as a struct But we need two full orders. And that's is only begining.
Why this is going on like this?
Solidity has a limit for local variables (16).
So every input parameter to the function takes one variable, and each return value takes one variable, and each struct cast, and each local declaration takes another variable, and references to storage take two - it surprised me how quickly the limit of 16 was reached.
will reserve 5 slots in stack (i'm not sure, it's just an empirical conclusion)
That is an old problem, we faced some months ago and it was a cause why we splitted one order/deal getter by two for both structs.
Since almost each function uses one/two orders or a deal sctruct, there is no way to implement crud this way. That's not the only issue i faced, but I think this is the most significant problem that needs to be solved.
So here is implemented crud for market
Included:
Deals
Orders
ChangeRequests
Master-worker contract named Administratum (discussable)
Also crud for Administratum
Updated event WorkerConfirmed (api-breaking)
Updated test enviroment (watch truffle.js & test.sh)
Aslo fixed some non-critical bugs
By the way we faced and original problem binded with this EIP. So we decided to modify our stack to avoid problems with contract's bytecode limit.
p.s. some weird comments and getters will be removed after refactoring iteration soon. 🇺🇦