@@ -21,6 +21,7 @@ import (
2121
2222 cliErrs "github.com/coinbase/rosetta-cli/pkg/errors"
2323 "github.com/coinbase/rosetta-cli/pkg/logger"
24+ "github.com/fatih/color"
2425
2526 "github.com/coinbase/rosetta-cli/pkg/results"
2627 "github.com/coinbase/rosetta-cli/pkg/tester"
@@ -54,6 +55,7 @@ and UTXO-based blockchains). However, we plan to add support for testing
5455arbitrary scenarios (for example, staking and governance).` ,
5556 RunE : runCheckConstructionCmd ,
5657 }
58+ constructionMetadata string
5759)
5860
5961func runCheckConstructionCmd (_ * cobra.Command , _ []string ) error {
@@ -66,6 +68,10 @@ func runCheckConstructionCmd(_ *cobra.Command, _ []string) error {
6668 )
6769 }
6870
71+ metadataMap := logger .ConvertStringToMap (Config .InfoMetaData )
72+ metadataMap = logger .AddRequestUUIDToMap (metadataMap , Config .RequestUUID )
73+ constructionMetadata = logger .ConvertMapToString (metadataMap )
74+
6975 ensureDataDirectoryExists ()
7076 ctx , cancel := context .WithCancel (Context )
7177
@@ -74,6 +80,7 @@ func runCheckConstructionCmd(_ *cobra.Command, _ []string) error {
7480 fetcher .WithRetryElapsedTime (time .Duration (Config .RetryElapsedTime ) * time .Second ),
7581 fetcher .WithTimeout (time .Duration (Config .HTTPTimeout ) * time .Second ),
7682 fetcher .WithMaxRetries (Config .MaxRetries ),
83+ fetcher .WithMetaData (metadata ),
7784 }
7885 if Config .ForceRetry {
7986 fetcherOpts = append (fetcherOpts , fetcher .WithForceRetry ())
@@ -87,22 +94,26 @@ func runCheckConstructionCmd(_ *cobra.Command, _ []string) error {
8794 _ , _ , fetchErr := fetcher .InitializeAsserter (ctx , Config .Network , Config .ValidationFile )
8895 if fetchErr != nil {
8996 cancel ()
97+ err := fmt .Errorf ("unable to initialize asserter for fetcher: %w%s" , fetchErr .Err , constructionMetadata )
98+ color .Red (err .Error ())
9099 return results .ExitConstruction (
91100 Config ,
92101 nil ,
93102 nil ,
94- fmt . Errorf ( "unable to initialize asserter for fetcher: %w" , fetchErr . Err ) ,
103+ err ,
95104 )
96105 }
97106
98107 _ , err := utils .CheckNetworkSupported (ctx , Config .Network , fetcher )
99108 if err != nil {
100109 cancel ()
110+ err = fmt .Errorf ("unable to confirm network %s is supported: %w%s" , types .PrintStruct (Config .Network ), err , constructionMetadata )
111+ color .Red (err .Error ())
101112 return results .ExitConstruction (
102113 Config ,
103114 nil ,
104115 nil ,
105- fmt . Errorf ( "unable to confirm network %s is supported: %w" , types . PrintStruct ( Config . Network ), err ) ,
116+ err ,
106117 )
107118 }
108119
@@ -111,11 +122,13 @@ func runCheckConstructionCmd(_ *cobra.Command, _ []string) error {
111122 ctx , fetcher , Config .Network , asserterConfigurationFile ,
112123 ); err != nil {
113124 cancel ()
125+ err = fmt .Errorf ("network options don't match asserter configuration file %s: %w%s" , asserterConfigurationFile , err , constructionMetadata )
126+ color .Red (err .Error ())
114127 return results .ExitConstruction (
115128 Config ,
116129 nil ,
117130 nil ,
118- fmt . Errorf ( "network options don't match asserter configuration file %s: %w" , asserterConfigurationFile , err ) ,
131+ err ,
119132 )
120133 }
121134 }
@@ -129,27 +142,30 @@ func runCheckConstructionCmd(_ *cobra.Command, _ []string) error {
129142 & SignalReceived ,
130143 )
131144 if err != nil {
145+ err = fmt .Errorf ("unable to initialize construction tester: %w%s" , err , constructionMetadata )
146+ color .Red (err .Error ())
132147 return results .ExitConstruction (
133148 Config ,
134149 nil ,
135150 nil ,
136- fmt . Errorf ( "unable to initialize construction tester: %w" , err ) ,
151+ err ,
137152 )
138153 }
139154 defer constructionTester .CloseDatabase (ctx )
140155
141156 if err := constructionTester .PerformBroadcasts (ctx ); err != nil {
157+ err = fmt .Errorf ("unable to perform broadcasts: %w%s" , err , constructionMetadata )
158+ color .Red (err .Error ())
142159 return results .ExitConstruction (
143160 Config ,
144161 nil ,
145162 nil ,
146- fmt . Errorf ( "unable to perform broadcasts: %w" , err ) ,
163+ err ,
147164 )
148165 }
149166
150167 g , ctx := errgroup .WithContext (ctx )
151- ctx = logger .AddRequestUUIDToContext (ctx , Config .RequestUUID )
152- ctx = logger .AddInfoMetaDataToContext (ctx , Config .InfoMetaData )
168+ ctx = logger .AddMetadataMapToContext (ctx , metadataMap )
153169
154170 g .Go (func () error {
155171 return constructionTester .StartPeriodicLogger (ctx )
0 commit comments