@@ -23,6 +23,7 @@ import (
2323 "fmt"
2424 "github.com/dapperlabs/flow-playground-api/model"
2525 "github.com/dapperlabs/flow-playground-api/storage"
26+ playground "github.com/dapperlabs/flow-playground-api/telemetry"
2627
2728 "github.com/getsentry/sentry-go"
2829 "github.com/google/uuid"
@@ -57,22 +58,27 @@ type Projects struct {
5758// Reset the blockchain state.
5859func (p * Projects ) Reset (project * model.InternalProject ) ([]* model.InternalAccount , error ) {
5960 p .cache .reset (project .ID )
61+ playground .Logger ().Info ("[projects] reset - start" )
6062
6163 err := p .store .ResetProjectState (project )
6264 if err != nil {
6365 return nil , err
6466 }
6567
68+ playground .Logger ().Info ("[projects] reset - project state reset" )
6669 accounts , err := p .CreateInitialAccounts (project .ID )
6770 if err != nil {
6871 return nil , err
6972 }
7073
74+ playground .Logger ().Info ("[projects] reset - accounts created" )
7175 return accounts , nil
7276}
7377
7478// ExecuteTransaction executes a transaction from the new transaction execution model and persists the execution.
7579func (p * Projects ) ExecuteTransaction (execution model.NewTransactionExecution ) (* model.TransactionExecution , error ) {
80+ playground .Logger ().Info ("[projects] execute transaction - start" )
81+
7682 projID := execution .ProjectID
7783 p .mutex .load (projID ).Lock ()
7884 defer p .mutex .remove (projID ).Unlock ()
@@ -81,6 +87,8 @@ func (p *Projects) ExecuteTransaction(execution model.NewTransactionExecution) (
8187 return nil , err
8288 }
8389
90+ playground .Logger ().Info ("[projects] execute transaction - emulator loaded" )
91+
8492 signers := make ([]flowsdk.Address , len (execution .Signers ))
8593 for i , sig := range execution .Signers {
8694 signers [i ] = sig .ToFlowAddress ()
@@ -95,12 +103,16 @@ func (p *Projects) ExecuteTransaction(execution model.NewTransactionExecution) (
95103 return nil , err
96104 }
97105
106+ playground .Logger ().Info ("[projects] execute transaction - emulator executed" )
107+
98108 exe := model .TransactionExecutionFromFlow (execution .ProjectID , result , tx )
99109 err = p .store .InsertTransactionExecution (exe )
100110 if err != nil {
101111 return nil , err
102112 }
103113
114+ playground .Logger ().Info ("[projects] execute transaction - execution inserted" )
115+
104116 return exe , nil
105117}
106118
@@ -188,13 +200,17 @@ func (p *Projects) DeployContract(
188200 address model.Address ,
189201 script string ,
190202) (* model.Account , error ) {
203+ playground .Logger ().Info ("[projects] deploy contract - start" )
204+
191205 p .mutex .load (projectID ).Lock ()
192206 defer p .mutex .remove (projectID ).Unlock ()
193207 emulator , err := p .load (projectID )
194208 if err != nil {
195209 return nil , err
196210 }
197211
212+ playground .Logger ().Info ("[projects] deploy contract - emulator loaded" )
213+
198214 result , tx , err := emulator .deployContract (address .ToFlowAddress (), script )
199215 if err != nil {
200216 return nil , err
@@ -203,12 +219,16 @@ func (p *Projects) DeployContract(
203219 return nil , result .Error
204220 }
205221
222+ playground .Logger ().Info ("[projects] deploy contract - contract deployed" )
223+
206224 exe := model .TransactionExecutionFromFlow (projectID , result , tx )
207225 err = p .store .InsertTransactionExecution (exe )
208226 if err != nil {
209227 return nil , err
210228 }
211229
230+ playground .Logger ().Info ("[projects] deploy contract - execution inserted" )
231+
212232 return p .getAccount (projectID , address )
213233}
214234
@@ -218,11 +238,15 @@ func (p *Projects) getAccount(projectID uuid.UUID, address model.Address) (*mode
218238 return nil , err
219239 }
220240
241+ playground .Logger ().Info ("[projects] get account - emulator loaded" )
242+
221243 flowAccount , store , err := emulator .getAccount (address .ToFlowAddress ())
222244 if err != nil {
223245 return nil , err
224246 }
225247
248+ playground .Logger ().Info ("[projects] get account - account retrieved from emualator" )
249+
226250 jsonStorage , err := json .Marshal (store )
227251 if err != nil {
228252 return nil , errors .Wrap (err , "error marshaling account storage" )
@@ -239,12 +263,17 @@ func (p *Projects) getAccount(projectID uuid.UUID, address model.Address) (*mode
239263//
240264// Do not call this method directly, it is not concurrency safe.
241265func (p * Projects ) load (projectID uuid.UUID ) (blockchain , error ) {
266+
267+ playground .Logger ().Info ("[projects] load - start" )
268+
242269 var executions []* model.TransactionExecution
243270 err := p .store .GetTransactionExecutionsForProject (projectID , & executions )
244271 if err != nil {
245272 return nil , err
246273 }
247274
275+ playground .Logger ().Info ("[projects] load - retrieve executions" )
276+
248277 emulator , executions , err := p .cache .get (projectID , executions )
249278 if emulator == nil || err != nil {
250279 emulator , err = newEmulator ()
@@ -253,6 +282,8 @@ func (p *Projects) load(projectID uuid.UUID) (blockchain, error) {
253282 }
254283 }
255284
285+ playground .Logger ().Info ("[projects] load - resolve cache" )
286+
256287 for _ , execution := range executions {
257288 result , _ , err := emulator .executeTransaction (
258289 execution .Script ,
@@ -282,6 +313,8 @@ func (p *Projects) load(projectID uuid.UUID) (blockchain, error) {
282313 }
283314 }
284315
316+ playground .Logger ().Info ("[projects] load - executions completed" )
317+
285318 p .cache .add (projectID , emulator )
286319
287320 return emulator , nil
0 commit comments