forked from NethermindEth/starknet.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_trace.go
132 lines (104 loc) · 4.66 KB
/
types_trace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package rpc
import "github.com/NethermindEth/juno/core/felt"
type SimulateTransactionInput struct {
//a sequence of transactions to simulate, running each transaction on the state resulting from applying all the previous ones
Txns []Transaction `json:"transactions"`
BlockID BlockID `json:"block_id"`
SimulationFlags []SimulationFlag `json:"simulation_flags"`
}
type SimulationFlag string
const (
SKIP_FEE_CHARGE SimulationFlag = "SKIP_FEE_CHARGE"
SKIP_EXECUTE SimulationFlag = "SKIP_EXECUTE"
// Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally
SKIP_VALIDATE SimulationFlag = "SKIP_VALIDATE"
)
// The execution trace and consumed resources of the required transactions
type SimulateTransactionOutput struct {
Txns []SimulatedTransaction `json:"result"`
}
type SimulatedTransaction struct {
TxnTrace `json:"transaction_trace"`
FeeEstimate
}
type TxnTrace interface{}
var _ TxnTrace = InvokeTxnTrace{}
var _ TxnTrace = DeclareTxnTrace{}
var _ TxnTrace = DeployAccountTxnTrace{}
var _ TxnTrace = L1HandlerTxnTrace{}
// the execution trace of an invoke transaction
type InvokeTxnTrace struct {
ValidateInvocation FnInvocation `json:"validate_invocation"`
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
ExecuteInvocation ExecInvocation `json:"execute_invocation"`
FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"`
StateDiff StateDiff `json:"state_diff"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
// the execution trace of a declare transaction
type DeclareTxnTrace struct {
ValidateInvocation FnInvocation `json:"validate_invocation"`
FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"`
StateDiff StateDiff `json:"state_diff"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
// the execution trace of a deploy account transaction
type DeployAccountTxnTrace struct {
ValidateInvocation FnInvocation `json:"validate_invocation"`
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
ConstructorInvocation FnInvocation `json:"constructor_invocation"`
FeeTransferInvocation FnInvocation `json:"fee_transfer_invocation"`
StateDiff StateDiff `json:"state_diff"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
// the execution trace of an L1 handler transaction
type L1HandlerTxnTrace struct {
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
FunctionInvocation FnInvocation `json:"function_invocation"`
StateDiff StateDiff `json:"state_diff"`
Type TransactionType `json:"type"`
}
type EntryPointType string
const (
External EntryPointType = "EXTERNAL"
L1Handler EntryPointType = "L1_HANDLER"
Constructor EntryPointType = "CONSTRUCTOR"
)
type CallType string
const (
CallTypeLibraryCall CallType = "LIBRARY_CALL"
CallTypeCall CallType = "CALL"
CallTypeDelegate CallType = "DELEGATE"
)
type FnInvocation struct {
FunctionCall
//The address of the invoking contract. 0 for the root invocation
CallerAddress *felt.Felt `json:"caller_address"`
// The hash of the class being called
ClassHash *felt.Felt `json:"class_hash"`
EntryPointType EntryPointType `json:"entry_point_type"`
CallType CallType `json:"call_type"`
//The value returned from the function invocation
Result []*felt.Felt `json:"result"`
// The calls made by this invocation
NestedCalls []FnInvocation `json:"calls"`
// The events emitted in this invocation
InvocationEvents []OrderedEvent `json:"events"`
// The messages sent by this invocation to L1
L1Messages []OrderedMsg `json:"messages"`
// Resources consumed by the internal call
// https://github.com/starkware-libs/starknet-specs/blob/v0.7.0-rc0/api/starknet_trace_api_openrpc.json#L374C1-L374C29
ComputationResources ComputationResources `json:"execution_resources"`
}
// A single pair of transaction hash and corresponding trace
type Trace struct {
TraceRoot TxnTrace `json:"trace_root,omitempty"`
TxnHash *felt.Felt `json:"transaction_hash,omitempty"`
}
type ExecInvocation struct {
FunctionInvocation FnInvocation `json:"function_invocation,omitempty"`
RevertReason string `json:"revert_reason,omitempty"`
}