Skip to content

Commit

Permalink
add get genesis info for exec api + more hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
mycodecrafting committed Feb 8, 2024
1 parent 5e3467c commit b9041f8
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 2,228 deletions.
20 changes: 19 additions & 1 deletion astria/execution/v1alpha2.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,36 @@ type ExecutionServiceServerV1Alpha2 struct {

store store.Store
blockManager *block.SSManager
genesis GenesisInfo
logger log.Logger
blockExecutionLock sync.Mutex
}

func NewExecutionServiceServerV1Alpha2(blockManager *block.SSManager, store store.Store, logger log.Logger) *ExecutionServiceServerV1Alpha2 {
type GenesisInfo struct {
RollupId [32]byte
SequencerGenesisBlockHeight uint64
CelestiaBaseBlockHeight uint64
CelestiaBlockVariance uint64
}

func NewExecutionServiceServerV1Alpha2(blockManager *block.SSManager, genesis GenesisInfo, store store.Store, logger log.Logger) *ExecutionServiceServerV1Alpha2 {
return &ExecutionServiceServerV1Alpha2{
blockManager: blockManager,
genesis: genesis,
store: store,
logger: logger,
}
}

func (s *ExecutionServiceServerV1Alpha2) GetGenesisInfo(ctx context.Context, req *astriaPb.GetGenesisInfoRequest) (*astriaPb.GenesisInfo, error) {
return &astriaPb.GenesisInfo{
RollupId: s.genesis.RollupId[:],
SequencerGenesisBlockHeight: uint32(s.genesis.SequencerGenesisBlockHeight),
CelestiaBaseBlockHeight: uint32(s.genesis.CelestiaBaseBlockHeight),
CelestiaBlockVariance: uint32(s.genesis.CelestiaBlockVariance),
}, nil
}

// GetBlock retrieves a block by its identifier.
func (s *ExecutionServiceServerV1Alpha2) GetBlock(ctx context.Context, req *astriaPb.GetBlockRequest) (*astriaPb.Block, error) {
reqJson, _ := protojson.Marshal(req)
Expand Down
20 changes: 11 additions & 9 deletions astria/sequencer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ import (

// SequencerClient is a client for interacting with the sequencer.
type Client struct {
Client *client.Client
Signer *client.Signer
chainId string
nonce uint32
Client *client.Client
Signer *client.Signer
rollupId [32]byte
nonce uint32
}

func NewClient(sequencerAddr string, private ed25519.PrivateKey, chainId string) *Client {
func NewClient(sequencerAddr string, private ed25519.PrivateKey, rollupId [32]byte) *Client {
c, err := client.NewClient(sequencerAddr)
if err != nil {
panic(err)
}

return &Client{
Client: c,
Signer: client.NewSigner(private),
chainId: chainId,
Client: c,
Signer: client.NewSigner(private),
rollupId: rollupId,
}
}

Expand All @@ -39,7 +39,7 @@ func (c *Client) BroadcastTx(tx []byte) (*tendermintPb.ResultBroadcastTx, error)
{
Value: &astriaPb.Action_SequenceAction{
SequenceAction: &astriaPb.SequenceAction{
RollupId: []byte(c.chainId),
RollupId: c.rollupId[:],
Data: tx,
},
},
Expand Down Expand Up @@ -84,9 +84,11 @@ func (c *Client) BroadcastTx(tx []byte) (*tendermintPb.ResultBroadcastTx, error)
return nil, err
}
if resp.Code != 0 {
fmt.Println(resp)
return nil, fmt.Errorf("unexpected error code: %d", resp.Code)
}
} else if resp.Code != 0 {
fmt.Println(resp)
return nil, fmt.Errorf("unexpected error code: %d", resp.Code)
}

Expand Down
290 changes: 0 additions & 290 deletions block/block_sync.go

This file was deleted.

Loading

0 comments on commit b9041f8

Please sign in to comment.