Skip to content

Commit

Permalink
Merge of patche19
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjatlanta committed Mar 26, 2019
2 parents 8dcb644 + 2956cf4 commit 167b355
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 3 deletions.
66 changes: 66 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: Bug Report
about: Create a detailed report about a deficiency in the BitShares Core implementation.

---

**Instructions**
Please include a detailed Title above. Next, please complete the following sections below:
* Bug Description
* Impacts
* Steps To Reproduce
* Expected Behavior
* Screenshots (optional)
* Host Environment (optional)
* Additional Context (optional)

Finally, press the 'Submit new issue' button. The Core Team will evaluate and prioritize your Bug Report for future development.

**Bug Description**
A clear and concise description of what the bug is.

**Impacts**
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.
- [ ] API (the application programming interface)
- [ ] Build (the build process or something prior to compiled code)
- [ ] CLI (the command line wallet)
- [ ] Deployment (the deployment process after building such as Docker, Travis, etc.)
- [ ] DEX (the Decentralized EXchange, market engine, etc.)
- [ ] P2P (the peer-to-peer network for transaction/block propagation)
- [ ] Performance (system or user efficiency, etc.)
- [ ] Protocol (the blockchain logic, consensus, validation, etc.)
- [ ] Security (the security of system or user data, etc.)
- [ ] UX (the User Experience)
- [ ] Other (please add below)

**Steps To Reproduce**
Steps to reproduce the behavior (example outlined below):
1. Execute API call '...'
2. Using JSON payload '...'
3. Received response '...'
4. See error in screenshot

**Expected Behavior**
A clear and concise description of what you expected to happen.

**Screenshots (optional)**
If applicable, add screenshots to help explain process flow and behavior.

**Host Environment**
Please provide details about the host environment. Much of this information can be found running: `witness_node --version`.
- Host OS: [e.g. Ubuntu 18.04 LTS]
- Host Physical RAM [e.g. 4GB]
- BitShares Version: [e.g. 2.0.180425]
- OpenSSL Version: [e.g. 1.1.0g]
- Boost Version: [e.g. 1.65.1]

**Additional Context (optional)**
Add any other context about the problem here.

## CORE TEAM TASK LIST
- [ ] Evaluate / Prioritize Bug Report
- [ ] Refine User Stories / Requirements
- [ ] Define Test Cases
- [ ] Design / Develop Solution
- [ ] Perform QA/Testing
- [ ] Update Documentation
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/build_error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Build Error
about: Create a detailed report about an error encountered during the BitShares Core build process.

---

**Instructions**
Please include a detailed Title above. Next, please complete the following sections below:
* Build Error
* Build Environment
* Steps To Reproduce
* Console Logs (optional)

Finally, press the 'Submit new issue' button. The Core Team will evaluate and prioritize your Bug Report for future development.

**Build Error Description**
A clear and concise description of what the build error is.

**Build Environment**
Details about the build environment, including the relevant required libraries. Much of this information can be found in the `CMakeFiles/CMakeOutput.log`.
- Host OS: [e.g. Ubuntu 18.04 LTS]
- Host Physical RAM [e.g. 4GB]
- Source Branch/Tag: [e.g. master or 2.0.180425]
- OpenSSL Version: [e.g. 1.1.0g]
- Boost Version: [e.g. 1.65.1]
- C++ Compiler: [e.g. gcc version 4.8.5]

**Steps To Reproduce**
Steps to reproduce the behavior (example outlined below):
1. Using installation guide from this URL...
2. This is my complete build script...
3. It fails at this step with the following output...
4. See the error in the console log below...

**Console Logs (optional)**
Please provide the full console log, including all commands entered and their output. This will allow detailed troubleshooting.

## CORE TEAM TASK LIST
- [ ] Evaluate `Build Error`
- [ ] Provide build guidance
- [ ] <OR> Create `Bug Report`
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Feature Request
about: Suggest an idea for the BitShares Core Team to evaluate and prioritize for development.

