@@ -14,7 +14,6 @@ import (
1414 "github.com/ethereum/go-ethereum/accounts/abi"
1515 "github.com/ethereum/go-ethereum/accounts/abi/bind"
1616 "github.com/ethereum/go-ethereum/common"
17- "github.com/ethereum/go-ethereum/core/types"
1817 "github.com/ethereum/go-ethereum/crypto"
1918 "github.com/ethereum/go-ethereum/ethclient"
2019 "github.com/pkg/errors"
@@ -27,24 +26,6 @@ import (
2726
2827const (
2928 chainIDCoston2 = 114
30-
31- breakingEpochCoston2 = 5338
32- )
33-
34- const (
35- newRegistryCoston2Addr = "0x6a0AF07b7972177B176d3D422555cbc98DfDe914"
36- oldRegistryCoston2Addr = "0xc6E40401395DCc648bC4bBb38fE4552423cD9BAC"
37-
38- newPreRegistryCoston2Addr = "0xee963D1867d8B5f3D3E304802B40BC55B3eDeCB8"
39- oldPreRegistryCoston2Addr = "0x47469Af25c253B4fb9b2a207BF4069574C6CcBd7"
40- )
41-
42- var (
43- newRegistryCoston2 = common .HexToAddress (newRegistryCoston2Addr )
44- oldRegistryCoston2 = common .HexToAddress (oldRegistryCoston2Addr )
45-
46- newPreRegistryCoston2 = common .HexToAddress (newPreRegistryCoston2Addr )
47- oldPreRegistryCoston2 = common .HexToAddress (oldPreRegistryCoston2Addr )
4829)
4930
5031var (
@@ -131,9 +112,7 @@ type registryContractClientImpl struct {
131112 registryAddress common.Address
132113 preregistryAddress common.Address
133114 registry * registry.Registry
134- oldRegistry * registry.Registry
135115 preregistry * preregistry.Preregistry
136- oldPreregistry * preregistry.Preregistry
137116 senderTxOpts * bind.TransactOpts
138117 gasCfg * config.Gas
139118 txVerifier * chain.TxVerifier
@@ -159,38 +138,12 @@ func NewRegistryContractClient(
159138 return nil , fmt .Errorf ("pre registry binding: %w" , err )
160139 }
161140
162- var oldRegistryBinding * registry.Registry
163- if registryAddress == newRegistryCoston2 {
164- oldRegistryBinding , err = registry .NewRegistry (oldRegistryCoston2 , ethClient )
165- if err != nil {
166- return nil , fmt .Errorf ("registry binding old: %w" , err )
167- }
168-
169- if chainID != chainIDCoston2 {
170- return nil , errors .New ("registry contract for coston2 on different chain" )
171- }
172- }
173-
174- var oldPreRegistryBinding * preregistry.Preregistry
175- if preregistryAddress == newPreRegistryCoston2 {
176- oldPreRegistryBinding , err = preregistry .NewPreregistry (oldPreRegistryCoston2 , ethClient )
177- if err != nil {
178- return nil , fmt .Errorf ("pre registry binding old: %w" , err )
179- }
180-
181- if chainID != chainIDCoston2 {
182- return nil , errors .New ("pre registry contract for coston2 on different chain" )
183- }
184- }
185-
186141 return & registryContractClientImpl {
187142 ethClient : ethClient ,
188143 registryAddress : registryAddress ,
189144 preregistryAddress : preregistryAddress ,
190145 registry : registryBinding ,
191- oldRegistry : oldRegistryBinding ,
192146 preregistry : preregistryBinding ,
193- oldPreregistry : oldPreRegistryBinding ,
194147 senderTxOpts : senderTxOpts ,
195148 gasCfg : gasCfg ,
196149 txVerifier : chain .NewTxVerifier (ethClient ),
@@ -216,16 +169,13 @@ func (r *registryContractClientImpl) RegisterVoter(nextRewardEpochID *big.Int, a
216169
217170func (r * registryContractClientImpl ) sendRegisterVoter (nextRewardEpochID * big.Int , address common.Address ) error {
218171 epochID := uint32 (nextRewardEpochID .Uint64 ())
219- old , oldAddress := shouldUseOldRegistry (epochID , r .registryAddress )
220- rAddress := r .registryAddress
221172
222173 var (
223174 signature []byte
224175 err error
225176 )
226177
227- if old || r .chainID != chainIDCoston2 {
228- rAddress = oldAddress
178+ if r .chainID != chainIDCoston2 {
229179 signature , err = r .createSignatureOld (epochID , address )
230180 if err != nil {
231181 return fmt .Errorf ("creating registry signature old: %w" , err )
@@ -252,7 +202,7 @@ func (r *registryContractClientImpl) sendRegisterVoter(nextRewardEpochID *big.In
252202 r .ethClient ,
253203 chain .DefaultTxTimeout ,
254204 r .senderTxOpts .From ,
255- rAddress ,
205+ r . registryAddress ,
256206 common .Big0 ,
257207 registryAbi ,
258208 "registerVoter" ,
@@ -269,18 +219,9 @@ func (r *registryContractClientImpl) sendRegisterVoter(nextRewardEpochID *big.In
269219 r .senderTxOpts .GasLimit = estimatedGasLimit
270220 }
271221
272- var tx * types.Transaction
273-
274- if old {
275- tx , err = r .oldRegistry .RegisterVoter (r .senderTxOpts , address , vrsSignature )
276- if err != nil {
277- return fmt .Errorf ("sending registry tx old: %w" , err )
278- }
279- } else {
280- tx , err = r .registry .RegisterVoter (r .senderTxOpts , address , vrsSignature )
281- if err != nil {
282- return fmt .Errorf ("sending registry tx new: %w" , err )
283- }
222+ tx , err := r .registry .RegisterVoter (r .senderTxOpts , address , vrsSignature )
223+ if err != nil {
224+ return fmt .Errorf ("sending registry tx: %w" , err )
284225 }
285226
286227 err = r .txVerifier .WaitUntilMined (r .senderTxOpts .From , tx , chain .DefaultTxTimeout )
@@ -308,16 +249,13 @@ func (r *registryContractClientImpl) PreregisterVoter(nextRewardEpochId *big.Int
308249
309250func (r * registryContractClientImpl ) sendPreRegisterVoter (nextRewardEpochID * big.Int , address common.Address ) error {
310251 epochID := uint32 (nextRewardEpochID .Uint64 ())
311- old , oldAddress := shouldUseOldPreRegistry (epochID , r .registryAddress )
312- prAddress := r .preregistryAddress
313252
314253 var (
315254 signature []byte
316255 err error
317256 )
318257
319- if old || r .chainID != chainIDCoston2 {
320- prAddress = oldAddress
258+ if r .chainID != chainIDCoston2 {
321259 signature , err = r .createSignatureOld (epochID , address )
322260 if err != nil {
323261 return fmt .Errorf ("creating registry signature old: %w" , err )
@@ -344,7 +282,7 @@ func (r *registryContractClientImpl) sendPreRegisterVoter(nextRewardEpochID *big
344282 r .ethClient ,
345283 chain .DefaultTxTimeout ,
346284 r .senderTxOpts .From ,
347- prAddress ,
285+ r . preregistryAddress ,
348286 common .Big0 ,
349287 preregistryAbi ,
350288 "preRegisterVoter" ,
@@ -361,17 +299,9 @@ func (r *registryContractClientImpl) sendPreRegisterVoter(nextRewardEpochID *big
361299 r .senderTxOpts .GasLimit = estimatedGasLimit
362300 }
363301
364- var tx * types.Transaction
365- if old {
366- tx , err = r .oldPreregistry .PreRegisterVoter (r .senderTxOpts , address , vrsSignature )
367- if err != nil {
368- return fmt .Errorf ("sending preregistry tx old: %w" , err )
369- }
370- } else {
371- tx , err = r .preregistry .PreRegisterVoter (r .senderTxOpts , address , vrsSignature )
372- if err != nil {
373- return fmt .Errorf ("sending preregistry tx new: %w" , err )
374- }
302+ tx , err := r .preregistry .PreRegisterVoter (r .senderTxOpts , address , vrsSignature )
303+ if err != nil {
304+ return fmt .Errorf ("sending preregistry tx: %w" , err )
375305 }
376306
377307 err = r .txVerifier .WaitUntilMined (r .senderTxOpts .From , tx , chain .DefaultTxTimeout )
@@ -452,19 +382,3 @@ func SetGas(txOptions *bind.TransactOpts, client *ethclient.Client, gasConfig *c
452382 return fmt .Errorf ("unsupported tx type: %d" , gasConfig .TxType )
453383 }
454384}
455-
456- func shouldUseOldRegistry (epochID uint32 , address common.Address ) (bool , common.Address ) {
457- if address == newRegistryCoston2 && epochID <= breakingEpochCoston2 {
458- return true , oldRegistryCoston2
459- }
460-
461- return false , common.Address {}
462- }
463-
464- func shouldUseOldPreRegistry (epochID uint32 , address common.Address ) (bool , common.Address ) {
465- if address == newPreRegistryCoston2 && epochID <= breakingEpochCoston2 {
466- return true , oldPreRegistryCoston2
467- }
468-
469- return false , common.Address {}
470- }
0 commit comments