From 6acd1dc24e27de088357a2029285f7ee25d053e1 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Wed, 23 Oct 2024 09:12:47 +0400 Subject: [PATCH] feat: agave v2 rpc: replace `getConfirmedBlock` with `getBlock` --- .../get-latest-validator-release-version.sh | 3 ++- src/connection.ts | 4 ++-- test/connection.test.ts | 22 +++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/get-latest-validator-release-version.sh b/scripts/get-latest-validator-release-version.sh index 9b45a20433e6..08f2332174c9 100755 --- a/scripts/get-latest-validator-release-version.sh +++ b/scripts/get-latest-validator-release-version.sh @@ -7,7 +7,8 @@ if [ -z $version ]; then exit 3 fi - echo $version + # echo $version + echo "v2.0.0" ) errorCode=$? if [ $errorCode -ne 0 ]; then diff --git a/src/connection.ts b/src/connection.ts index de07c83a68e2..31c3722981ed 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -5223,7 +5223,7 @@ export class Connection { commitment?: Finality, ): Promise { const args = this._buildArgsAtLeastConfirmed([slot], commitment); - const unsafeRes = await this._rpcRequest('getConfirmedBlock', args); + const unsafeRes = await this._rpcRequest('getBlock', args); const res = create(unsafeRes, GetConfirmedBlockRpcResult); if ('error' in res) { @@ -5329,7 +5329,7 @@ export class Connection { rewards: false, }, ); - const unsafeRes = await this._rpcRequest('getConfirmedBlock', args); + const unsafeRes = await this._rpcRequest('getBlock', args); const res = create(unsafeRes, GetBlockSignaturesRpcResult); if ('error' in res) { throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block'); diff --git a/test/connection.test.ts b/test/connection.test.ts index 0b708e385776..563a2805a417 100644 --- a/test/connection.test.ts +++ b/test/connection.test.ts @@ -2351,7 +2351,7 @@ describe('Connection', function () { await waitForSlot.call(this, connection, 1); await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [1], value: { blockTime: 1614281964, @@ -2433,7 +2433,7 @@ describe('Connection', function () { const mockSignature = '5SHZ9NwpnS9zYnauN7pnuborKf39zGMr11XpMC59VvRSeDJNcnYLecmdxXCVuBFPNQLdCBBjyZiNCL4KoHKr3tvz'; await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [slot, {transactionDetails: 'signatures', rewards: false}], value: { blockTime: 1614281964, @@ -2449,7 +2449,7 @@ describe('Connection', function () { value: 123, }); await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [slot + 2, {transactionDetails: 'signatures', rewards: false}], value: { blockTime: 1614281964, @@ -2482,7 +2482,7 @@ describe('Connection', function () { const badSlot = Number.MAX_SAFE_INTEGER - 1; await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [badSlot - 1, {transactionDetails: 'signatures', rewards: false}], error: {message: 'Block not available for slot ' + badSlot}, }); @@ -2531,7 +2531,7 @@ describe('Connection', function () { await waitForSlot.call(this, connection, 1); await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [1], value: { blockTime: 1614281964, @@ -2640,7 +2640,7 @@ describe('Connection', function () { await waitForSlot.call(this, connection, 1); await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [1], value: { blockTime: 1614281964, @@ -3294,7 +3294,7 @@ describe('Connection', function () { await waitForSlot.call(this, connection, 1); await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [1], value: { blockTime: 1614281964, @@ -4252,7 +4252,7 @@ describe('Connection', function () { it('gets the genesis block', async function () { await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [0], value: { blockHeight: 0, @@ -4290,7 +4290,7 @@ describe('Connection', function () { it('gets a block having a parent', async function () { // Mock parent of block with transaction. await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [0], value: { blockHeight: 0, @@ -4303,7 +4303,7 @@ describe('Connection', function () { }); // Mock block with transaction. await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [1], value: { blockTime: 1614281964, @@ -4390,7 +4390,7 @@ describe('Connection', function () { .null; await mockRpcResponse({ - method: 'getConfirmedBlock', + method: 'getBlock', params: [Number.MAX_SAFE_INTEGER], error: { message: `Block not available for slot ${Number.MAX_SAFE_INTEGER}`,