Skip to content

Commit

Permalink
fix: move SigBlockHeight from TxBody into AuthInfo (Finschia#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Oct 5, 2021
1 parent 81bdb22 commit f8e8635
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 265 deletions.
4 changes: 0 additions & 4 deletions baseapp/accountwgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ func (tx AccountLockTestTx) ValidateBasic() error {
return nil
}

func (tx AccountLockTestTx) GetSigBlockHeight() uint64 {
return 0
}

func newTestPrivKeys(num int) []*secp256k1.PrivKey {
privs := make([]*secp256k1.PrivKey, 0, num)
for i := 0; i < num; i++ {
Expand Down
2 changes: 1 addition & 1 deletion docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9469,6 +9469,7 @@ transaction.
| ----- | ---- | ----- | ----------- |
| `signer_infos` | [SignerInfo](#lbm.tx.v1.SignerInfo) | repeated | signer_infos defines the signing modes for the required signers. The number and order of elements must match the required signers from TxBody's messages. The first element is the primary signer and the one which pays the fee. |
| `fee` | [Fee](#lbm.tx.v1.Fee) | | Fee is the fee and gas limit for the transaction. The first signer is the primary signer and the one which pays the fee. The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation. |
| `sig_block_height` | [uint64](#uint64) | | sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_PERIOD` this is used for distinguish signatures instead of account number. this is mandatory. |



Expand Down Expand Up @@ -9605,7 +9606,6 @@ TxBody is the body of a transaction that all signers sign over.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is a list of messages to be executed. The required signers of those messages define the number and order of elements in AuthInfo's signer_infos and Tx's signatures. Each required signer address is added to the list only the first time it occurs. By convention, the first required signer (usually from the first message) is referred to as the primary signer and pays the fee for the whole transaction. |
| `sig_block_height` | [uint64](#uint64) | | sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_PERIOD` this is used for distinguish signatures instead of account number. this is mandatory. |
| `memo` | [string](#string) | | memo is any arbitrary memo to be added to the transaction |
| `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain |
| `extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, the transaction will be rejected |
Expand Down
12 changes: 6 additions & 6 deletions proto/lbm/tx/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ message TxBody {
// transaction.
repeated google.protobuf.Any messages = 1;

// sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_PERIOD`
// this is used for distinguish signatures instead of account number. this is mandatory.
uint64 sig_block_height = 2;

// memo is any arbitrary memo to be added to the transaction
string memo = 3;
string memo = 2;

// timeout is the block height after which this transaction will not
// be processed by the chain
uint64 timeout_height = 4;
uint64 timeout_height = 3;

// extension_options are arbitrary options that can be added by chains
// when the default options are not sufficient. If any of these are present
Expand All @@ -107,6 +103,10 @@ message AuthInfo {
// based on the cost of evaluating the body and doing signature verification
// of the signers. This can be estimated via simulation.
Fee fee = 2;

// sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_PERIOD`
// this is used for distinguish signatures instead of account number. this is mandatory.
uint64 sig_block_height = 3;
}

// SignerInfo describes the public key and signing mode of a single top-level
Expand Down
4 changes: 0 additions & 4 deletions server/mock/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func (tx kvstoreTx) GetSignBytes() []byte {
return tx.bytes
}

func (tx kvstoreTx) GetSigBlockHeight() uint64 {
return 0
}

// Should the app be calling this? Or only handlers?
func (tx kvstoreTx) ValidateBasic() error {
return nil
Expand Down
1 change: 0 additions & 1 deletion simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch
ChainID: chainID,
Sequence: accSeqs[i],
}
tx.SetSigBlockHeight(sbh[i])
signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
if err != nil {
panic(err)
Expand Down
258 changes: 111 additions & 147 deletions testutil/testdata/unknonwnproto.pb.go

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions testutil/testdata/unknonwnproto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,9 @@ message TestUpdatedTxRaw {

message TestUpdatedTxBody {
repeated google.protobuf.Any messages = 1;
uint64 sig_block_height = 2;
string memo = 3;
int64 timeout_height = 4;
uint64 some_new_field = 5;
string memo = 2;
int64 timeout_height = 3;
uint64 some_new_field = 4;
string some_new_field_non_critical_field = 1050;
repeated google.protobuf.Any extension_options = 1023;
repeated google.protobuf.Any non_critical_extension_options = 2047;
Expand Down
Loading

0 comments on commit f8e8635

Please sign in to comment.