diff --git a/ethereum/rpc/blocks.go b/ethereum/rpc/blocks.go index d31c6b7d..452a47c4 100644 --- a/ethereum/rpc/blocks.go +++ b/ethereum/rpc/blocks.go @@ -2,6 +2,7 @@ package rpc import ( "context" + "encoding/base64" "encoding/json" "errors" "fmt" @@ -335,7 +336,12 @@ func (b *BackendImpl) blockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethty for _, attr := range event.Attributes { if attr.Key == evmtypes.AttributeKeyEthereumBloom { - return ethtypes.BytesToBloom([]byte(attr.Value)), nil + encodedBloom, err := base64.StdEncoding.DecodeString(attr.Value) + if err != nil { + return ethtypes.Bloom{}, err + } + + return ethtypes.BytesToBloom(encodedBloom), nil } } } diff --git a/ethereum/rpc/websockets.go b/ethereum/rpc/websockets.go index 6285545b..01e86c0a 100644 --- a/ethereum/rpc/websockets.go +++ b/ethereum/rpc/websockets.go @@ -3,6 +3,7 @@ package rpc import ( "bytes" "context" + "encoding/base64" "encoding/json" "fmt" "io" @@ -426,7 +427,18 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un for _, attr := range et.Attributes { if attr.Key == evmtypes.AttributeKeyEthereumBloom { - bloom = ethtypes.BytesToBloom([]byte(attr.Value)) + + encodedBloom, deCodeErr := base64.StdEncoding.DecodeString(attr.Value) + + sprintf := fmt.Sprintf("subscribeNewHeads event %d bloom %s header %d, ", len(bloom.Bytes()), attr.Value, data.Header.Height) + api.logger.Info(sprintf) + + if len(encodedBloom) != 256 { + continue + } + if deCodeErr == nil { + bloom = ethtypes.BytesToBloom(encodedBloom) + } } } } diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 8ef039d7..0ea3fdc8 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -1,11 +1,11 @@ package keeper import ( + "encoding/base64" "fmt" "math/big" "github.com/artela-network/aspect-core/djpm" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -208,10 +208,15 @@ func (k Keeper) GetAuthority() cosmos.AccAddress { // EmitBlockBloomEvent emit block bloom events func (k Keeper) EmitBlockBloomEvent(ctx cosmos.Context, bloom ethereum.Bloom) { + encodedBloom := base64.StdEncoding.EncodeToString(bloom.Bytes()) + + sprintf := fmt.Sprintf("emit block event %d bloom %s header %d, ", len(bloom.Bytes()), encodedBloom, ctx.BlockHeight()) + k.Logger(ctx).Info(sprintf) + ctx.EventManager().EmitEvent( cosmos.NewEvent( types.EventTypeBlockBloom, - cosmos.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())), + cosmos.NewAttribute(types.AttributeKeyEthereumBloom, encodedBloom), ), ) }