Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
release: 11.0.0 (#1034)
Browse files Browse the repository at this point in the history
* Add V4 order format

* Bump ganache snapshot version to include V3 & V4

* Add ExchangeProxy (v4) address

* Add Bytes32 type

* Use Bytes32 and fix EIP712 type and encoding

* []byte encoding should work

* Switch to cherry-picked go-ethereum

* Set correct reference hash, test passes

* Add sign test (fails)

* Signature test

* Verify signer address

* Fix signature

* Fix taker/maker

* use OrderWithMetadata as the common type

* Document contract events

* Cleanup

* Add DevUtilsV4 contract addresses

* Document wrapper generation

* Require V4 addresses in app config

* add FindOrdersV4 and AddOrdersV4

* move queries to sql_queries.go and sql_v4_queries.go

also fixes insertQuery

* Add generated contracts

* Fix build issues

* Document wrapper gen

* Fixed Exchange wrapper

* ABI type conversion

* Implement validator

* Scenario support for v4 orders

* Test validator v4

* Fix length test

* Fix signature test

* Add SignatureType to ABI struct

* Helper to create an eth client

* Ganache orderhash workaround

* Fix test

* Test siging util

* Validator v4 tests

* Minimal failing state test

* Fix orderstate test

* Cleanup

* Add V4 orderstate

* Set ERC20 allowances on V3 & V4

* Fix batch test

* Cleanup

* Exact chunking

* Fix OffchainValidate test

* Skip failing v3 test

* add remaining db methods,add graphql findOrderV4 schema and resolver (#1005)

* add remaining db methods,add graphql findOrderV4 schema and resolver

* add order v4 signature into sqltypes and db

* add jsonschema validators, new types, v4 signature storage

* adds marshallers for the signed order type

* make GetCurrentMaxExpirationTime use both v3 and v4 orders

* add batch validation to addOrdersV4

* P2P v4: PubSub and Ordersync (with orderwatcher pr merged in) (#1011)

* Add aplicable tests

* Mechanical replacements

* More test porting

* Fix exchange address in check

* V4 orders in orderInfoToOrderWithMetadata

* Handle mixed orders

* Fix taker address

* Generic db.AddOrders

* Handle V4 orders in setupInMemoryOrderState

* Use FindOrdersV4

* Fix keeping rejected V4 orders

* Decode assetData for tokens

* V4 support in findOrdersByTokenAddress

* Add v4 support to more queries

* Add V4 to generateOrderEventsIfChanged

* Dispatching UpdateOrder

* Set V4 fields in orderevent

* Dispatch expiry update

* V4 has no maker fee

* Support V4 in ERC20 approve

* Handle mixed orders

* Fix tests

* Dispatch expiry in convertValidationResultsIntoOrderEvents

* Support ExchangeOrderCancelledEventV4

* Add ExchangePairCancelledLimitOrdersEventV4

* Fix tests

* More V4 dispatching in order watcher

* Add Cancelled event

* Fix TestOrderWatcherV4HandleOrderExpirationsExpired

* Use GetOderV4

* Fix UpdateOrder ErrNotFound

* Add ExchangeLimitOrderFilledEventV4

* OrderSync V4 scafolding

* Create ordersync protocol V4

* Integrate V4 service with App

* Add V4 pubsub receiver

* Handle v4 messages

* Simlpify and share V4

* Fix tests

* Remove debug prints

* Increase test timeout

* Update ganache snapshot

* Unahck order hash

* Upgrade to snapshot 6.5.11

* chore: v4 clients and minor changes

* ADDS websocket client onReconnected optional callback

* FIXES disable results caching

* ADDS gitpkg integration

* update apollo client, use fetchPolicy on subscription

* add graphql addOrdersV4 onto client

* continue the v4 client progress

* add gql resolver changes

* fix client hash and query

* fix mesh graphql client

* update conversions

* move queries, update tests

* use nested type for signature in ts SignedOrderV4

* update protocol strings

* bump vbersion to 10.3.0

* add numOrderV4 to Stats and other missing fields

* update client types to accept new GetStats query results

* fix types and export some order results

* use proper VerifyingContract field on the OrderV4 types

Co-authored-by: Kim Persson <[email protected]>

* ADDS random client fixes (#1014)

* Order event order fields are optional

* Allow event order fields to be null

* Regenerate graphql types

* send v4 order events

* fix: graphql client V4 order query response structure (#1017)

* FIXES graphql client V4 order query response structure

* FIXES remove duplicate signature properties from parsed orders

* FIXES unify OrderV4WithMetadata fields returned by queries and mutations

* Add back INVALID order event end state (#1027)

* add back "
INVALID" end state

* add log msg for uncaught RejectedOrderStatus

* cut release 11.0.0

Co-authored-by: Remco Bloemen <[email protected]>
Co-authored-by: Kim Persson <[email protected]>
Co-authored-by: Kim Persson <[email protected]>
Co-authored-by: Xianny <[email protected]>
  • Loading branch information
5 people authored Mar 2, 2021
1 parent 1fcb8c7 commit 4581600
Show file tree
Hide file tree
Showing 82 changed files with 17,979 additions and 1,792 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- image: circleci/golang:1.15-browsers
- image: 0xorg/ganache-cli:istanbul
environment:
VERSION: 6.2.4
VERSION: 6.5.11
SNAPSHOT_NAME: 0x_ganache_snapshot
resource_class: large
steps:
Expand Down
44 changes: 37 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,11 @@ changing any Go code will require running `yarn build` at the root of the projec
Some of the tests depend on having a test Ethereum node running. Before running
the tests, make sure you have [Docker](https://docs.docker.com/install/)
installed locally and start
[0xorg/ganache-cli](https://hub.docker.com/r/0xorg/ganache-cli). In these commands,
`$GANACHE_VERSION` should be set to the version of ganache-cli that is used in the mesh project's
CI found [here](https://github.com/0xProject/0x-mesh/blob/development/.circleci/config.yml#L10):
[0xorg/ganache-cli](https://hub.docker.com/r/0xorg/ganache-cli) with the appropriate [snapshot version](https://github.com/0xProject/protocol/blob/development/packages/migrations/README.md#publish) passed in the `VERSION` environment variable. The snapshot version that is used in the mesh project's
CI can be found [here](https://github.com/0xProject/0x-mesh/blob/development/.circleci/config.yml#L10)

```
docker pull 0xorg/ganache-cli
# Run the $GANACHE_VERSION image of ganache-cli.
docker run -ti -p 8545:8545 -e VERSION=$GANACHE_VERSION 0xorg/ganache-cli
docker run --rm --pull -ti -p 8545:8545 -e VERSION=6.5.11 0xorg/ganache-cli
```

There are various Make targets for running tests:
Expand Down Expand Up @@ -183,3 +179,37 @@ Prettier configurations for most popular text editors can be found

TSLint configurations for most popular text editors can be found
[here](https://palantir.github.io/tslint/usage/third-party-tools/).

### Updating the Go contract wrappers

**Installing abi-gen:**

See <https://geth.ethereum.org/docs/dapp/native-bindings>

```
git clone [email protected]:ethereum/go-ethereum.git
cd go-ethereum
git checkout v1.9.24
go install ./cmd/abigen
```

**Obtain contract ABIs:**

Extract any ABI from [`@0x/contract-artifacts/artifacts/*.json`](https://github.com/0xProject/protocol/tree/development/packages/contract-artifacts/artifacts), taking only the contents of the `abi` key. For example for the V4 DevUtils contract:

```
git clone [email protected]:0xProject/protocol.git
jq < protocol/packages/contract-artifacts/artifacts/DevUtils.json .compilerOutput.abi > DevUtilsV4.abi.json
```

jq < ../protocol/packages/contract-artifacts/artifacts/IZeroEx.json .compilerOutput.abi > IZeroEx.abi.json

The V4 ABI contains some internal functions whose names start with `_`. The next `abigen` command will strip the underscores and fail due to name collisions with non-prefixed versions. The easiest solution is to manually remove these functions from the JSON. (TODO: Come up with a `jq` query to automate this).

**Generate wrapper:**

```
abigen --abi ./IZeroEx.abi.json --pkg wrappers --type ExchangeV4 --out ethereum/wrappers/exhange_v4.go
```

Then edit the file and correct the `package` name and remove any commonalities between different wrappers.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test-key-value-stores-wasm:

.PHONY: test-go-serial
test-go-serial:
go test ./zeroex/ordervalidator ./zeroex/orderwatch ./core -race -timeout 90s -p=1 --serial
go test ./zeroex/ordervalidator ./zeroex/orderwatch ./core -race -timeout 300s -p=1 --serial

.PHONY: test-browser-integration
test-browser-integration: test-browser-legacy-integration test-browser-graphql-integration
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Version](https://img.shields.io/badge/version-10.2.2-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
[![Version](https://img.shields.io/badge/version-11.0.0-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
[![Docs](https://img.shields.io/badge/docs-website-yellow.svg)](https://0x-org.gitbook.io/mesh)
[![Chat with us on Discord](https://img.shields.io/badge/chat-Discord-blueViolet.svg)](https://discord.gg/HF7fHwk)
[![Circle CI](https://img.shields.io/circleci/project/0xProject/0x-mesh/master.svg)](https://circleci.com/gh/0xProject/0x-mesh/tree/master)
Expand Down
76 changes: 40 additions & 36 deletions common/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ type Stats struct {
LatestBlock LatestBlock `json:"latestBlock"`
NumPeers int `json:"numPeers"`
NumOrders int `json:"numOrders"`
NumOrdersV4 int `json:"numOrdersV4"`
NumOrdersIncludingRemoved int `json:"numOrdersIncludingRemoved"`
NumOrdersIncludingRemovedV4 int `json:"numOrdersIncludingRemovedV4"`
NumPinnedOrders int `json:"numPinnedOrders"`
NumPinnedOrdersV4 int `json:"numPinnedOrdersV4"`
MaxExpirationTime *big.Int `json:"maxExpirationTime"`
StartOfCurrentUTCDay time.Time `json:"startOfCurrentUTCDay"`
EthRPCRequestsSentInCurrentUTCDay int `json:"ethRPCRequestsSentInCurrentUTCDay"`
Expand Down Expand Up @@ -110,26 +113,14 @@ func (o *OrderInfo) UnmarshalJSON(data []byte) error {
}

type OrderWithMetadata struct {
Hash common.Hash `json:"hash"`
ChainID *big.Int `json:"chainID"`
ExchangeAddress common.Address `json:"exchangeAddress"`
MakerAddress common.Address `json:"makerAddress"`
MakerAssetData []byte `json:"makerAssetData"`
MakerFeeAssetData []byte `json:"makerFeeAssetData"`
MakerAssetAmount *big.Int `json:"makerAssetAmount"`
MakerFee *big.Int `json:"makerFee"`
TakerAddress common.Address `json:"takerAddress"`
TakerAssetData []byte `json:"takerAssetData"`
TakerFeeAssetData []byte `json:"takerFeeAssetData"`
TakerAssetAmount *big.Int `json:"takerAssetAmount"`
TakerFee *big.Int `json:"takerFee"`
SenderAddress common.Address `json:"senderAddress"`
FeeRecipientAddress common.Address `json:"feeRecipientAddress"`
ExpirationTimeSeconds *big.Int `json:"expirationTimeSeconds"`
Salt *big.Int `json:"salt"`
Signature []byte `json:"signature"`
FillableTakerAssetAmount *big.Int `json:"fillableTakerAssetAmount"`
LastUpdated time.Time `json:"lastUpdated"`
OrderV3 *zeroex.Order
OrderV4 *zeroex.OrderV4

Hash common.Hash `json:"hash"`
Signature []byte `json:"signature"`
SignatureV4 zeroex.SignatureFieldV4 `json:"signaturev4"`
FillableTakerAssetAmount *big.Int `json:"fillableTakerAssetAmount"`
LastUpdated time.Time `json:"lastUpdated"`
// Was this order flagged for removal? Due to the possibility of block-reorgs, instead
// of immediately removing an order when FillableTakerAssetAmount becomes 0, we instead
// flag it for removal. After this order isn't updated for X time and has IsRemoved = true,
Expand Down Expand Up @@ -169,29 +160,42 @@ type OrderWithMetadata struct {
}

func (order OrderWithMetadata) SignedOrder() *zeroex.SignedOrder {
if order.OrderV3 == nil {
return nil
}
return &zeroex.SignedOrder{
Order: zeroex.Order{
ChainID: order.ChainID,
ExchangeAddress: order.ExchangeAddress,
MakerAddress: order.MakerAddress,
MakerAssetData: order.MakerAssetData,
MakerFeeAssetData: order.MakerFeeAssetData,
MakerAssetAmount: order.MakerAssetAmount,
MakerFee: order.MakerFee,
TakerAddress: order.TakerAddress,
TakerAssetData: order.TakerAssetData,
TakerFeeAssetData: order.TakerFeeAssetData,
TakerAssetAmount: order.TakerAssetAmount,
TakerFee: order.TakerFee,
SenderAddress: order.SenderAddress,
FeeRecipientAddress: order.FeeRecipientAddress,
ExpirationTimeSeconds: order.ExpirationTimeSeconds,
Salt: order.Salt,
ChainID: order.OrderV3.ChainID,
ExchangeAddress: order.OrderV3.ExchangeAddress,
MakerAddress: order.OrderV3.MakerAddress,
MakerAssetData: order.OrderV3.MakerAssetData,
MakerFeeAssetData: order.OrderV3.MakerFeeAssetData,
MakerAssetAmount: order.OrderV3.MakerAssetAmount,
MakerFee: order.OrderV3.MakerFee,
TakerAddress: order.OrderV3.TakerAddress,
TakerAssetData: order.OrderV3.TakerAssetData,
TakerFeeAssetData: order.OrderV3.TakerFeeAssetData,
TakerAssetAmount: order.OrderV3.TakerAssetAmount,
TakerFee: order.OrderV3.TakerFee,
SenderAddress: order.OrderV3.SenderAddress,
FeeRecipientAddress: order.OrderV3.FeeRecipientAddress,
ExpirationTimeSeconds: order.OrderV3.ExpirationTimeSeconds,
Salt: order.OrderV3.Salt,
},
Signature: order.Signature,
}
}

func (order OrderWithMetadata) SignedOrderV4() *zeroex.SignedOrderV4 {
if order.OrderV4 == nil {
return nil
}
return &zeroex.SignedOrderV4{
OrderV4: *order.OrderV4, // QUESTION: Is there a reason we would explicitly copy every field like above instead of doing this?
Signature: order.SignatureV4,
}
}

type SingleAssetData struct {
Address common.Address `json:"address"`
TokenID *big.Int `json:"tokenID"`
Expand Down
Loading

0 comments on commit 4581600

Please sign in to comment.