Skip to content

Commit

Permalink
Merge pull request #982 from HorizenOfficial/is/signature_v_field_hotfix
Browse files Browse the repository at this point in the history
SDK-1687 - hotfix for signature V field in eth endpoints
  • Loading branch information
paolocappelletti authored Jan 25, 2024
2 parents 3eb90a9 + b39ef20 commit 1b2dd4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import io.horizen.evm.Address;
import io.horizen.evm.Hash;
import io.horizen.utils.BytesUtils;
import org.web3j.crypto.Sign;

import java.math.BigInteger;
import java.util.Objects;

Expand Down Expand Up @@ -71,7 +73,13 @@ public EthereumTransactionView(EthereumTransaction tx, EthereumReceipt receipt,
if (signature == null) {
v = null; r = null; s = null;
} else {
v = signature.getV();
if (tx.isEIP1559()) {
// isEIP1559 txs are defined to use 0 and 1 as their recovery
// id, subtract 27 to become equivalent to unprotected Homestead signatures.
v = signature.getV().subtract(BigInteger.valueOf(Sign.LOWER_REAL_V));
} else {
v = signature.getV();
}
r = signature.getR();
s = signature.getS();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"gasPrice": "0x342770c1",
"chainId": "0x10f447",
"accessList": [],
"v": "0x1c",
"v": "0x1",
"r": "0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s": "0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d"
}"""
Expand Down Expand Up @@ -143,7 +143,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -164,7 +164,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -187,7 +187,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -212,7 +212,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -239,7 +239,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -266,7 +266,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand All @@ -289,7 +289,7 @@ class EthServiceTest extends JUnitSuite with MockitoSugar with ReceiptFixture wi
"maxPriorityFeePerGas":"0x6ef91",
"maxFeePerGas":"0x3b9aca64",
"chainId":"0x7cd",
"v":"0x1c",
"v":"0x1",
"r":"0x805c658ac084be6da079d96bd4799bef3aa4578c8e57b97c3c6df9f581551023",
"s":"0x568277f09a64771f5b4588ff07f75725a8e40d2c641946eb645152dcd4c93f0d",
"accessList":[]
Expand Down

0 comments on commit 1b2dd4d

Please sign in to comment.