11package changeset
22
33import (
4+ "context"
45 "fmt"
56
67 "github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -12,6 +13,7 @@ import (
1213
1314 cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
1415 cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
16+ "github.com/smartcontractkit/chainlink-deployments-framework/pkg/logger"
1517
1618 "github.com/smartcontractkit/chainlink/deployment/data-feeds/changeset/types"
1719)
@@ -81,21 +83,87 @@ func DeployAggregatorProxy(chain cldf_evm.Chain, aggregator common.Address, acce
8183 return resp , nil
8284}
8385
84- func DeployBundleAggregatorProxy (chain cldf_evm.Chain , aggregator common.Address , owner common.Address , labels []string ) (* types.DeployBundleAggregatorProxyResponse , error ) {
85- proxyAddr , tx , proxyContract , err := bundleproxy .DeployBundleAggregatorProxy (chain .DeployerKey , chain .Client , aggregator , owner )
86+ func DeployBundleAggregatorProxy (lggr logger.Logger , chain cldf_evm.Chain , aggregator common.Address , owner common.Address , labels []string ) (* types.DeployBundleAggregatorProxyResponse , error ) {
87+ lggr .Debugw ("Deploying BundleAggregatorProxy" ,
88+ "chainSelector" , chain .Selector ,
89+ "aggregator" , aggregator .Hex (),
90+ "owner" , owner .Hex (),
91+ "deployer" , chain .DeployerKey .From .Hex ())
92+
93+ proxyAddr , tx , _ , err := bundleproxy .DeployBundleAggregatorProxy (chain .DeployerKey , chain .Client , aggregator , owner )
8694 if err != nil {
8795 return nil , fmt .Errorf ("failed to deploy BundleAggregatorProxy: %w" , err )
8896 }
8997
90- _ , err = chain .Confirm (tx )
98+ lggr .Debugw ("BundleAggregatorProxy deploy tx submitted" ,
99+ "chainSelector" , chain .Selector ,
100+ "txHash" , tx .Hash ().Hex (),
101+ "txNonce" , tx .Nonce (),
102+ "predictedAddress" , proxyAddr .Hex ())
103+
104+ blockNum , err := chain .Confirm (tx )
91105 if err != nil {
92106 return nil , fmt .Errorf ("failed to confirm BundleAggregatorProxy: %w" , err )
93107 }
94108
109+ lggr .Debugw ("BundleAggregatorProxy deploy tx confirmed" ,
110+ "chainSelector" , chain .Selector ,
111+ "txHash" , tx .Hash ().Hex (),
112+ "blockNumber" , blockNum ,
113+ "predictedAddress" , proxyAddr .Hex ())
114+
115+ receipt , err := chain .Client .TransactionReceipt (context .Background (), tx .Hash ())
116+ if err != nil {
117+ return nil , fmt .Errorf ("failed to get receipt for BundleAggregatorProxy deploy tx: %w" , err )
118+ }
119+
120+ receiptAddr := receipt .ContractAddress
121+ if receiptAddr != proxyAddr {
122+ lggr .Warnw ("BundleAggregatorProxy predicted address does not match receipt address" ,
123+ "chainSelector" , chain .Selector ,
124+ "predictedAddress" , proxyAddr .Hex (),
125+ "receiptAddress" , receiptAddr .Hex (),
126+ "txHash" , tx .Hash ().Hex (),
127+ "txNonce" , tx .Nonce (),
128+ "receiptStatus" , receipt .Status )
129+ proxyAddr = receiptAddr
130+ }
131+
132+ code , err := chain .Client .CodeAt (context .Background (), proxyAddr , nil )
133+ if err != nil {
134+ return nil , fmt .Errorf ("failed to check code at BundleAggregatorProxy address %s: %w" , proxyAddr , err )
135+ }
136+ if len (code ) == 0 {
137+ lggr .Errorw ("No contract code found at BundleAggregatorProxy address after confirmed deployment" ,
138+ "chainSelector" , chain .Selector ,
139+ "address" , proxyAddr .Hex (),
140+ "txHash" , tx .Hash ().Hex (),
141+ "txNonce" , tx .Nonce (),
142+ "receiptStatus" , receipt .Status ,
143+ "blockNumber" , receipt .BlockNumber )
144+ return nil , fmt .Errorf ("no contract code at BundleAggregatorProxy address %s (tx %s, status %d)" , proxyAddr , tx .Hash (), receipt .Status )
145+ }
146+
147+ lggr .Debugw ("BundleAggregatorProxy code verified at address" ,
148+ "chainSelector" , chain .Selector ,
149+ "address" , proxyAddr .Hex (),
150+ "codeSize" , len (code ))
151+
152+ proxyContract , err := bundleproxy .NewBundleAggregatorProxy (proxyAddr , chain .Client )
153+ if err != nil {
154+ return nil , fmt .Errorf ("failed to bind BundleAggregatorProxy at %s: %w" , proxyAddr , err )
155+ }
156+
95157 tvStr , err := proxyContract .TypeAndVersion (& bind.CallOpts {})
96158 if err != nil {
97- return nil , fmt .Errorf ("failed to get type and version: %w" , err )
159+ return nil , fmt .Errorf ("failed to get type and version at %s : %w" , proxyAddr , err )
98160 }
161+
162+ lggr .Debugw ("BundleAggregatorProxy typeAndVersion retrieved" ,
163+ "chainSelector" , chain .Selector ,
164+ "address" , proxyAddr .Hex (),
165+ "typeAndVersion" , tvStr )
166+
99167 tv , err := cldf .TypeAndVersionFromString (tvStr )
100168 if err != nil {
101169 return nil , fmt .Errorf ("failed to parse type and version from %s: %w" , tvStr , err )
0 commit comments