From 121fc3657d45c390229c9019ebdba02e80a13276 Mon Sep 17 00:00:00 2001 From: alexqrid <> Date: Thu, 11 Jul 2024 21:43:02 +0300 Subject: [PATCH 1/4] added BounceBit module --- Modules/BounceBitERC1155Module.php | 20 ++++++++++++++++++ Modules/BounceBitERC20Module.php | 20 ++++++++++++++++++ Modules/BounceBitERC721Module.php | 20 ++++++++++++++++++ Modules/BounceBitMainModule.php | 33 ++++++++++++++++++++++++++++++ Modules/BounceBitTraceModule.php | 24 ++++++++++++++++++++++ Modules/Common/EVMMainModule.php | 3 +++ Modules/Common/EVMTraits.php | 1 + 7 files changed, 121 insertions(+) create mode 100644 Modules/BounceBitERC1155Module.php create mode 100644 Modules/BounceBitERC20Module.php create mode 100644 Modules/BounceBitERC721Module.php create mode 100644 Modules/BounceBitMainModule.php create mode 100644 Modules/BounceBitTraceModule.php diff --git a/Modules/BounceBitERC1155Module.php b/Modules/BounceBitERC1155Module.php new file mode 100644 index 0000000..61021ad --- /dev/null +++ b/Modules/BounceBitERC1155Module.php @@ -0,0 +1,20 @@ +blockchain = 'bouncebit'; + $this->module = 'bouncebit-erc-1155'; + $this->is_main = false; + $this->first_block_date = '2024-04-08'; + $this->first_block_id = 1; + } +} diff --git a/Modules/BounceBitERC20Module.php b/Modules/BounceBitERC20Module.php new file mode 100644 index 0000000..aad22ee --- /dev/null +++ b/Modules/BounceBitERC20Module.php @@ -0,0 +1,20 @@ +blockchain = 'bouncebit'; + $this->module = 'bouncebit-erc-20'; + $this->is_main = false; + $this->first_block_date = '2024-04-08'; + $this->first_block_id = 1; + } +} diff --git a/Modules/BounceBitERC721Module.php b/Modules/BounceBitERC721Module.php new file mode 100644 index 0000000..1c0d466 --- /dev/null +++ b/Modules/BounceBitERC721Module.php @@ -0,0 +1,20 @@ +blockchain = 'bouncebit'; + $this->module = 'bouncebit-erc-721'; + $this->is_main = false; + $this->first_block_date = '2024-04-08'; + $this->first_block_id = 1; + } +} \ No newline at end of file diff --git a/Modules/BounceBitMainModule.php b/Modules/BounceBitMainModule.php new file mode 100644 index 0000000..d40e320 --- /dev/null +++ b/Modules/BounceBitMainModule.php @@ -0,0 +1,33 @@ +blockchain = 'bouncebit'; + $this->module = 'bouncebit-main'; + $this->is_main = true; + $this->first_block_date = '2024-04-08'; + $this->first_block_id = 1; + $this->currency = 'bouncebit'; + $this->currency_details = ['name' => 'BounceBit', 'symbol' => 'BB', 'decimals' => 18, 'description' => null]; + + // EVMMainModule + $this->evm_implementation = EVMImplementation::geth; + $this->extra_features = [EVMSpecialFeatures::FeesToTreasury]; + $this->reward_function = function($block_id) + { + return '0'; + }; + + // Handles + $this->handles_implemented = false; + } +} diff --git a/Modules/BounceBitTraceModule.php b/Modules/BounceBitTraceModule.php new file mode 100644 index 0000000..2681616 --- /dev/null +++ b/Modules/BounceBitTraceModule.php @@ -0,0 +1,24 @@ +blockchain = 'bouncebit'; + $this->module = 'bouncebit-trace'; + $this->complements = 'bouncebit-main'; + $this->is_main = false; + $this->first_block_date = '2024-04-08'; + $this->first_block_id = 1; + + // EVMTraceModule + $this->evm_implementation = EVMImplementation::geth; + } +} diff --git a/Modules/Common/EVMMainModule.php b/Modules/Common/EVMMainModule.php index ed9bc62..f95798a 100644 --- a/Modules/Common/EVMMainModule.php +++ b/Modules/Common/EVMMainModule.php @@ -238,6 +238,9 @@ final public function pre_process_block($block_id) // Data processing + if (in_array(EVMSpecialFeatures::FeesToTreasury, $this->extra_features)) + $miner = 'treasury'; + $this->block_time = date('Y-m-d H:i:s', to_int64_from_0xhex($block_time)); if (($ic = count($general_data)) !== count($receipt_data)) diff --git a/Modules/Common/EVMTraits.php b/Modules/Common/EVMTraits.php index 880732a..8dbde81 100644 --- a/Modules/Common/EVMTraits.php +++ b/Modules/Common/EVMTraits.php @@ -38,6 +38,7 @@ enum EVMSpecialFeatures case rskEVM; // Rootstock has different traces and deferred validators rewards (in N+4000 block). case TraceBlockSupport; // Support for `trace_block` in RPC API case EIP4844; // Support of blob transaction + case FeesToTreasury; // when the fee is not directly added to the block author balance } trait EVMTraits From 32776e283f093390fbc11bb10829688df5eba100 Mon Sep 17 00:00:00 2001 From: alexqrid <> Date: Tue, 16 Jul 2024 19:33:58 +0300 Subject: [PATCH 2/4] added draft BounceBit module --- Modules/BounceBitERC1155Module.php | 2 +- Modules/BounceBitERC20Module.php | 2 +- Modules/BounceBitERC721Module.php | 2 +- Modules/BounceBitMainModule.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/BounceBitERC1155Module.php b/Modules/BounceBitERC1155Module.php index 61021ad..0e889b3 100644 --- a/Modules/BounceBitERC1155Module.php +++ b/Modules/BounceBitERC1155Module.php @@ -6,7 +6,7 @@ /* This module processes ERC-1155 token transfers in BounceBit. */ -final class BounceBitERC1155Module extends EVMERC1155Module implements Module +final class BounceBitERC1155Module extends EVMERC1155Module implements Module, MultipleBalanceSpecial { function initialize() { diff --git a/Modules/BounceBitERC20Module.php b/Modules/BounceBitERC20Module.php index aad22ee..b367960 100644 --- a/Modules/BounceBitERC20Module.php +++ b/Modules/BounceBitERC20Module.php @@ -6,7 +6,7 @@ /* This module processes ERC-20 token transfers in BounceBit. */ -final class BounceBitERC20Module extends EVMERC20Module implements Module +final class BounceBitERC20Module extends EVMERC20Module implements Module, MultipleBalanceSpecial, SupplySpecial { function initialize() { diff --git a/Modules/BounceBitERC721Module.php b/Modules/BounceBitERC721Module.php index 1c0d466..91ad962 100644 --- a/Modules/BounceBitERC721Module.php +++ b/Modules/BounceBitERC721Module.php @@ -6,7 +6,7 @@ /* This module processes ERC-721 NFT transfers in BounceBit. */ -final class BounceBitERC721Module extends EVMERC721Module implements Module +final class BounceBitERC721Module extends EVMERC721Module implements Module, MultipleBalanceSpecial { function initialize() { diff --git a/Modules/BounceBitMainModule.php b/Modules/BounceBitMainModule.php index d40e320..6f9cdad 100644 --- a/Modules/BounceBitMainModule.php +++ b/Modules/BounceBitMainModule.php @@ -6,7 +6,7 @@ /* This is the main BounceBit module. */ -final class BounceBitMainModule extends EVMMainModule implements Module +final class BounceBitMainModule extends EVMMainModule implements Module, BalanceSpecial, TransactionSpecials, AddressSpecials { function initialize() { From a57793833d506cfdd15c433838f556dcba9e2e80 Mon Sep 17 00:00:00 2001 From: alexqrid <> Date: Tue, 16 Jul 2024 23:26:24 +0300 Subject: [PATCH 3/4] added tests for bounce-bit --- Modules/BounceBitERC20Module.php | 4 ++++ Modules/BounceBitMainModule.php | 5 +++++ Modules/BounceBitTraceModule.php | 3 +++ 3 files changed, 12 insertions(+) diff --git a/Modules/BounceBitERC20Module.php b/Modules/BounceBitERC20Module.php index b367960..46f4922 100644 --- a/Modules/BounceBitERC20Module.php +++ b/Modules/BounceBitERC20Module.php @@ -16,5 +16,9 @@ function initialize() $this->is_main = false; $this->first_block_date = '2024-04-08'; $this->first_block_id = 1; + $this->tests = [ + ['block' => 150387, 'result' => 'a:2:{s:6:"events";a:2:{i:0;a:8:{s:11:"transaction";N;s:7:"address";s:4:"0x00";s:6:"effect";s:2:"-0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372;s:4:"time";s:19:"2024-04-10 19:24:23";s:8:"sort_key";i:0;}i:1;a:8:{s:11:"transaction";N;s:7:"address";s:8:"treasury";s:6:"effect";s:1:"0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372;s:4:"time";s:19:"2024-04-10 19:24:23";s:8:"sort_key";i:1;}}s:10:"currencies";N;}'], + ['block' => 2369594, 'result' => 'a:2:{s:6:"events";a:4:{i:0;a:7:{s:11:"transaction";s:66:"0x5bec430459b9f2ad54f60dd691aa6f562aa7483e6ea4759cd5829282e953b296";s:8:"currency";s:42:"0x7f150c293c97172c75983bd8ac084c187107ea19";s:7:"address";s:42:"0x0000000000000000000000000000000000000000";s:8:"sort_key";i:0;s:6:"effect";s:16:"-100000000000000";s:5:"block";i:2369594;s:4:"time";s:19:"2024-07-16 14:24:57";}i:1;a:7:{s:11:"transaction";s:66:"0x5bec430459b9f2ad54f60dd691aa6f562aa7483e6ea4759cd5829282e953b296";s:8:"currency";s:42:"0x7f150c293c97172c75983bd8ac084c187107ea19";s:7:"address";s:42:"0x8fbad0655df10e92cca0ecc48a902b170ac7b2b0";s:8:"sort_key";i:1;s:6:"effect";s:15:"100000000000000";s:5:"block";i:2369594;s:4:"time";s:19:"2024-07-16 14:24:57";}i:2;a:7:{s:11:"transaction";s:66:"0x5bec430459b9f2ad54f60dd691aa6f562aa7483e6ea4759cd5829282e953b296";s:8:"currency";s:42:"0xf5e11df1ebcf78b6b6d26e04ff19cd786a1e81dc";s:7:"address";s:42:"0x8fbad0655df10e92cca0ecc48a902b170ac7b2b0";s:8:"sort_key";i:2;s:6:"effect";s:16:"-100000000000000";s:5:"block";i:2369594;s:4:"time";s:19:"2024-07-16 14:24:57";}i:3;a:7:{s:11:"transaction";s:66:"0x5bec430459b9f2ad54f60dd691aa6f562aa7483e6ea4759cd5829282e953b296";s:8:"currency";s:42:"0xf5e11df1ebcf78b6b6d26e04ff19cd786a1e81dc";s:7:"address";s:42:"0x7f150c293c97172c75983bd8ac084c187107ea19";s:8:"sort_key";i:3;s:6:"effect";s:15:"100000000000000";s:5:"block";i:2369594;s:4:"time";s:19:"2024-07-16 14:24:57";}}s:10:"currencies";a:2:{i:0;a:4:{s:2:"id";s:42:"0x7f150c293c97172c75983bd8ac084c187107ea19";s:4:"name";s:18:"Liquid staked BBTC";s:6:"symbol";s:6:"stBBTC";s:8:"decimals";i:18;}i:1;a:4:{s:2:"id";s:42:"0xf5e11df1ebcf78b6b6d26e04ff19cd786a1e81dc";s:4:"name";s:13:"BounceBit BTC";s:6:"symbol";s:4:"BBTC";s:8:"decimals";i:18;}}}'], + ]; } } diff --git a/Modules/BounceBitMainModule.php b/Modules/BounceBitMainModule.php index 6f9cdad..742c928 100644 --- a/Modules/BounceBitMainModule.php +++ b/Modules/BounceBitMainModule.php @@ -29,5 +29,10 @@ function initialize() // Handles $this->handles_implemented = false; + $this->tests = [ + ['block' => 1, 'result' => 'a:2:{s:6:"events";a:2:{i:0;a:8:{s:11:"transaction";N;s:7:"address";s:4:"0x00";s:6:"effect";s:2:"-0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:1;s:4:"time";s:19:"2024-04-08 06:43:00";s:8:"sort_key";i:0;}i:1;a:8:{s:11:"transaction";N;s:7:"address";s:8:"treasury";s:6:"effect";s:1:"0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:1;s:4:"time";s:19:"2024-04-08 06:43:00";s:8:"sort_key";i:1;}}s:10:"currencies";N;}'], + ['block' => 2372, 'result' => 'a:2:{s:6:"events";a:2:{i:0;a:8:{s:11:"transaction";N;s:7:"address";s:4:"0x00";s:6:"effect";s:2:"-0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372;s:4:"time";s:19:"2024-04-10 19:24:23";s:8:"sort_key";i:0;}i:1;a:8:{s:11:"transaction";N;s:7:"address";s:8:"treasury";s:6:"effect";s:1:"0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372;s:4:"time";s:19:"2024-04-10 19:24:23";s:8:"sort_key";i:1;}}s:10:"currencies";N;}'], + ['block' => 2372111, 'result' => 'a:2:{s:6:"events";a:8:{i:0;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:42:"0x503c2a26bf64294d7955c929127a29847f7db57a";s:6:"effect";s:16:"-246680000000000";s:6:"failed";s:1:"f";s:5:"extra";s:1:"b";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:0;}i:1;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:4:"0x00";s:6:"effect";s:15:"246680000000000";s:6:"failed";s:1:"f";s:5:"extra";s:1:"b";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:1;}i:2;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:42:"0x503c2a26bf64294d7955c929127a29847f7db57a";s:6:"effect";s:15:"-30835000000000";s:6:"failed";s:1:"f";s:5:"extra";s:1:"f";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:2;}i:3;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:8:"treasury";s:6:"effect";s:14:"30835000000000";s:6:"failed";s:1:"f";s:5:"extra";s:1:"f";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:3;}i:4;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:42:"0x503c2a26bf64294d7955c929127a29847f7db57a";s:6:"effect";s:2:"-0";s:6:"failed";s:1:"f";s:5:"extra";N;s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:4;}i:5;a:8:{s:11:"transaction";s:66:"0x5c9d15c0918dfd621b4e0e54a70d84c4d1ecacf36cde6190353defe861c24dde";s:7:"address";s:42:"0xc226ff4526afee15d32665f3ef3b291ac1e0c731";s:6:"effect";s:1:"0";s:6:"failed";s:1:"f";s:5:"extra";N;s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:5;}i:6;a:8:{s:11:"transaction";N;s:7:"address";s:4:"0x00";s:6:"effect";s:2:"-0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:6;}i:7;a:8:{s:11:"transaction";N;s:7:"address";s:8:"treasury";s:6:"effect";s:1:"0";s:6:"failed";s:1:"f";s:5:"extra";s:1:"r";s:5:"block";i:2372111;s:4:"time";s:19:"2024-07-16 16:56:29";s:8:"sort_key";i:7;}}s:10:"currencies";N;}'], + ]; } } diff --git a/Modules/BounceBitTraceModule.php b/Modules/BounceBitTraceModule.php index 2681616..8e26d25 100644 --- a/Modules/BounceBitTraceModule.php +++ b/Modules/BounceBitTraceModule.php @@ -20,5 +20,8 @@ function initialize() // EVMTraceModule $this->evm_implementation = EVMImplementation::geth; + $this->tests = [ + ['block' =>2374738, 'result' => 'a:2:{s:6:"events";a:2:{i:0;a:7:{s:11:"transaction";s:66:"0x4254a319a69c866eb701c01086ae23355eaa6a0c2510516f2c6bf46f98e205c9";s:7:"address";s:42:"0x3be72fcc9eaba1283744909b7b8260a4bc8ec956";s:8:"sort_key";i:0;s:6:"effect";s:21:"-83893757661856936691";s:5:"extra";N;s:5:"block";i:2374738;s:4:"time";s:19:"2024-07-16 19:32:06";}i:1;a:7:{s:11:"transaction";s:66:"0x4254a319a69c866eb701c01086ae23355eaa6a0c2510516f2c6bf46f98e205c9";s:7:"address";s:42:"0xd2f2e0cb8aa04235c868acbc9ac9782af0d21595";s:8:"sort_key";i:1;s:6:"effect";s:20:"83893757661856936691";s:5:"extra";N;s:5:"block";i:2374738;s:4:"time";s:19:"2024-07-16 19:32:06";}}s:10:"currencies";N;}'], + ]; } } From 2efc5da345e0f87aea3c4f1af019c62972e3a696 Mon Sep 17 00:00:00 2001 From: alexqrid <> Date: Tue, 16 Jul 2024 23:34:00 +0300 Subject: [PATCH 4/4] fixed trace module description --- Modules/BounceBitTraceModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/BounceBitTraceModule.php b/Modules/BounceBitTraceModule.php index 8e26d25..320b080 100644 --- a/Modules/BounceBitTraceModule.php +++ b/Modules/BounceBitTraceModule.php @@ -4,7 +4,7 @@ * Copyright (c) 2023 3xpl developers, 3@3xpl.com, see CONTRIBUTORS.md * Distributed under the MIT software license, see LICENSE.md */ -/* This module processes internal Ethereum transactions (using block tracing). It requires an archival Erigon node to run. */ +/* This module processes internal BounceBit transactions (using block tracing). It requires an archival node to run. */ final class BounceBitTraceModule extends EVMTraceModule implements Module {