Skip to content

Commit

Permalink
1450 refactor debug module (#1490)
Browse files Browse the repository at this point in the history
* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 http client refactoring

* feat: 1450 ThorClient refactoring

* feat: 1450 ThorClient refactoring

* feat: 1450 ThorClient refactoring

* fix: release candidate 1.0.0-r

* fix: release candidate 1.0.0-r

* feat: 1450 account module refactoring

* feat: 1450 account module refactoring

* feat: 1450 account module refactoring

* feat: 1450 account module refactoring

* feat: 1450 account module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 accounts module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refatoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* feat: 1450 debug module refactoring

* fix: 1450 cyclic dependencies in thor-client.md

---------

Co-authored-by: Fabio Rigamonti <[email protected]>
  • Loading branch information
lucanicoladebiasi and fabiorigam authored Nov 12, 2024
1 parent 59e2dc2 commit b370f7a
Show file tree
Hide file tree
Showing 46 changed files with 1,910 additions and 870 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:

- name: Lint
run: yarn lint
- name: Circular dependencies check
run: yarn check:circular-dependencies

# - name: Circular dependencies check
# run: yarn check:circular-dependencies

- name: Build
run: yarn build
run: yarn build
34 changes: 20 additions & 14 deletions docs/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ const thorClient = ThorClient.at(TESTNET_URL);
// 2 - Retrieve the storage range.
const result = await thorClient.debug.retrieveStorageRange({
target: {
blockID:
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f',
blockId: BlockId.of(
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f'
),
transaction: 0,
clauseIndex: 0
},
options: {
address: '0x0000000000000000000000000000456E65726779',
keyStart:
'0x0000000000000000000000000000000000000000000000000000000000000000',
address: Address.of('0x0000000000000000000000000000456E65726779'),
keyStart: BlockId.of(
'0x0000000000000000000000000000000000000000000000000000000000000000'
),
maxResult: 10
}
});
Expand Down Expand Up @@ -111,12 +113,14 @@ const thorClient = ThorClient.at(TESTNET_URL);
// 2 - Trace the contract call.
const result = await thorClient.debug.traceContractCall(
{
contractInput: {
to: '0x0000000000000000000000000000456E65726779',
data: '0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000',
value: '0x0'
target: {
to: Address.of('0x0000000000000000000000000000456E65726779'),
data: HexUInt.of(
'0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000'
),
value: VET.of(0)
},
transactionOptions: {
options: {
caller: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
gasPayer: '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF',
expiration: 18,
Expand Down Expand Up @@ -170,10 +174,12 @@ const thorClient = ThorClient.at(TESTNET_URL);
const result = await thorClient.debug.traceTransactionClause(
{
target: {
blockID:
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f',
transaction:
'0x05b31824569f2f2ec64c62c4e6396199f56ae872ff219288eb3293b4a36e7b0f',
blockId: BlockId.of(
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f'
),
transaction: BlockId.of(
'0x05b31824569f2f2ec64c62c4e6396199f56ae872ff219288eb3293b4a36e7b0f'
),
clauseIndex: 0
},
config: {}
Expand Down
33 changes: 33 additions & 0 deletions docs/diagrams/architecture/accounts-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
```mermaid
classDiagram
class AccountData {
<<interface>>
string balance
string energy
boolean hasCode
}
class AccountDetails {
VET vet
VTHO vtho
AccountDetails constructor(AccountData accountData)
}
class AccountInputOptions {
<<interface>>
Revision revision
}
class AccountsModule {
AccountModule constructor(HttpClient httpClient)
Promise~AccountDetail~ getAccount(Address address, AccountInputOptions options)
Promise~HexUInt~ getBytecode(Address adderess, AccountInputOptions options)
Promise~HexUInt~ getStorageAt(Address address, BlockId blockId, AccountInputOptions options)
}
namespace http {
class HttpClient {
<<interface>>
}
}
AccountData <|-- AccountDetails
AccountDetails <|.. AccountsModule
AccountInputOptions o-- AccountsModule
HttpClient *-- AccountsModule
```
93 changes: 93 additions & 0 deletions docs/diagrams/architecture/debug-module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
```mermaid
classDiagram
class ContractTraceTarget {
<<interface>>
Address|null to
Hex data
VET value
}
class ContractTraceOptions {
<<type>>
}
class DebugModule {
DebugModule constructor(HttpClient httpClient)
Promise~RetrieveStorageRange~ retrieveStorageRange(RetrieveStorageRangeInput input)
Promise~TraceReturnType~T~~ traceContractCall(TraceContractCallInput input, TracerName name)
Promise~TraceReturnType~T~~ traceTransactionClause(TraceTransactionClauseInput input, TracerName name)
}
namespace http {
class HttpClient {
<<interface>>
}
}
class RetrieveStorageRange {
string|null nestKey
Record~string, Record~ key, value~storage~~
}
class RetrieveStorageRangeInput {
<<interface>>
TransactionTraceTarget target
RetrieveStorageRangeOptions options
}
class RetrieveStorageRangeOptions {
<<interface>>
Address address
BlockId blockId
number maxResult
}
class TraceContractCallInput {
<<interface>>
ContractTraceTarget target
ContractTraceOptions options
TracerConfig config
}
class TraceTransactionClauseInput {
<<interface>>
TransactionTraceTarget target
TracerConfig config
}
class TraceReturnType~TracerName|undefined~
namespace transactions-module {
class SimulateTransactionOptions {
<<interface>>
}
}
class TracerConfig~TracerName|undefined~ {
<<type>>
}
class TracerName {
<<enumeration>>
4byte
call
empty
evmdis
noop
null
opcount
prestate
trigram
unigram
}
class TransactionTraceTarget {
<<interface>>
BlockId blockId
number clauseIndex
BlockId|number transaction
}
ContractTraceTarget *-- TraceContractCallInput
ContractTraceOptions *-- TraceContractCallInput
HttpClient o-- DebugModule
RetrieveStorageRange <|.. DebugModule
RetrieveStorageRangeInput *-- DebugModule
RetrieveStorageRangeOptions *-- RetrieveStorageRangeInput
string <|-- TracerName
SimulateTransactionOptions <|.. ContractTraceOptions
TraceContractCallInput *-- DebugModule
TraceTransactionClauseInput *-- DebugModule
TransactionTraceTarget *-- RetrieveStorageRangeInput
TracerConfig *-- TraceContractCallInput
TracerConfig *-- TraceTransactionClauseInput
TracerName <|.. TracerConfig
TracerName <|.. TraceReturnType
TraceReturnType <|.. DebugModule
```
1 change: 0 additions & 1 deletion docs/diagrams/architecture/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ classDiagram
Promise~unknown~ get(string path, HttpParams path)
Promise~unknown~ http(HttpMethod method, string path, HttpParams path)
Promise~unknown~ post(string path, HttpParams path)
}
class HttpMethod {
<<enum>>
Expand Down
61 changes: 42 additions & 19 deletions docs/diagrams/architecture/network.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
```mermaid
classDiagram
class AccountData {
<<interface>>
string balance
string energy
boolean hasCode
}
class AccountDetail {
<<interface>>
VET vet
VTHO vtho
}
class AccountInputOptions {
<<interface>>
Revision revision
}
class AccountsModule {
HttpClient httpClient
AccountsModule constructor(HttpClient httpClient)
Promise~AccountDetail~ getAccount(Address address, AccountInputOption options)
Promise~HexUInt~ getByteCode(Address address, AccountInputOption options)
Promise~HexUInt~ getStorageAt(Address address, ThorId position, AccountInputOptions options)
}
class BlocksModule {
HttpClient httpClient
BlocksModule constructor(HttpClient httpClient)
}
class ContractsModule {
}
class DebugModule {
HttpClient httpClient
DebugModule constructor(HttpClient httpClient)
Promise ~RetrieveStorageRange~ retrieveStorageRange(input: RetrieveStorageRangeInput)
Promise ~TraceReturnType~typeof name~~ traceContractCall(input: TraceContractCallInput, name: TracerName)
Promise~TraceReturnType~typeof name~~ traceTransactionClause(input: TraceTransactionClauseInput, name: TracerName)
}
class GasModule {
}
Expand All @@ -41,30 +32,62 @@ classDiagram
}
class NodesModule {
}
class RetrieveStorageRangeInput {
<<interface>>
TransactionTraceTarget target
RetrieveStorageRangeOptions options
}
class RetrieveStorageRange {
<<interface>>
string|null nextKey
Record~string, Record~string key, string value~~
}
class ThorClient {
AccountModule accounts;
ThorClient at(string url, BlockModuleOptions options)$
destroy()
}
class TraceContractCallInput {
<<interface>>
ContractTraceTarget target
ContractTraceOptions options
TracerConfig~typeof name~ config
}
class TraceTransactionClauseInput {
<<interface>>
TransactionTraceTarget target
TracerConfig~typeof name~ config
}
class TraceTransactionTarget {
<<interface>>
ThorId blockID
number|ThorId transaction
number clauseIndex
}
class TransactionsModule {
}
AccountData <|-- AccountDetail
AccountInputOptions o-- AccountsModule
AccountsModule *-- ThorClient
BlocksModule *-- GasModule
BlocksModule *-- ThorClient
BlocksModule *-- NodesModule
BlocksModule *-- ThorClient
BlocksModule *-- ThorClient
BlocksModule *-- TransactionsModule
ContractsModule *-- ThorClient
DebugModule *-- ThorClient
DebugModule *-- TransactionsModule
GasModule *-- ThorClient
HttpClient o-- AccountsModule
HttpClient o-- BlocksModule
HttpClient o-- DebugModule
HttpClient o-- ThorClient
LogsModule *-- ThorClient
NodesModule *-- ThorClient
TransactionsModule *-- GasModule
RetrieveStorageRangeInput o-- DebugModule
TraceContractCallInput o-- DebugModule
TraceTransactionClauseInput o-- DebugModule
TraceTransactionTarget *-- RetrieveStorageRangeInput
TraceTransactionTarget *-- TraceTransactionClauseInput
TransactionsModule *-- ContractsModule
TransactionsModule *-- GasModule
TransactionsModule *-- ThorClient
```
33 changes: 33 additions & 0 deletions docs/diagrams/architecture/thor-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
```mermaid
classDiagram
namespace accounts-module {
class AccountsModule {
Promise~AccountDetail~ getAccount(Address address, AccountInputOptions options)
Promise~HexUInt~ getBytecode(Address adderess, AccountInputOptions options)
Promise~HexUInt~ getStorageAt(Address address, BlockId blockId, AccountInputOptions options)
}
}
namespace debug-module {
class DebugModule {
Promise~RetrieveStorageRange~ retrieveStorageRange(RetrieveStorageRangeInput input)
Promise~TraceReturnType~T~~ traceContractCall(TraceContractCallInput input, TracerName name)
Promise~TraceReturnType~T~~ traceTransactionClause(TraceTransactionClauseInput input, TracerName name)
}
}
namespace http {
class HttpClient {
<<interface>>
}
}
class ThorClient {
AccountsModule accounts
DebugModule debug
HttpClient httpClient
}
AccountsModule *-- ThorClient
DebugModule *-- ThorClient
HttpClient o-- AccountsModule
HttpClient o-- DebugModule
HttpClient o-- ThorClient
```
Loading

1 comment on commit b370f7a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
98.99% (4343/4387) 97.53% (1387/1422) 99% (896/905)
Title Tests Skipped Failures Errors Time
core 827 0 πŸ’€ 0 ❌ 0 πŸ”₯ 2m 22s ⏱️
network 719 0 πŸ’€ 0 ❌ 0 πŸ”₯ 5m 0s ⏱️
errors 42 0 πŸ’€ 0 ❌ 0 πŸ”₯ 17.059s ⏱️
logging 3 0 πŸ’€ 0 ❌ 0 πŸ”₯ 18.44s ⏱️
hardhat-plugin 19 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 0s ⏱️
aws-kms-adapter 23 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 23s ⏱️
ethers-adapter 5 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 16s ⏱️
rpc-proxy 37 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 3s ⏱️

Please sign in to comment.