---

**Instructions**
Please include a detailed Title above. Next, please complete the following sections below:
* User Story
* Impacts
* Additional Context (optional)

Finally, press the 'Submit new issue' button. The Core Team will evaluate and prioritize your Feature Request for future development.

**User Story**
Please tell us about your feature request using the User Story format:
As a `<persona>` I want `<some functionality>` so that `<some benefit is realized>`.

At minimum, please define the `<who>`, `<what>` and `<why>` for your feature request. The `<who>` may be the system software, a component thereof, the end user, etc.; please be specific describing the context. The `<what>` details the solution your feature will provide; please describe the process flow for the functionality. The `<why>` details the benefits the feature will deliver; consider referencing alternative implementations for context.

**Impacts**
Describe which portion(s) of BitShares Core may be impacted by your request. Please tick at least one box.
- [ ] API (the application programming interface)
- [ ] Build (the build process or something prior to compiled code)
- [ ] CLI (the command line wallet)
- [ ] Deployment (the deployment process after building such as Docker, Travis, etc.)
- [ ] DEX (the Decentralized EXchange, market engine, etc.)
- [ ] P2P (the peer-to-peer network for transaction/block propagation)
- [ ] Performance (system or user efficiency, etc.)
- [ ] Protocol (the blockchain logic, consensus, validation, etc.)
- [ ] Security (the security of system or user data, etc.)
- [ ] UX (the User Experience)
- [ ] Other (please add below)

**Additional Context (optional)**
Add any other context about your request here.

## CORE TEAM TASK LIST
- [ ] Evaluate / Prioritize Feature Request
- [ ] Refine User Stories / Requirements
- [ ] Define Test Cases
- [ ] Design / Develop Solution
- [ ] Perform QA/Testing
- [ ] Update Documentation
3 changes: 2 additions & 1 deletion libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope
d.adjust_balance( o.funding_account, o.delta_debt );

// Deduct the debt paid from the total supply of the debt asset.
d.modify(*_dynamic_data_obj, [&](asset_dynamic_data_object& dynamic_asset) {
d.modify(_debt_asset->dynamic_asset_data_id(d), [&o](asset_dynamic_data_object& dynamic_asset) {
FC_ASSERT( dynamic_asset.current_supply + o.delta_debt.amount <= GRAPHENE_MAX_SHARE_SUPPLY ); //_debt_asset->options.max_supply );
dynamic_asset.current_supply += o.delta_debt.amount;
});
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/chain/proposal_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ struct proposal_operation_hardfork_visitor
const fc::time_point_sec block_time;
const fc::time_point_sec next_maintenance_time;

proposal_operation_hardfork_visitor( const database& _db, const fc::time_point_sec bt )
: db( _db ), block_time(bt), next_maintenance_time( db.get_dynamic_global_properties().next_maintenance_time ) {}
proposal_operation_hardfork_visitor( const database& _db, const fc::time_point_sec& bt )
: db( _db ), block_time( bt ),
next_maintenance_time( db.get_dynamic_global_properties().next_maintenance_time ) {}

template<typename T>
void operator()(const T &v) const {}
Expand Down
86 changes: 86 additions & 0 deletions tests/tests/call_order_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/market_object.hpp>

#include "../common/database_fixture.hpp"
Expand Down Expand Up @@ -345,4 +346,89 @@ BOOST_AUTO_TEST_CASE( call_order_object_test )

} FC_CAPTURE_LOG_AND_RETHROW( (0) ) }

#define BILLION 1000000000

