Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracers/prestate: fix the balance track of payer and sender #436

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Apr 15, 2024

In sponsored transaction, payer of gas fee can be different from sender. This commit fixes the prestate tracer to correctly track the balance of payer and sender in sponsored transaction.

Test with a sponsored transaction:

	{
		"from": "0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718",
		"to": "0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718",
		"payer": "0xd24d87ddc1917165435b306aac68d99e0f49a3fa",
		"value": "0x0",
		"gas": "0x7530",
		"gasPrice": "0x4a817c800",
	}

Request:

	{
		"jsonrpc": "2.0",
		"method": "debug_traceTransaction",
		"params": [
			"0xf4794f0301f3235bdbe6d68a775ec3191cae02e8125e3a43b7cbe8457cfc5287",
			{
				"tracer": "prestateTracer",
				"tracerConfig": {
					"diffMode": true
				}
			}
		],
		"id": 1
	}

Before:

	{
		"jsonrpc": "2.0",
		"id": 1,
		"result": {
			"post": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x0",
					"nonce": 1
				}
			},
			"pre": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x221b262dd8000"
				}
			}
		}
	}

After:

	{
		"jsonrpc": "2.0",
		"id": 1,
		"result": {
			"post": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"nonce": 1
				},
				"0xd24d87ddc1917165435b306aac68d99e0f49a3fa": {
					"balance": "0xd2c58d581b3cbfd4e553"
				}
			},
			"pre": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x0"
				},
				"0xd24d87ddc1917165435b306aac68d99e0f49a3fa": {
					"balance": "0xd2c58d5999399ea32553",
					"nonce": 610
				}
			}
		}
	}

In sponsored transaction, payer of gas fee can be different from sender. This
commit fixes the prestate tracer to correctly track the balance of payer and
sender in sponsored transaction.

Test with a sponsored transaction:
	{
		"from": "0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718",
		"to": "0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718",
		"payer": "0xd24d87ddc1917165435b306aac68d99e0f49a3fa",
		"value": "0x0",
		"gas": "0x7530",
		"gasPrice": "0x4a817c800",
	}

Request:
	{
		"jsonrpc": "2.0",
		"method": "debug_traceTransaction",
		"params": [
			"0xf4794f0301f3235bdbe6d68a775ec3191cae02e8125e3a43b7cbe8457cfc5287",
			{
				"tracer": "prestateTracer",
				"tracerConfig": {
					"diffMode": true
				}
			}
		],
		"id": 1
	}

Before:
	{
		"jsonrpc": "2.0",
		"id": 1,
		"result": {
			"post": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x0",
					"nonce": 1
				}
			},
			"pre": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x221b262dd8000"
				}
			}
		}
	}

After:
	{
		"jsonrpc": "2.0",
		"id": 1,
		"result": {
			"post": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"nonce": 1
				},
				"0xd24d87ddc1917165435b306aac68d99e0f49a3fa": {
					"balance": "0xd2c58d581b3cbfd4e553"
				}
			},
			"pre": {
				"0xc89e2d7e38eb36d5213c2c505edd2d8974cd8718": {
					"balance": "0x0"
				},
				"0xd24d87ddc1917165435b306aac68d99e0f49a3fa": {
					"balance": "0xd2c58d5999399ea32553",
					"nonce": 610
				}
			}
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant