Skip to content

Commit

Permalink
fix: update with new asset proto (#34)
Browse files Browse the repository at this point in the history
Updates to utilize the new asset proto, additionally fixes a genesis
parameter naming issue.
  • Loading branch information
joroshiba authored Jun 28, 2024
1 parent 082e84f commit e89845e
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 77 deletions.
2 changes: 1 addition & 1 deletion genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"astriaRollupName": "astria",
"astriaOverrideGenesisExtraData": true,
"astriaSequencerInitialHeight": 2,
"astriaSequencerHrpPrefix": "astria",
"astriaSequencerAddressPrefix": "astria",
"astriaCelestiaInitialHeight": 2,
"astriaCelestiaHeightVariance": 10,
"astriaBridgeAddresses": [
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ethereum/go-ethereum
go 1.21

require (
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240626163506-6267d841fc26.1
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240626163506-6267d841fc26.2
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240627184145-202c666b5a8a.1
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240627184145-202c666b5a8a.2
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.2-20240626163506-691883836b9e.2
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240626163506-3df35f3e4d06.2
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240627184145-00f432997496.2
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
github.com/Microsoft/go-winio v0.6.1
github.com/VictoriaMetrics/fastcache v1.12.1
Expand Down
18 changes: 9 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240626163506-6267d841fc26.1 h1:YYd471Be/s8tR25c8AqKheopi3pVqe1UEq8iihl4QYQ=
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240626163506-6267d841fc26.1/go.mod h1:E/5TEy5OyZT3KWWeyGkQF6wMOExaKiq/Uh5WA3Hr/Hw=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-20240626163506-6267d841fc26.1/go.mod h1:RRvnadMnGUIiPLuPe7u7+ceMFziAif4+837MBE2oe6E=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240626163506-6267d841fc26.2 h1:1Yo2otKPFY5Q43uDTM1bp5rOPxa777A6KtFIjm0N2rU=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240626163506-6267d841fc26.2/go.mod h1:0x/TVFf+tWPurkqOHHvGqh6m+y3f69ffpu4lTkfNkyI=
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240627184145-202c666b5a8a.1 h1:hYCnNcMBgnEa6XLAMgGD0cZXoulA1Dmn5xi6cERVqZA=
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240627184145-202c666b5a8a.1/go.mod h1:SFzpkHZaY4sEyrJ5vSwZU6XdPo1ntBDKXtt75T26dac=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-20240627184145-202c666b5a8a.1/go.mod h1:lBkx3jiHbz6XM0FAkbQEmUFNifgc4x7oi9LuOK/HDbg=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240627184145-202c666b5a8a.2 h1:IYFQwWxQXFovUY/kMnXWaQJ8KJ5uuLOBE0ks2II254c=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.2-20240627184145-202c666b5a8a.2/go.mod h1:czHASkeeVmYV4IC0uo9qWDQ0dmEJeC6LfgYWBwSSREI=
buf.build/gen/go/astria/primitives/grpc/go v1.4.0-20240626163506-691883836b9e.1/go.mod h1:VU1xcDnHOU7++vCZHJzilQGWAd4m1SWTBYKuo4qx/cg=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.1-20240626163506-691883836b9e.1/go.mod h1:pkz/GfhAgZSnDxyZ5bmGUzk6iQNAvyW72pYPkqb7Pbk=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.2-20240626163506-691883836b9e.2 h1:bCHvCYyvhCPWGc3tpl164ONADbH+nKPSc6KhOWb9tfk=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.2-20240626163506-691883836b9e.2/go.mod h1:J0Tk7JAHcrhzWNEf1lbePSfFZ1Kp78eAlnO8Cs2ELKg=
buf.build/gen/go/astria/sequencerblock-apis/grpc/go v1.4.0-20240626163506-3df35f3e4d06.1/go.mod h1:Zt4fThI4h3dw3FjyWA8bkoB9R3pQ9zPxhlIqLuTp130=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.1-20240626163506-3df35f3e4d06.1/go.mod h1:KkZ92tBsbbl5HTuN/AbQLkW2ALXsaV5MsEU9PPy/n9c=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240626163506-3df35f3e4d06.2 h1:ZXnJ2iUreFCU/umNBaTo5iL2sVQtHPdjYC17/uSgA+s=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240626163506-3df35f3e4d06.2/go.mod h1:NEZbII2+dhqPXaQqMYN8ziELoYQgp7hbDFv5Oc45EZU=
buf.build/gen/go/astria/sequencerblock-apis/grpc/go v1.4.0-20240627184145-00f432997496.1/go.mod h1:viF0ZoRvyO5qpIZb1wB3aBBt9WWKOg5x5t6AFKKuKQU=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.1-20240627184145-00f432997496.1/go.mod h1:KkZ92tBsbbl5HTuN/AbQLkW2ALXsaV5MsEU9PPy/n9c=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240627184145-00f432997496.2 h1:s349kECGqPwCKQ1q09lqBR6782/0zDqDez+FEM5PT0s=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240627184145-00f432997496.2/go.mod h1:NEZbII2+dhqPXaQqMYN8ziELoYQgp7hbDFv5Oc45EZU=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down
27 changes: 13 additions & 14 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ type ExecutionServiceServerV1Alpha2 struct {
genesisInfoCalled bool
getCommitmentStateCalled bool

bridgeAddresses map[string]*params.AstriaBridgeAddressConfig // astria bridge addess to config for that bridge account
bridgeAllowedAssetIDs map[[32]byte]struct{} // a set of allowed asset IDs structs are left empty
bridgeSenderAddress common.Address // address from which AstriaBridgeableERC20 contracts are called
bridgeAddresses map[string]*params.AstriaBridgeAddressConfig // astria bridge addess to config for that bridge account
bridgeAllowedAssets map[string]struct{} // a set of allowed asset IDs structs are left empty
bridgeSenderAddress common.Address // address from which AstriaBridgeableERC20 contracts are called

nextFeeRecipient common.Address // Fee recipient for the next block
}
Expand Down Expand Up @@ -95,13 +95,13 @@ func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServ
}

bridgeAddresses := make(map[string]*params.AstriaBridgeAddressConfig)
bridgeAllowedAssetIDs := make(map[[32]byte]struct{})
bridgeAllowedAssets := make(map[string]struct{})
if bc.Config().AstriaBridgeAddressConfigs == nil {
log.Warn("bridge addresses not set")
} else {
nativeBridgeSeen := false
for _, cfg := range bc.Config().AstriaBridgeAddressConfigs {
err := cfg.Validate(bc.Config().AstriaSequencerHrpPrefix)
err := cfg.Validate(bc.Config().AstriaSequencerAddressPrefix)
if err != nil {
return nil, fmt.Errorf("invalid bridge address config: %w", err)
}
Expand All @@ -118,8 +118,7 @@ func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServ
}

bridgeAddresses[cfg.BridgeAddress] = &cfg
assetID := sha256.Sum256([]byte(cfg.AssetDenom))
bridgeAllowedAssetIDs[assetID] = struct{}{}
bridgeAllowedAssets[cfg.AssetDenom] = struct{}{}
if cfg.Erc20Asset == nil {
log.Info("bridge for sequencer native asset initialized", "bridgeAddress", cfg.BridgeAddress, "assetDenom", cfg.AssetDenom)
} else {
Expand All @@ -145,12 +144,12 @@ func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServ
}

return &ExecutionServiceServerV1Alpha2{
eth: eth,
bc: bc,
bridgeAddresses: bridgeAddresses,
bridgeAllowedAssetIDs: bridgeAllowedAssetIDs,
bridgeSenderAddress: bc.Config().AstriaBridgeSenderAddress,
nextFeeRecipient: nextFeeRecipient,
eth: eth,
bc: bc,
bridgeAddresses: bridgeAddresses,
bridgeAllowedAssets: bridgeAllowedAssets,
bridgeSenderAddress: bc.Config().AstriaBridgeSenderAddress,
nextFeeRecipient: nextFeeRecipient,
}, nil
}

Expand Down Expand Up @@ -250,7 +249,7 @@ func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req *

txsToProcess := types.Transactions{}
for _, tx := range req.Transactions {
unmarshalledTx, err := validateAndUnmarshalSequencerTx(height, tx, s.bridgeAddresses, s.bridgeAllowedAssetIDs, s.bridgeSenderAddress)
unmarshalledTx, err := validateAndUnmarshalSequencerTx(height, tx, s.bridgeAddresses, s.bridgeAllowedAssets, s.bridgeSenderAddress)
if err != nil {
log.Debug("failed to validate sequencer tx, ignoring", "tx", tx, "err", err)
continue
Expand Down
8 changes: 4 additions & 4 deletions grpc/execution/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlock(t *testing.T) {
if tt.depositTxAmount.Cmp(big.NewInt(0)) != 0 {
depositAmount := bigIntToProtoU128(tt.depositTxAmount)
bridgeAddress := ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].BridgeAddress
bridgeAssetDenom := sha256.Sum256([]byte(ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom))
bridgeAssetDenom := ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom

// create new chain destination address for better testing
chainDestinationAddressPrivKey, err := crypto.GenerateKey()
Expand All @@ -298,7 +298,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlock(t *testing.T) {
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
AssetId: bridgeAssetDenom[:],
Asset: bridgeAssetDenom,
Amount: depositAmount,
RollupId: &primitivev1.RollupId{Inner: genesisInfo.RollupId},
DestinationChainAddress: chainDestinationAddress.String(),
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitment(t *testi
amountToDeposit := big.NewInt(1000000000000000000)
depositAmount := bigIntToProtoU128(amountToDeposit)
bridgeAddress := ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].BridgeAddress
bridgeAssetDenom := sha256.Sum256([]byte(ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom))
bridgeAssetDenom := ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom

// create new chain destination address for better testing
chainDestinationAddressPrivKey, err := crypto.GenerateKey()
Expand All @@ -391,7 +391,7 @@ func TestExecutionServiceServerV1Alpha2_ExecuteBlockAndUpdateCommitment(t *testi
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
AssetId: bridgeAssetDenom[:],
Asset: bridgeAssetDenom,
Amount: depositAmount,
RollupId: &primitivev1.RollupId{Inner: genesisInfo.RollupId},
DestinationChainAddress: chainDestinationAddress.String(),
Expand Down
10 changes: 4 additions & 6 deletions grpc/execution/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package execution

import (
"crypto/ecdsa"
"crypto/sha256"
"math/big"
"testing"
"time"
Expand Down Expand Up @@ -56,12 +55,12 @@ func generateMergeChain(n int, merged bool) (*core.Genesis, []*types.Block, stri
}

config.AstriaRollupName = "astria"
config.AstriaSequencerHrpPrefix = "astria"
config.AstriaSequencerAddressPrefix = "astria"
config.AstriaSequencerInitialHeight = 10
config.AstriaCelestiaInitialHeight = 10
config.AstriaCelestiaHeightVariance = 10

bech32mBridgeAddress, err := bech32.EncodeM(config.AstriaSequencerHrpPrefix, bridgeAddressBytes)
bech32mBridgeAddress, err := bech32.EncodeM(config.AstriaSequencerAddressPrefix, bridgeAddressBytes)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -141,8 +140,8 @@ func setupExecutionService(t *testing.T, noOfBlocksToGenerate int) (*eth.Ethereu
feeCollector := crypto.PubkeyToAddress(feeCollectorKey.PublicKey)
require.Equal(t, feeCollector, serviceV1Alpha1.nextFeeRecipient, "nextFeeRecipient not set correctly")

bridgeAsset := sha256.Sum256([]byte(genesis.Config.AstriaBridgeAddressConfigs[0].AssetDenom))
_, ok := serviceV1Alpha1.bridgeAllowedAssetIDs[bridgeAsset]
bridgeAsset := genesis.Config.AstriaBridgeAddressConfigs[0].AssetDenom
_, ok := serviceV1Alpha1.bridgeAllowedAssets[bridgeAsset]
require.True(t, ok, "bridgeAllowedAssetIDs does not contain bridge asset id")

_, ok = serviceV1Alpha1.bridgeAddresses[bridgeAddress]
Expand All @@ -152,5 +151,4 @@ func setupExecutionService(t *testing.T, noOfBlocksToGenerate int) (*eth.Ethereu
require.Nil(t, err, "can't insert blocks")

return ethservice, serviceV1Alpha1

}
18 changes: 5 additions & 13 deletions grpc/execution/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func validateAndUnmarshalSequencerTx(
height uint64,
tx *sequencerblockv1alpha1.RollupData,
bridgeAddresses map[string]*params.AstriaBridgeAddressConfig,
bridgeAllowedAssetIDs map[[32]byte]struct{},
bridgeAllowedAssets map[string]struct{},
bridgeSenderAddress common.Address,
) (*types.Transaction, error) {
if deposit := tx.GetDeposit(); deposit != nil {
Expand All @@ -34,20 +34,12 @@ func validateAndUnmarshalSequencerTx(
return nil, fmt.Errorf("bridging asset %s from bridge %s not allowed before height %d", bac.AssetDenom, bridgeAddress, bac.StartHeight)
}

if len(deposit.AssetId) != 32 {
return nil, fmt.Errorf("invalid asset ID: %x", deposit.AssetId)
if _, ok := bridgeAllowedAssets[deposit.Asset]; !ok {
return nil, fmt.Errorf("disallowed asset %s in deposit tx", deposit.Asset)
}

assetID := [32]byte{}
copy(assetID[:], deposit.AssetId[:32])

if _, ok := bridgeAllowedAssetIDs[assetID]; !ok {
return nil, fmt.Errorf("disallowed asset ID %x in deposit tx", deposit.AssetId)
}

expectedAssetID := sha256.Sum256([]byte(bac.AssetDenom))
if assetID != expectedAssetID {
return nil, fmt.Errorf("asset ID %x does not match bridge address %s asset", deposit.AssetId, bridgeAddress)
if deposit.Asset != bac.AssetDenom {
return nil, fmt.Errorf("asset %s does not match bridge address %s asset", deposit.Asset, bridgeAddress)
}

recipient := common.HexToAddress(deposit.DestinationChainAddress)
Expand Down
31 changes: 8 additions & 23 deletions grpc/execution/validation_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package execution

import (
"crypto/sha256"
"math/big"
"testing"

Expand Down Expand Up @@ -73,11 +72,10 @@ func TestSequenceTxValidation(t *testing.T) {
require.Nil(t, err, "failed to generate chain destination key: %v", err)
chainDestinationAddress := crypto.PubkeyToAddress(chainDestinationKey.PublicKey)

bridgeAssetDenom := sha256.Sum256([]byte(ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom))
invalidBridgeAssetDenom := sha256.Sum256([]byte("invalid-asset-denom"))
bridgeAssetDenom := ethservice.BlockChain().Config().AstriaBridgeAddressConfigs[0].AssetDenom
invalidBridgeAssetDenom := "invalid-asset-denom"

invalidHeightBridgeAssetDenom := "invalid-height-asset-denom"
invalidHeightBridgeAssetDenomID := sha256.Sum256([]byte(invalidHeightBridgeAssetDenom))
invalidHeightBridgeAddressBech32m := generateBech32MAddress()
serviceV1Alpha1.bridgeAddresses[invalidHeightBridgeAddressBech32m] = &params.AstriaBridgeAddressConfig{
AssetDenom: invalidHeightBridgeAssetDenom,
Expand Down Expand Up @@ -125,46 +123,33 @@ func TestSequenceTxValidation(t *testing.T) {
BridgeAddress: &primitivev1.Address{
Bech32M: generateBech32MAddress(),
},
AssetId: bridgeAssetDenom[:],
Asset: bridgeAssetDenom,
Amount: bigIntToProtoU128(big.NewInt(1000000000000000000)),
RollupId: &primitivev1.RollupId{Inner: make([]byte, 0)},
DestinationChainAddress: chainDestinationAddress.String(),
}}},
wantErr: "unknown bridge address",
},
{
description: "deposit tx with an invalid asset id",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
AssetId: []byte("invalid-asset-id"),
Amount: bigIntToProtoU128(big.NewInt(1000000000000000000)),
RollupId: &primitivev1.RollupId{Inner: make([]byte, 0)},
DestinationChainAddress: chainDestinationAddress.String(),
}}},
wantErr: "invalid asset ID",
},
{
description: "deposit tx with a disallowed asset id",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
AssetId: invalidBridgeAssetDenom[:],
Asset: invalidBridgeAssetDenom,
Amount: bigIntToProtoU128(big.NewInt(1000000000000000000)),
RollupId: &primitivev1.RollupId{Inner: make([]byte, 0)},
DestinationChainAddress: chainDestinationAddress.String(),
}}},
wantErr: "disallowed asset ID",
wantErr: "disallowed asset",
},
{
description: "deposit tx with a height and asset below the bridge start height",
sequencerTx: &sequencerblockv1alpha1.RollupData{Value: &sequencerblockv1alpha1.RollupData_Deposit{Deposit: &sequencerblockv1alpha1.Deposit{
BridgeAddress: &primitivev1.Address{
Bech32M: invalidHeightBridgeAddressBech32m,
},
AssetId: invalidHeightBridgeAssetDenomID[:],
Asset: invalidHeightBridgeAssetDenom,
Amount: bigIntToProtoU128(big.NewInt(1000000000000000000)),
RollupId: &primitivev1.RollupId{Inner: make([]byte, 0)},
DestinationChainAddress: chainDestinationAddress.String(),
Expand All @@ -177,7 +162,7 @@ func TestSequenceTxValidation(t *testing.T) {
BridgeAddress: &primitivev1.Address{
Bech32M: bridgeAddress,
},
AssetId: bridgeAssetDenom[:],
Asset: bridgeAssetDenom,
Amount: bigIntToProtoU128(big.NewInt(1000000000000000000)),
RollupId: &primitivev1.RollupId{Inner: make([]byte, 0)},
DestinationChainAddress: chainDestinationAddress.String(),
Expand All @@ -195,7 +180,7 @@ func TestSequenceTxValidation(t *testing.T) {

for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
_, err := validateAndUnmarshalSequencerTx(2, test.sequencerTx, serviceV1Alpha1.bridgeAddresses, serviceV1Alpha1.bridgeAllowedAssetIDs, common.Address{})
_, err := validateAndUnmarshalSequencerTx(2, test.sequencerTx, serviceV1Alpha1.bridgeAddresses, serviceV1Alpha1.bridgeAllowedAssets, common.Address{})
if test.wantErr == "" && err == nil {
return
}
Expand Down
8 changes: 4 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ type ChainConfig struct {
AstriaExtraDataOverride hexutil.Bytes `json:"astriaExtraDataOverride,omitempty"`
AstriaRollupName string `json:"astriaRollupName"`
AstriaSequencerInitialHeight uint32 `json:"astriaSequencerInitialHeight"`
AstriaSequencerHrpPrefix string `json:"astriaSequencerHrpPrefix"`
AstriaSequencerAddressPrefix string `json:"astriaSequencerAddressPrefix,omitempty"`
AstriaCelestiaInitialHeight uint64 `json:"astriaCelestiaInitialHeight"`
AstriaCelestiaHeightVariance uint64 `json:"astriaCelestiaHeightVariance,omitempty"`
AstriaBridgeAddressConfigs []AstriaBridgeAddressConfig `json:"astriaBridgeAddresses,omitempty"`
Expand Down Expand Up @@ -1066,7 +1066,7 @@ type AstriaErc20AssetConfig struct {
ContractPrecision uint16 `json:"contractPrecision"`
}

func (abc *AstriaBridgeAddressConfig) Validate(hrpPrefix string) error {
func (abc *AstriaBridgeAddressConfig) Validate(genesisPrefix string) error {
prefix, byteAddress, err := bech32.Decode(abc.BridgeAddress)
if err != nil {
return fmt.Errorf("bridge address must be a bech32 encoded string")
Expand All @@ -1075,8 +1075,8 @@ func (abc *AstriaBridgeAddressConfig) Validate(hrpPrefix string) error {
if err != nil {
return fmt.Errorf("failed to convert address to 8 bit")
}
if prefix != hrpPrefix {
return fmt.Errorf("bridge address must have prefix %s", hrpPrefix)
if prefix != genesisPrefix {
return fmt.Errorf("bridge address must have prefix %s", genesisPrefix)
}
if len(byteAddress) != 20 {
return fmt.Errorf("bridge address must have resolve to 20 byte address, got %d", len(byteAddress))
Expand Down

0 comments on commit e89845e

Please sign in to comment.