Skip to content

Commit

Permalink
v1.2.0-pre0 - Network Robustness, Fog 1.2.0, Apple Silicon/M1 & Mac…
Browse files Browse the repository at this point in the history
… Catalyst, `LibMobileCoin` v1.2.0-pre1 (#73)

# Title

`v1.2.0-pre0` - Network Robustness,  Fog 1.2.0, Apple Silicon/M1 & Mac Catalyst

# Description 

Added a way for implementing apps to pass in there own `HttpRequester` which can be useful for network robustness. Subspec `LibMobileCoin` now supports Apple Silicon/M1 and Mac Catalyst. Code changes to support Fog v1.2.0.

#### `pre1` Changes 

- Uses the `v1.2.0-pre1` version of `LibMobileCoin` which supports a higher version of `GRPC`.
- Added bridging headers
- Updated Gemfile/Makefile to use the latest `cocoapods` version `1.11.2`


#### Future Work

Fix the `docs` steps in the circleci build process. Will require `jazzy` related fixes and testing on Xcode 11.

# Changes

## Network Robustness

Adds a separate `HTTP` networking architecture. An object conforming to `protocol HttpRequester` can be provided to the `NetworkConfig` object when the `MobileCoinClient` is created. Then the `TransportProtocolOption` can be changed from `grpc` to `http`.

> NOTE: This branch will not run because it depends on changes in other submodules that have not yet been merged.

### `HttpRequester`

Implementing apps/frameworks should provide an object conforming to this protocol. Our `RestApiRequester` wraps around an `HttpRequester` to communicate with with our services using `protobuf`s.

```
Sources/Network/HttpConnection/HttpRequester.swift
```

### Attested & Auth Connection Wrappers

`HTTP` versions of the Auth & Attested wrapper classes. These protocol and their default implementations handle the logic paths needed for authentication/attestation and re-authentication/attestation:

> Can become generic

```
Sources/Network/HttpConnection/ArbitraryHttpConnection.swift
Sources/Network/HttpConnection/AttestedHttpConnection.swift
```

### Networking Protocols 

Separate code-paths for `HTTP` versions of the networking protocols:

```
Sources/Network/HttpConnection/HttpCallable/AttestedHttpCallable.swift
Sources/Network/HttpConnection/HttpCallable/AuthHttpCallable.swift
Sources/Network/HttpConnection/HttpCallable/AuthHttpCallableClientWrapper.swift
Sources/Network/HttpConnection/HttpCallable/HttpCallable.swift
```

`HTTP` "interfaces" that closely mimic functionality from `GRPC`. Allows us to re-use more of our existing patterns.

```
Sources/Network/HttpConnection/HTTPInterface/HTTPCallOptions.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPClient.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPClientCall.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPMethod.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPResponse.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPStatus.swift
Sources/Network/HttpConnection/HTTPInterface/HTTPUnaryCall.swift
```

### `HTTP` Connection Implementations

Wrapper classes that interface directly with `protoc-swift` generated `.swift` files for our protobuf models.

```
Sources/Network/HttpConnection/HttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/BlockchainHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/ConsensusHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogBlockHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogKeyImageHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogMerkleProofHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogReportHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogUntrustedTxOutHttpConnection.swift
Sources/Network/HttpConnection/HttpConnections/FogViewHttpConnection.swift
```

### `HTTP` versions of `protoc-swift` generated models

The GRPC versions of these are generated by `protoc-swift`. The HTTP versions were edited by hand to work with the `HTTP` Connections implementations. 

> **This could be automated preferably with a `protoc-swift` plugin template but also `sed`/`VIM` if needed.**

```
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/attest.http.swift
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/consensus_client.http.swift
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/consensus_common.http.swift
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/ledger.http.swift
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/report.http.swift
Sources/Network/HttpConnection/HttpConnections/Http Proto Generated/view.http.swift
```

## Fog Updates 

The latest version of `fog` changes the name of a protobuf `FogLedger_Block` -> `FogLedger_BlockData`.

### Compressed Commitment 

The `TxOut` compressed commitment is no longer sent in the protobuf message because it can be reconstructed with its constituent parts (+ the user's `view_private_key`)

We now reconstruct the commitment in several places whereas before it was being returned from the decoded protobuf message.

Lastly some function signatures into `LibMobileCoin` were updated to adjust to the changes.

## Miscellaneous

New MrEnclave values

Support for Apple Silicon/M1 & Mac Catalyst

## Unit Tests

One unit test was removed. It creates a TxOut and tries to unmask the value with an **incorrect** private view key. The return value should be 'nil' but is noise. It will require a change in the rust code and should be implemented in a future release.

Some objects were re-serialized to match the new TxOut structure.

Credentials are not required for `consensus` so this has been changed in the `NetworkConfig`

Tests can be run with `TransportProtocol == .http` by changing the default value in `NetworkConfig`
  • Loading branch information
the-real-adammork authored Sep 17, 2021
1 parent 446a1d3 commit 9bc59e1
Show file tree
Hide file tree
Showing 105 changed files with 4,054 additions and 764 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ jobs:
- print-tool-versions
- run: make build
- run: make test
- run: make docs
- run: make lint-docs
#- run: make docs
#- run: make lint-docs
- store_artifacts: { path: output }
- store_test_results: { path: output/scan }
- store_artifacts: { path: ~/Library/Logs/DiagnosticReports }
Expand Down Expand Up @@ -222,10 +222,10 @@ workflows:
matrix:
parameters:
xcode-version: ["11.7.0", *default-xcode-version]
- generate-docs:
filters:
branches: { only: master }
- deploy-docs:
requires: [ build-and-test, generate-docs ]
filters:
branches: { only: master }
#- generate-docs:
#filters:
#branches: { only: master }
#- deploy-docs:
#requires: [ build-and-test, generate-docs ]
#filters:
#branches: { only: master }
11 changes: 10 additions & 1 deletion Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -364,17 +364,20 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 05E35D1FAC2827984EE8B421 /* Pods-Example.debug.xcconfig */;
buildSettings = {
"ARCHS[sdk=iphonesimulator*]" = x86_64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = 8JT9JJD9Y5;
ENABLE_ONLY_ACTIVE_RESOURCES = NO;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.mobilecoin.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -386,17 +389,20 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 3AF40DB60A0ADA2CB879AE38 /* Pods-Example.release.xcconfig */;
buildSettings = {
"ARCHS[sdk=iphonesimulator*]" = x86_64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = 8JT9JJD9Y5;
ENABLE_ONLY_ACTIVE_RESOURCES = NO;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mobilecoin.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -463,17 +469,20 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FC106CAA4E993C2D6301C5CA /* Pods-Example.testable release.xcconfig */;
buildSettings = {
"ARCHS[sdk=iphonesimulator*]" = x86_64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
DEVELOPMENT_TEAM = 8JT9JJD9Y5;
ENABLE_ONLY_ACTIVE_RESOURCES = NO;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Example/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mobilecoin.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
5 changes: 4 additions & 1 deletion Example/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ GIT
fourflusher (~> 2.0)
xcpretty (~> 0.3.0)

GEM
specs:

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -290,4 +293,4 @@ DEPENDENCIES
fastlane!

BUNDLED WITH
2.1.4
2.2.24
11 changes: 5 additions & 6 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source 'https://cdn.cocoapods.org/'
platform :ios, '10.0'

plugin 'cocoapods-repo-update'
plugin 'cocoapods-binary'
keep_source_code_for_prebuilt_frameworks!
plugin 'cocoapods-keys', {
:project => "MobileCoin",
Expand All @@ -26,14 +25,14 @@ target 'Example' do
# pod 'MobileCoin', git: 'https://github.com/mobilecoinofficial/MobileCoin-Swift.git'
# pod 'MobileCoin/Core', git: 'https://github.com/mobilecoinofficial/MobileCoin-Swift.git', testspecs: ['Tests', 'IntegrationTests']

pod 'LibMobileCoin', binary: true
pod 'LibMobileCoin'
# pod 'LibMobileCoin', path: '../Vendor/libmobilecoin-ios-artifacts'
# pod 'LibMobileCoin', podspec: '../Vendor/libmobilecoin-ios-artifacts/LibMobileCoin.podspec'
# pod 'LibMobileCoin', git: 'https://github.com/mobilecoinofficial/libmobilecoin-ios-artifacts.git'
# pod 'LibMobileCoin', git: 'https://github.com/the-real-adammork/libmobilecoin-ios-artifacts.git'

pod 'gRPC-Swift', binary: true
pod 'SwiftProtobuf', binary: true
pod 'SwiftLint', binary: true
pod 'gRPC-Swift'
pod 'SwiftProtobuf'
pod 'SwiftLint'
end

post_install do |installer|
Expand Down
Loading

0 comments on commit 9bc59e1

Please sign in to comment.