Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ethereum/rpc/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rpc

import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -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
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion ethereum/rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rpc
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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),
),
)
}
Expand Down