Skip to content

Commit

Permalink
fixed? i guess.
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty committed Feb 28, 2025
1 parent 3e5ea40 commit bc3478b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 46 deletions.
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(54436) // baseGas is the gas consumed before tx msg
baseGas := uint64(57504) // baseGas is the gas consumed before tx msg
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
if expGasConsumed > uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) {
// capped by gasLimit
Expand Down
83 changes: 38 additions & 45 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,47 @@ func (w *wrapper) ValidateBasic() error {

func (w *wrapper) getBodyBytes() []byte {
if len(w.bodyBz) == 0 {
if !w.tx.Body.Unordered && (w.tx.Body.TimeoutTimestamp.IsZero() || w.tx.Body.TimeoutTimestamp.Unix() == 0) {
anyMsgs, err := msgsV1toAnyV2(w.GetMsgs())
if err != nil {
panic(fmt.Errorf("unable to convert messages: %w", err))
}
body := &txv1beta1.TxBodyCompat{
Messages: anyMsgs,
Memo: w.GetMemo(),
TimeoutHeight: w.GetTimeoutHeight(),
ExtensionOptions: intoAnyV2(w.GetExtensionOptions()),
NonCriticalExtensionOptions: intoAnyV2(w.GetNonCriticalExtensionOptions()),
if w.tx.Body != nil {
if w.tx.Body.TimeoutTimestamp == nil {
w.tx.Body.TimeoutTimestamp = &time.Time{}
}
bodyBytes, err := marshalOption.Marshal(body)
if err != nil {
panic(fmt.Errorf("unable to marshal body: %w", err))
}
w.bodyBz = bodyBytes
} else {
// if bodyBz is empty, then marshal the body. bodyBz will generally
// be set to nil whenever SetBody is called so the result of calling
// this method should always return the correct bytes. Note that after
// decoding bodyBz is derived from TxRaw so that it matches what was
// transmitted over the wire
var err error
w.bodyBz, err = proto.Marshal(w.tx.Body)
if err != nil {
panic(err)
if !w.tx.Body.Unordered && (w.tx.Body.TimeoutTimestamp.IsZero() || w.tx.Body.TimeoutTimestamp.Unix() == 0) {
var anyMsgs []*anypb.Any
if len(w.tx.Body.Messages) > 0 {
for _, msg := range w.tx.Body.Messages {
anyMsgs = append(anyMsgs, &anypb.Any{
TypeUrl: msg.TypeUrl,
Value: msg.Value,
})
}
}

body := &txv1beta1.TxBodyCompat{
Messages: anyMsgs,
Memo: w.GetMemo(),
TimeoutHeight: w.GetTimeoutHeight(),
ExtensionOptions: intoAnyV2(w.GetExtensionOptions()),
NonCriticalExtensionOptions: intoAnyV2(w.GetNonCriticalExtensionOptions()),
}
bodyBytes, err := marshalOption.Marshal(body)
if err != nil {
panic(fmt.Errorf("unable to marshal body: %w", err))
}
w.bodyBz = bodyBytes
return w.bodyBz
}
}

// if bodyBz is empty, then marshal the body. bodyBz will generally
// be set to nil whenever SetBody is called so the result of calling
// this method should always return the correct bytes. Note that after
// decoding bodyBz is derived from TxRaw so that it matches what was
// transmitted over the wire
var err error
w.bodyBz, err = proto.Marshal(w.tx.Body)
if err != nil {
panic(err)
}
}
return w.bodyBz
}
Expand Down Expand Up @@ -454,25 +466,6 @@ func (w *wrapper) setSignatureAtIndex(index int, sig []byte) {
}

func (w *wrapper) GetTx() authsigning.Tx {
if !w.tx.Body.Unordered && (w.tx.Body.TimeoutTimestamp.IsZero() || w.tx.Body.TimeoutTimestamp.Unix() == 0) {
anyMsgs, err := msgsV1toAnyV2(w.GetMsgs())
if err != nil {
panic(fmt.Errorf("unable to convert messages: %w", err))
}
body := &txv1beta1.TxBodyCompat{
Messages: anyMsgs,
Memo: w.GetMemo(),
TimeoutHeight: w.GetTimeoutHeight(),
ExtensionOptions: intoAnyV2(w.GetExtensionOptions()),
NonCriticalExtensionOptions: intoAnyV2(w.GetNonCriticalExtensionOptions()),
}
bodyBytes, err := marshalOption.Marshal(body)
if err != nil {
panic(fmt.Errorf("unable to marshal body: %w", err))
}

w.bodyBz = bodyBytes
}
return w
}

Expand Down

0 comments on commit bc3478b

Please sign in to comment.