BOOST_AUTO_TEST_CASE( mpa_supply_test )
{ try {

ACTORS( (feeder)(borrower) );
fund( borrower, asset( BILLION ) );

generate_blocks( fc::time_point::now() );
generate_block();

set_expiration( db, trx );
const auto& bitusd = create_bitasset( "USDBIT", feeder_id );
const asset_id_type usd_id = bitusd.id;
const asset_id_type core_id;
update_feed_producers( usd_id( db ), { feeder_id } );

price_feed feed;
feed.maintenance_collateral_ratio = 1750; // need to set this explicitly, testnet has a different default
feed.settlement_price = usd_id( db ).amount( BILLION ) / core_id( db ).amount( 1 );
publish_feed( usd_id( db ), feeder_id( db ), feed );

borrow( borrower_id, usd_id( db ).amount( GRAPHENE_MAX_SHARE_SUPPLY / 2 ), asset( GRAPHENE_MAX_SHARE_SUPPLY * 10 / BILLION ) );
borrow( borrower_id, usd_id( db ).amount( GRAPHENE_MAX_SHARE_SUPPLY / 2 ), asset( GRAPHENE_MAX_SHARE_SUPPLY * 10 / BILLION ) );
GRAPHENE_REQUIRE_THROW( borrow( borrower_id, usd_id( db ).amount( 1 ),
asset( GRAPHENE_MAX_SHARE_SUPPLY * 10 / BILLION ) ), fc::assert_exception );

trx.clear();
call_order_update_operation cup;
cup.funding_account = borrower_id;
cup.delta_collateral = asset( GRAPHENE_MAX_SHARE_SUPPLY * 10 / BILLION );
cup.delta_debt = usd_id( db ).amount( 1 );
proposal_create_operation pop;
pop.proposed_ops.emplace_back( cup );
pop.fee_paying_account = borrower_id;
pop.expiration_time = db.head_block_time() + fc::days(1);
trx.operations.push_back( pop );
sign( trx, borrower_private_key );
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx ), fc::assert_exception );
trx.clear();

generate_block();

BOOST_CHECK( usd_id( db ).dynamic_asset_data_id( db ).current_supply.value == GRAPHENE_MAX_SHARE_SUPPLY );

const auto& btc = create_bitasset( "BTCUSD", feeder_id, 0, 0, 8, usd_id );
const asset_id_type btc_id = btc.id;
update_feed_producers( btc_id( db ), { feeder_id } );

feed.maintenance_collateral_ratio = 1100;
feed.maximum_short_squeeze_ratio = 1001;
feed.settlement_price = btc_id( db ).amount( 1101 ) / usd_id( db ).amount( 1000 );
feed.core_exchange_rate = btc_id( db ).amount( 1 ) / asset( 1 );
publish_feed( btc_id( db ), feeder_id( db ), feed );

borrow( borrower_id, btc_id( db ).amount( GRAPHENE_MAX_SHARE_SUPPLY - 1 ),
usd_id( db ).amount( GRAPHENE_MAX_SHARE_SUPPLY - 10 ) );
GRAPHENE_REQUIRE_THROW( borrow( borrower_id, btc_id( db ).amount( 2 ), usd_id( db ).amount( 10 ) ), fc::assert_exception );

trx.clear();
cup.delta_collateral = usd_id( db ).amount( 10 );
cup.delta_debt = btc_id( db ).amount( 2 );
pop.proposed_ops.clear();
pop.proposed_ops.emplace_back( cup );
trx.operations.push_back( pop );
sign( trx, borrower_private_key );
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx ), fc::assert_exception );
trx.clear();

borrow( borrower_id, btc_id( db ).amount( 1 ), usd_id( db ).amount( 10 ) );

generate_block();

BOOST_CHECK( btc_id( db ).dynamic_asset_data_id( db ).current_supply.value == GRAPHENE_MAX_SHARE_SUPPLY );

force_settle( borrower_id, btc_id( db ).amount( GRAPHENE_MAX_SHARE_SUPPLY ) );

generate_blocks( db.head_block_time() + (*btc_id( db ).bitasset_data_id)( db ).options.force_settlement_delay_sec - 5 );

feed.settlement_price = btc_id( db ).amount( 1000 ) / usd_id( db ).amount( 1000 );
publish_feed( btc_id( db ), feeder_id( db ), feed );

generate_block( 2 );
} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 167b355

Please sign in to comment.