forked from cerc-io/laconicd-deprecated
parent
3b3daa4b48
commit
036ffb7a39
@ -1,16 +1,14 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/tharsis/ethermint/x/evm/types"
|
"github.com/tharsis/ethermint/x/evm/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,14 +31,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.Vali
|
|||||||
infCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
infCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
||||||
k.WithContext(ctx)
|
k.WithContext(ctx)
|
||||||
|
|
||||||
// get the block bloom bytes from the transient store and set it to the persistent storage
|
k.SetBlockBloom(infCtx, req.Height, ethtypes.BytesToBloom(k.GetBlockBloomTransient().Bytes()))
|
||||||
bloomBig, found := k.GetBlockBloomTransient()
|
|
||||||
if !found {
|
|
||||||
bloomBig = big.NewInt(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
bloom := ethtypes.BytesToBloom(bloomBig.Bytes())
|
|
||||||
k.SetBlockBloom(infCtx, req.Height, bloom)
|
|
||||||
k.WithContext(ctx)
|
k.WithContext(ctx)
|
||||||
|
|
||||||
return []abci.ValidatorUpdate{}
|
return []abci.ValidatorUpdate{}
|
||||||
|
@ -131,14 +131,14 @@ func (k Keeper) SetBlockBloom(ctx sdk.Context, height int64, bloom ethtypes.Bloo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockBloomTransient returns bloom bytes for the current block height
|
// GetBlockBloomTransient returns bloom bytes for the current block height
|
||||||
func (k Keeper) GetBlockBloomTransient() (*big.Int, bool) {
|
func (k Keeper) GetBlockBloomTransient() *big.Int {
|
||||||
store := k.ctx.TransientStore(k.transientKey)
|
store := k.ctx.TransientStore(k.transientKey)
|
||||||
bz := store.Get(types.KeyPrefixTransientBloom)
|
bz := store.Get(types.KeyPrefixTransientBloom)
|
||||||
if len(bz) == 0 {
|
if len(bz) == 0 {
|
||||||
return nil, false
|
return big.NewInt(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(big.Int).SetBytes(bz), true
|
return new(big.Int).SetBytes(bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBlockBloomTransient sets the given bloom bytes to the transient store. This value is reset on
|
// SetBlockBloomTransient sets the given bloom bytes to the transient store. This value is reset on
|
||||||
|
@ -144,11 +144,18 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT
|
|||||||
return nil, stacktrace.Propagate(err, "failed to apply ethereum core message")
|
return nil, stacktrace.Propagate(err, "failed to apply ethereum core message")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the ethereum-formatted hash to the tx result as the tendermint hash is different
|
// NOTE: we set up the transaction hash from tendermint as it is the format expected by the application:
|
||||||
// NOTE: see https://github.com/tendermint/tendermint/issues/6539 for reference.
|
// Remove once hashing is fixed on Tendermint. See https://github.com/tendermint/tendermint/issues/6539
|
||||||
txHash := tx.Hash()
|
txHash := common.BytesToHash(tmtypes.Tx(k.ctx.TxBytes()).Hash())
|
||||||
res.Hash = txHash.Hex()
|
res.Hash = txHash.Hex()
|
||||||
res.Logs = types.NewLogsFromEth(k.GetTxLogs(txHash))
|
|
||||||
|
logs := k.GetTxLogs(txHash)
|
||||||
|
res.Logs = types.NewLogsFromEth(logs)
|
||||||
|
|
||||||
|
// update block bloom filter
|
||||||
|
bloom := k.GetBlockBloomTransient()
|
||||||
|
bloom.Or(bloom, big.NewInt(0).SetBytes(ethtypes.LogsBloom(logs)))
|
||||||
|
k.SetBlockBloomTransient(bloom)
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ func (k *Keeper) AddLog(log *ethtypes.Log) {
|
|||||||
log.BlockHash = common.BytesToHash(k.ctx.HeaderHash())
|
log.BlockHash = common.BytesToHash(k.ctx.HeaderHash())
|
||||||
log.TxIndex = uint(k.GetTxIndexTransient())
|
log.TxIndex = uint(k.GetTxIndexTransient())
|
||||||
|
|
||||||
logs := k.GetTxLogs(log.TxHash)
|
logs := k.GetTxLogs(key)
|
||||||
|
|
||||||
log.Index = uint(len(logs))
|
log.Index = uint(len(logs))
|
||||||
logs = append(logs, log)
|
logs = append(logs, log)
|
||||||
|
Loading…
Reference in New Issue
Block a user