Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 9dc5782

Browse files
authored
fix: deneb hard fork (#35)
1 parent bc2f287 commit 9dc5782

File tree

9 files changed

+44
-41
lines changed

9 files changed

+44
-41
lines changed

chains/evm/lightclient/lightclient.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ func NewLightClient(url string) *LightClient {
2323
}
2424

2525
// Updates fetches light client updates for sync committee period
26-
func (c *LightClient) Updates(period uint64) ([]*consensus.LightClientUpdateCapella, error) {
26+
func (c *LightClient) Updates(period uint64) ([]*consensus.LightClientUpdateDeneb, error) {
2727
resp, err := http.Get(fmt.Sprintf("%s/eth/v1/beacon/light_client/updates?start_period=%d&count=1", c.beaconURL, period))
2828
if err != nil {
2929
return nil, err
3030
}
3131
defer resp.Body.Close()
3232

3333
type response struct {
34-
Data *consensus.LightClientUpdateCapella `json:"data"`
34+
Data *consensus.LightClientUpdateDeneb `json:"data"`
3535
}
3636
apiResponse := make([]response, 0)
3737
if err := c.decodeResp(resp, &apiResponse); err != nil {
3838
return nil, err
3939
}
4040

41-
updates := make([]*consensus.LightClientUpdateCapella, len(apiResponse))
41+
updates := make([]*consensus.LightClientUpdateDeneb, len(apiResponse))
4242
for i, update := range apiResponse {
4343
updates[i] = update.Data
4444
}
@@ -47,15 +47,15 @@ func (c *LightClient) Updates(period uint64) ([]*consensus.LightClientUpdateCape
4747
}
4848

4949
// FinalityUpdate returns the latest finalized light client update
50-
func (c *LightClient) FinalityUpdate() (*consensus.LightClientFinalityUpdateCapella, error) {
50+
func (c *LightClient) FinalityUpdate() (*consensus.LightClientFinalityUpdateDeneb, error) {
5151
resp, err := http.Get(fmt.Sprintf("%s/eth/v1/beacon/light_client/finality_update", c.beaconURL))
5252
if err != nil {
5353
return nil, err
5454
}
5555
defer resp.Body.Close()
5656

5757
type response struct {
58-
Data *consensus.LightClientFinalityUpdateCapella `json:"data,omitempty"`
58+
Data *consensus.LightClientFinalityUpdateDeneb `json:"data,omitempty"`
5959
}
6060
var apiResponse response
6161
if err := c.decodeResp(resp, &apiResponse); err != nil {
@@ -66,15 +66,15 @@ func (c *LightClient) FinalityUpdate() (*consensus.LightClientFinalityUpdateCape
6666
}
6767

6868
// Boostrap returns the latest light client bootstrap for the given block root
69-
func (c *LightClient) Bootstrap(blockRoot string) (*consensus.LightClientBootstrapCapella, error) {
69+
func (c *LightClient) Bootstrap(blockRoot string) (*consensus.LightClientBootstrapDeneb, error) {
7070
resp, err := http.Get(fmt.Sprintf("%s/eth/v1/beacon/light_client/bootstrap/%s", c.beaconURL, blockRoot))
7171
if err != nil {
7272
return nil, err
7373
}
7474
defer resp.Body.Close()
7575

7676
type response struct {
77-
Data *consensus.LightClientBootstrapCapella `json:"data,omitempty"`
77+
Data *consensus.LightClientBootstrapDeneb `json:"data,omitempty"`
7878
}
7979
var apiResponse response
8080
if err := c.decodeResp(resp, &apiResponse); err != nil {

chains/evm/listener/handlers/rotate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (h *RotateHandler) HandleEvents(checkpoint *apiv1.Finality) error {
7272
}
7373
sArgs := &prover.StepArgs{
7474
Pubkeys: args.Pubkeys,
75-
Update: &consensus.LightClientFinalityUpdateCapella{
75+
Update: &consensus.LightClientFinalityUpdateDeneb{
7676
AttestedHeader: args.Update.AttestedHeader,
7777
FinalizedHeader: args.Update.FinalizedHeader,
7878
FinalityBranch: args.Update.FinalityBranch,

chains/evm/listener/handlers/rotate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (s *RotateHandlerTestSuite) Test_HandleEvents_CurrentPeriodOlderThanLatest(
7474
func (s *RotateHandlerTestSuite) Test_HandleEvents_ValidPeriod() {
7575
s.mockPeriodStorer.EXPECT().StorePeriod(uint8(1), big.NewInt(4)).Return(nil)
7676
s.mockProver.EXPECT().RotateArgs(uint64(4)).Return(&prover.RotateArgs{
77-
Update: &consensus.LightClientUpdateCapella{},
77+
Update: &consensus.LightClientUpdateDeneb{},
7878
Domain: phase0.Domain{},
7979
Spec: "mainnet",
8080
Pubkeys: [512][48]byte{},

chains/evm/listener/handlers/step.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/sygmaprotocol/sygma-core/relayer/message"
2525
)
2626

27-
const EXECUTION_STATE_ROOT_INDEX = 18
27+
const EXECUTION_STATE_ROOT_INDEX = 34
2828

2929
type EventFetcher interface {
3030
FetchEventLogs(ctx context.Context, contractAddress common.Address, event string, startBlock *big.Int, endBlock *big.Int) ([]types.Log, error)

chains/evm/listener/handlers/step_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_FetchingArgsFails() {
8383

8484
func (s *StepHandlerTestSuite) Test_HandleEvents_FetchingLogsFails() {
8585
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
86-
Update: &consensus.LightClientFinalityUpdateCapella{
87-
FinalizedHeader: &consensus.LightClientHeaderCapella{
86+
Update: &consensus.LightClientFinalityUpdateDeneb{
87+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
8888
Header: &consensus.BeaconBlockHeader{
8989
Slot: 10,
9090
},
@@ -108,12 +108,12 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_FetchingLogsFails() {
108108

109109
func (s *StepHandlerTestSuite) Test_HandleEvents_FirstStep_StepExecuted() {
110110
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
111-
Update: &consensus.LightClientFinalityUpdateCapella{
112-
FinalizedHeader: &consensus.LightClientHeaderCapella{
111+
Update: &consensus.LightClientFinalityUpdateDeneb{
112+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
113113
Header: &consensus.BeaconBlockHeader{
114114
Slot: 10,
115115
},
116-
Execution: &consensus.ExecutionPayloadHeaderCapella{},
116+
Execution: &consensus.ExecutionPayloadHeaderDeneb{},
117117
},
118118
},
119119
}, nil)
@@ -153,12 +153,12 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_FirstStep_StepExecuted() {
153153

154154
func (s *StepHandlerTestSuite) Test_HandleEvents_SecondStep_MissingDeposits() {
155155
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
156-
Update: &consensus.LightClientFinalityUpdateCapella{
157-
FinalizedHeader: &consensus.LightClientHeaderCapella{
156+
Update: &consensus.LightClientFinalityUpdateDeneb{
157+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
158158
Header: &consensus.BeaconBlockHeader{
159159
Slot: 10,
160160
},
161-
Execution: &consensus.ExecutionPayloadHeaderCapella{},
161+
Execution: &consensus.ExecutionPayloadHeaderDeneb{},
162162
},
163163
},
164164
}, nil)
@@ -190,12 +190,12 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_SecondStep_MissingDeposits() {
190190
s.Nil(err)
191191

192192
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
193-
Update: &consensus.LightClientFinalityUpdateCapella{
194-
FinalizedHeader: &consensus.LightClientHeaderCapella{
193+
Update: &consensus.LightClientFinalityUpdateDeneb{
194+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
195195
Header: &consensus.BeaconBlockHeader{
196196
Slot: 10,
197197
},
198-
Execution: &consensus.ExecutionPayloadHeaderCapella{},
198+
Execution: &consensus.ExecutionPayloadHeaderDeneb{},
199199
},
200200
},
201201
}, nil)
@@ -229,12 +229,12 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_SecondStep_MissingDeposits() {
229229

230230
func (s *StepHandlerTestSuite) Test_HandleEvents_SecondStep_ValidDeposits() {
231231
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
232-
Update: &consensus.LightClientFinalityUpdateCapella{
233-
FinalizedHeader: &consensus.LightClientHeaderCapella{
232+
Update: &consensus.LightClientFinalityUpdateDeneb{
233+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
234234
Header: &consensus.BeaconBlockHeader{
235235
Slot: 10,
236236
},
237-
Execution: &consensus.ExecutionPayloadHeaderCapella{},
237+
Execution: &consensus.ExecutionPayloadHeaderDeneb{},
238238
},
239239
},
240240
}, nil)
@@ -266,12 +266,12 @@ func (s *StepHandlerTestSuite) Test_HandleEvents_SecondStep_ValidDeposits() {
266266
s.Nil(err)
267267

268268
s.mockStepProver.EXPECT().StepArgs().Return(&prover.StepArgs{
269-
Update: &consensus.LightClientFinalityUpdateCapella{
270-
FinalizedHeader: &consensus.LightClientHeaderCapella{
269+
Update: &consensus.LightClientFinalityUpdateDeneb{
270+
FinalizedHeader: &consensus.LightClientHeaderDeneb{
271271
Header: &consensus.BeaconBlockHeader{
272272
Slot: 10,
273273
},
274-
Execution: &consensus.ExecutionPayloadHeaderCapella{},
274+
Execution: &consensus.ExecutionPayloadHeaderDeneb{},
275275
},
276276
},
277277
}, nil)

chains/evm/prover/prover.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ type StepArgs struct {
2020
Spec Spec
2121
Pubkeys [512][48]byte
2222
Domain phase0.Domain
23-
Update *consensus.LightClientFinalityUpdateCapella
23+
Update *consensus.LightClientFinalityUpdateDeneb
2424
}
2525

2626
type RotateArgs struct {
2727
Spec Spec
28-
Update *consensus.LightClientUpdateCapella
28+
Update *consensus.LightClientUpdateDeneb
2929
Pubkeys [512][48]byte
3030
Domain phase0.Domain
3131
}
@@ -42,9 +42,9 @@ type EvmProof[T any] struct {
4242
}
4343

4444
type LightClient interface {
45-
FinalityUpdate() (*consensus.LightClientFinalityUpdateCapella, error)
46-
Updates(period uint64) ([]*consensus.LightClientUpdateCapella, error)
47-
Bootstrap(blockRoot string) (*consensus.LightClientBootstrapCapella, error)
45+
FinalityUpdate() (*consensus.LightClientFinalityUpdateDeneb, error)
46+
Updates(period uint64) ([]*consensus.LightClientUpdateDeneb, error)
47+
Bootstrap(blockRoot string) (*consensus.LightClientBootstrapDeneb, error)
4848
}
4949

5050
type BeaconClient interface {

go.mod

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,7 @@ require (
9191
rsc.io/tmplfunc v0.0.3 // indirect
9292
)
9393

94-
replace github.com/attestantio/go-eth2-client => github.com/mpetrun5/go-eth2-client v0.0.0-20231117132517-d4f046b12a1a
94+
replace (
95+
github.com/attestantio/go-eth2-client => github.com/mpetrun5/go-eth2-client v0.0.0-20231117132517-d4f046b12a1a
96+
github.com/umbracle/go-eth-consensus => github.com/sygmaprotocol/go-eth-consensus v0.0.0-20240209115220-99232c637bc3
97+
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
328328
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
329329
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
330330
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
331+
github.com/sygmaprotocol/go-eth-consensus v0.0.0-20240209115220-99232c637bc3 h1:SQsyRz3yyUxPlrfTR0s9YCdicTuJ3gE0ZiVm4xfz71c=
332+
github.com/sygmaprotocol/go-eth-consensus v0.0.0-20240209115220-99232c637bc3/go.mod h1:qaMaUGUsL5Twx/6TfG6BkJU3t6e8Pp9QUqFn7LvUOf8=
331333
github.com/sygmaprotocol/sygma-core v0.0.0-20231023115554-62219e098d0d h1:S2129X3uNculIdDae6J88ekiPWfzpcYhnVAeEuNRLQg=
332334
github.com/sygmaprotocol/sygma-core v0.0.0-20231023115554-62219e098d0d/go.mod h1:b4RZCyYr20Mp4WAAj4TkC6gU2KZ0ZWcpSGmKc6n8NKc=
333335
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
@@ -337,8 +339,6 @@ github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0h
337339
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
338340
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
339341
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
340-
github.com/umbracle/go-eth-consensus v0.1.3-0.20230605085523-929b6624372a h1:vb78VEJGmdd210nTX+/RfcIRanvxr4gnhxpO2RWlbvo=
341-
github.com/umbracle/go-eth-consensus v0.1.3-0.20230605085523-929b6624372a/go.mod h1:qaMaUGUsL5Twx/6TfG6BkJU3t6e8Pp9QUqFn7LvUOf8=
342342
github.com/umbracle/gohashtree v0.0.2-alpha.0.20230207094856-5b775a815c10 h1:CQh33pStIp/E30b7TxDlXfM0145bn2e8boI30IxAhTg=
343343
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
344344
github.com/vedhavyas/go-subkey v1.0.4 h1:QwjBZx4w7qXC2lmqol2jJfhaNXPI9BsgLZiMiCwqGDU=

mock/prover.go

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)