Cosmos PR changes (#158)

* Changes necessary for enforced custom account encoding/decoding and keyring keybase changes

* updates cosmos dependency and fixes inconsistency in gas usage for simulated/real txs

* Update PR changes

* Remove unused password prompt when using OS keyring

* Update from changes to sdk

* Update to merged PR commit :the_horns:

* updated code to handle keyring backend options

* update documentation and replace cosmos-sdk with fork (temporarily)

* update cosmos dependency from fork

* update documentation
This commit is contained in:
Austin Abell
2019-12-13 14:50:19 -05:00
committed by GitHub
parent c2646c7b18
commit ce8a94a98e
13 changed files with 342 additions and 76 deletions
+5 -2
View File
@@ -1,6 +1,7 @@
package cli
import (
"bufio"
"fmt"
"strconv"
"strings"
@@ -48,8 +49,9 @@ func GetCmdGenTx(cdc *codec.Codec) *cobra.Command {
Args: cobra.RangeArgs(2, 3),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
toAddr, err := cosmosAddressFromArg(args[0])
if err != nil {
@@ -104,8 +106,9 @@ func GetCmdGenCreateTx(cdc *codec.Codec) *cobra.Command {
Args: cobra.RangeArgs(1, 2),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
payload := args[0]
if !strings.HasPrefix(payload, "0x") {
+8 -8
View File
@@ -56,6 +56,11 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result)
csdb = st.Csdb.Copy()
}
// This gas meter is set up to consume gas from gaskv during evm execution and be ignored
currentGasMeter := ctx.GasMeter()
evmGasMeter := sdk.NewInfiniteGasMeter()
csdb.WithContext(ctx.WithGasMeter(evmGasMeter))
// Clear cache of accounts to handle changes outside of the EVM
csdb.UpdateAccounts()
@@ -72,13 +77,7 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result)
GasPrice: ctx.MinGasPrices().AmountOf(emint.DenomDefault).Int,
}
// This gas meter is set up to consume gas from gaskv during evm execution and be ignored
evmGasMeter := sdk.NewInfiniteGasMeter()
vmenv := vm.NewEVM(
context, csdb.WithContext(ctx.WithGasMeter(evmGasMeter)),
GenerateChainConfig(st.ChainID), vm.Config{},
)
vmenv := vm.NewEVM(context, csdb, GenerateChainConfig(st.ChainID), vm.Config{})
var (
ret []byte
@@ -130,6 +129,7 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result)
}
// TODO: Refund unused gas here, if intended in future
if !st.Simulate {
// Finalise state if not a simulated transaction
st.Csdb.Finalise(true) // Change to depend on config
@@ -137,7 +137,7 @@ func (st StateTransition) TransitionCSDB(ctx sdk.Context) (*big.Int, sdk.Result)
// Consume gas from evm execution
// Out of gas check does not need to be done here since it is done within the EVM execution
ctx.GasMeter().ConsumeGas(gasLimit-leftOverGas, "EVM execution consumption")
ctx.WithGasMeter(currentGasMeter).GasMeter().ConsumeGas(gasLimit-leftOverGas, "EVM execution consumption")
return bloomInt, sdk.Result{Data: returnData, GasUsed: st.GasLimit - leftOverGas}
}